feat(llm): add Perplexity as a model provider#12259
Open
james-pplx wants to merge 1 commit intocontinuedev:mainfrom
Open
feat(llm): add Perplexity as a model provider#12259james-pplx wants to merge 1 commit intocontinuedev:mainfrom
james-pplx wants to merge 1 commit intocontinuedev:mainfrom
Conversation
Adds Perplexity as a first-class provider, exposing the Sonar family of chat-completion models (sonar, sonar-pro, sonar-reasoning, sonar-reasoning-pro). The Perplexity API is OpenAI-compatible, so the provider extends the existing OpenAI class with a custom apiBase. Sonar models include built-in web search, which is particularly useful for coding agents that need to research up-to-date documentation or APIs while answering. - core/llm/llms/Perplexity.ts: provider class extending OpenAI - core/llm/llms/index.ts: registered in LLMClasses - core/llm/autodetect.ts: added "perplexity" to providers using OpenAI templating - packages/openai-adapters: provider registered in schema and factory - extensions/vscode/config_schema.json: enum, model list, and description - docs: new provider page and overview/sidebar entries - core/llm/llms/Perplexity.vitest.ts: unit tests via createOpenAISubclassTests See https://docs.perplexity.ai/docs/getting-started for API details.
Contributor
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Continue's provider list covers 25+ inference services but Perplexity is missing. Perplexity's Sonar family (
sonar,sonar-pro,sonar-reasoning,sonar-reasoning-pro) ships with built-in web search, which is particularly relevant for coding agents that need to research up-to-date documentation or APIs while answering — a common workflow in Continue.The Perplexity API is OpenAI-compatible, so this PR mirrors the pattern used by other OpenAI-compatible providers like
Groq,Together,OpenRouter, andInception: the provider class subclassesOpenAIand only overridesproviderNameandapiBase. No custom request/response transformation is needed.Changes
core/llm/llms/Perplexity.ts— provider class extendingOpenAIwithapiBase = "https://api.perplexity.ai/"and defaultmodel: "sonar"core/llm/llms/index.ts— registered inLLMClasses(import + array entry)core/llm/autodetect.ts— added"perplexity"to the list of providers that use OpenAI templatingpackages/openai-adapters/src/types.ts— added"perplexity"to theOpenAIConfigSchemaunionpackages/openai-adapters/src/index.ts— added thecase "perplexity"factory branchextensions/vscode/config_schema.json— added"perplexity"to the provider enum, the modelif/thenblock (Sonar models +AUTODETECT), and a markdown descriptiondocs/customize/model-providers/more/perplexity.mdx— new provider page modeled ongroq.mdxdocs/customize/model-providers/overview.mdx— added to the hosted-services tabledocs/docs.json— added to the More providers sidebar groupcore/llm/llms/Perplexity.vitest.ts— tests via the existingcreateOpenAISubclassTestshelperTests
core/llm/llms/Perplexity.vitest.tscallscreateOpenAISubclassTests(Perplexity, ...), the same helper used by Groq, Together, and other OpenAI-compatible providers. The helper generates 7 cases covering: providerName, default API base,streamChat,chat,streamComplete,complete, andembedagainst a mocked fetch. Run with:```
cd core && npm run vitest -- llms/Perplexity
```
References
Summary by cubic
Adds Perplexity as a first-class LLM provider using its OpenAI-compatible API, with default
sonarmodel. This enables Sonar models (sonar,sonar-pro,sonar-reasoning,sonar-reasoning-pro) with built-in web search for fresher answers.Perplexityprovider extendingOpenAIwithapiBase: "https://api.perplexity.ai/"and defaultmodel: "sonar".LLMClassesand added to OpenAI-templated autodetect providers.packages/openai-adapterstypes and factory to supportperplexity.config_schema.jsonwith provider enum, Sonar model list (AUTODETECTsupported), and help text.createOpenAISubclassTestsfor core chat/complete/embed paths.Written for commit f4bdacd. Summary will update on new commits. Review in cubic