langchain - 💡(How to fix) Fix perplexity: Add use_responses_api flag to ChatPerplexity for Agent API support [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fixed

RAW_BUFFERClick to expand / collapse

Privileged issue

Feature request

Add a use_responses_api: bool | None = None flag to ChatPerplexity in libs/partners/perplexity/ so requests can be routed through Perplexity's Agent API (the Perplexity-flavored Responses API) in addition to the existing Chat Completions endpoint. Mirrors ChatOpenAI.use_responses_api.

Motivation

Perplexity exposes two HTTP surfaces from the same SDK client object:

  • client.chat.completions.create() → Chat Completions (today's ChatPerplexity path)
  • client.responses.create() → Agent API (POST /v1/agent, alias POST /v1/responses)

The Agent API supports built-in tools (web_search, fetch_url, finance_search, people_search), instructions, input, previous_response_id, and include — none of which exist on Chat Completions. Today ChatPerplexity only calls Chat Completions, so users who want the Agent API have to drop down to the raw SDK. This is the same situation ChatOpenAI solved with its use_responses_api flag.

Proposal

  • New optional field use_responses_api: bool | None = None on ChatPerplexity, behavior mirroring ChatOpenAI:
    • True → always route through client.responses.create()
    • False → always route through client.chat.completions.create()
    • None (default) → auto-detect based on payload: True if the request uses any built-in tool (any tools[*] whose type is not "function") or any of previous_response_id, instructions, input, include; False otherwise.
  • Backwards-compatible: every existing ChatPerplexity(model="sonar", ...) call keeps hitting client.chat.completions.create() unchanged.
  • No new class. Single ChatPerplexity keeps parity with the single-class ChatOpenAI model that LangChain users already understand.

Why a flag, not a new class

ChatPerplexityAgent would duplicate ~90% of ChatPerplexity for no win, and would break parity with how the OpenAI integration handles the same two-surfaces-one-SDK situation.

System Info

N/A — net new feature.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

langchain - 💡(How to fix) Fix perplexity: Add use_responses_api flag to ChatPerplexity for Agent API support [1 pull requests]