feat: add Perplexity as a first-class API provider#12230
Open
james-pplx wants to merge 1 commit intoRooCodeInc:mainfrom
Open
feat: add Perplexity as a first-class API provider#12230james-pplx wants to merge 1 commit intoRooCodeInc:mainfrom
james-pplx wants to merge 1 commit intoRooCodeInc:mainfrom
Conversation
Introduce a new Perplexity provider that targets Perplexity's OpenAI-compatible chat-completions endpoint at https://api.perplexity.ai. Models exposed: sonar, sonar-pro, sonar-reasoning, sonar-reasoning-pro (all 128k context). API key resolution order: 1. perplexityApiKey from settings 2. PERPLEXITY_API_KEY env var 3. PPLX_API_KEY env var (fallback) Wired into the provider registry (packages/types), api factory, profile validation, webview settings UI, model picker, validation, and English locale strings. Tests cover construction, base URL/auth, env-var fallbacks, model selection, streaming, and error propagation.
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.
Summary
Adds Perplexity as a first-class API provider in Roo Code, targeting Perplexity's OpenAI-compatible chat-completions endpoint at
https://api.perplexity.ai.Models exposed (all 128k context):
sonarsonar-pro(default)sonar-reasoningsonar-reasoning-proAPI key resolution order:
perplexityApiKeyfrom settingsPERPLEXITY_API_KEYenv varPPLX_API_KEYenv var (fallback)Changes
packages/types/src/providers/perplexity.ts):PerplexityModelId,perplexityModels,perplexityDefaultModelId.packages/types/src/provider-settings.ts):perplexityadded to theProviderNameunion,perplexitySchemaadded to the discriminated union and merged schema, registered inmodelIdKeysByProviderandMODELS_BY_PROVIDER.packages/types/src/global-settings.ts):perplexityApiKeyadded toSECRET_STATE_KEYS.src/api/providers/perplexity.ts):PerplexityHandlerextendingBaseOpenAiCompatibleProvider, withresolvePerplexityApiKeyhelper for env-var fallback.src/api/index.ts): wired intocreateHandlerForProvider.src/shared/ProfileValidator.ts):perplexityresolves toapiModelId.webview-ui/src/components/settings/providers/Perplexity.tsx): API-key field + sign-up link, mirroringFireworks.tsx. Wired intoApiOptions.tsx,constants.ts,providerModelConfig.ts,useSelectedModel.ts, andvalidate.ts.webview-ui/src/i18n/locales/en/settings.json):perplexityApiKey/getPerplexityApiKeystrings added.Testing
src/api/providers/__tests__/perplexity.spec.tscovers:https://api.perplexity.ai).PERPLEXITY_API_KEYenv-var fallback.PPLX_API_KEYenv-var secondary fallback.resolvePerplexityApiKeyreturns undefined for empty/unset cases.sonar-pro.sonar-reasoning-proreturns itsModelInfo.createMessagestreams text content.createMessagepasses the configured model id to the upstream client.createMessagepropagates upstream errors.Run with:
npx vitest run api/providers/__tests__/perplexity.spec.tsTest plan
perplexity.spec.tsand passes.perplexityApiKeyin settings, select a Perplexity model, send a message, verify streaming response.PERPLEXITY_API_KEYenv, restart extension, verify provider works via env fallback.