langchain - ✅(Solved) Fix Integration with Perplexity Agent API [1 pull requests, 1 comments, 2 participants]

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…
GitHub stats
langchain-ai/langchain#36830Fetched 2026-04-17 08:26:48
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
labeled ×3commented ×1issue_type_added ×1

PR fix notes

PR #36856: feat(perplexity): add use_responses_api support for Perplexity Agent API

Description (problem / solution / changelog)

Fixes #36830

Adds use_responses_api: bool = False to ChatPerplexity to support the Perplexity Agent API, giving access to third-party models (OpenAI, Anthropic, Google) with Perplexity web search under one API key. Existing Sonar behaviour is unchanged — flag defaults to False.

Verification: Ran make test from libs/partners/perplexity — 60 passed, 1 skipped (pre-existing). Added 8 unit tests covering message conversion, invoke routing, system-message-as-instructions, and streaming.

Social handles (optional)

LinkedIn: https://linkedin.com/in/arya-kaushal-4b7b58258

Changed files

  • libs/partners/perplexity/langchain_perplexity/chat_models.py (modified, +385/-0)
  • libs/partners/perplexity/tests/unit_tests/test_chat_models.py (modified, +178/-0)
RAW_BUFFERClick to expand / collapse

Submission checklist

  • This is a feature request, not a bug report or usage question.
  • I added a clear and descriptive title that summarizes the feature request.
  • I used the GitHub search to find a similar feature request and didn't find it.
  • I checked the LangChain documentation and API reference to see if this feature already exists.
  • This is not related to the langchain-community package.

Package (Required)

  • langchain
  • langchain-openai
  • langchain-anthropic
  • langchain-classic
  • langchain-core
  • langchain-model-profiles
  • langchain-tests
  • langchain-text-splitters
  • langchain-chroma
  • langchain-deepseek
  • langchain-exa
  • langchain-fireworks
  • langchain-groq
  • langchain-huggingface
  • langchain-mistralai
  • langchain-nomic
  • langchain-ollama
  • langchain-openrouter
  • langchain-perplexity
  • langchain-qdrant
  • langchain-xai
  • Other / not sure / general

Feature Description

Currently, LangChain is only integrated with Perplexity's Sonar API, which provides access to the Sonar, Sonar Pro, and Sonar Deep Research models. The Agent API, on the other hand, provides models from other providers such as Google, OpenAI, and Anthropic, allowing their integration with Perplexity Search capabilities.

I propose the addition of an argument to the ChatPerplexity class in langchain-perplexity in order to provide access to the Agent API.

Use Case

This feature can be used by developers who want to integrate the search capabilities of Perplexity into models from other providers without needing to manage different billing accounts.

Proposed Solution

Both the Sonar and Agent APIs are compatible with the OpenAI SDK, but the main difference is that Sonar uses the completions endpoint, while the Agent API accesses the newer Responses API. Currently, ChatPerplexity only communicates through the completions endpoint, limiting its usage to Sonar models.

A possible solution is to implement a use_responses_api argument in the ChatPerplexity class, analogous to the one in ChatOpenAI. Another solution is to use the Perplexity SDK (which is very similar to the OpenAI SDK).

Alternatives Considered

No response

Additional Context

No response

extent analysis

TL;DR

Add a use_responses_api argument to the ChatPerplexity class to enable access to the Agent API and models from other providers.

Guidance

  • Implement the use_responses_api argument in the ChatPerplexity class, similar to the one in ChatOpenAI, to switch between the completions endpoint and the Responses API.
  • Consider using the Perplexity SDK, which is similar to the OpenAI SDK, as an alternative solution.
  • Verify the compatibility of the proposed solution with the OpenAI SDK and the Perplexity Agent API.
  • Test the implementation with different models and providers to ensure seamless integration.

Example

No code snippet is provided due to the lack of specific implementation details in the issue.

Notes

The proposed solution assumes that the Perplexity Agent API and the OpenAI SDK are compatible, and that the use_responses_api argument can be implemented in a way that is analogous to the one in ChatOpenAI.

Recommendation

Apply the workaround by implementing the use_responses_api argument, as it provides a flexible solution to access different models and providers through the Agent API.

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