Add Perplexity as a first-class API provider#9762
Open
jliounis wants to merge 1 commit intoKilo-Org:mainfrom
Open
Add Perplexity as a first-class API provider#9762jliounis wants to merge 1 commit intoKilo-Org:mainfrom
jliounis wants to merge 1 commit intoKilo-Org:mainfrom
Conversation
Wire Perplexity (Sonar) as a first-class OpenAI-compatible chat provider. The provider entry already lives in the upstream models.dev snapshot — this commit adds Kilo-side customization so: - A `perplexity` custom loader supports `PERPLEXITY_API_KEY` with a `PPLX_API_KEY` fallback, and resolves the key from config / Auth / env in that order. - Every outgoing request carries the `X-Pplx-Integration: kilo-code/<version>` attribution header, set centrally in `patchCustomLoaderResult` so it cannot be missed at a call site. - The provider auto-loads when an API key is present, exposing the 4 chat models in the snapshot (sonar, sonar-pro, sonar-reasoning-pro, sonar-deep-research). Default chat model is `sonar-pro`. Mirrors the Cline provider PR (cline/cline#10462) and the existing sibling-provider conventions in this repo (cerebras, anthropic). See https://docs.perplexity.ai for the API surface. Co-authored by mirroring sibling provider conventions in this repo.
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Reviewed by gpt-5.5-2026-04-23 · 1,159,496 tokens |
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 (Sonar Agent API) as a first-class provider in Kilo Code, alongside existing OpenAI-compatible providers like xAI, Cerebras, and Fireworks.
The provider entry already lives in the upstream models.dev snapshot (4 chat models —
sonar,sonar-pro,sonar-reasoning-pro,sonar-deep-research; default chat model issonar-pro; 128k context for the Sonar tier and 200k forsonar-pro). This PR adds the Kilo-side customizations needed to ship it as a first-class integration:kiloCustomLoadersthat:PERPLEXITY_API_KEY→PPLX_API_KEYfallback chainpatchCustomLoaderResult— every outgoing request carriesX-Pplx-Integration: kilo-code/<package-version>. Single point, never sprinkled across call sites.patchCustomLoaderResultbranch, env-var loading from bothPERPLEXITY_API_KEYand thePPLX_API_KEYfallback, and the presence of the attribution header on the merged options.OpenAI-compatible base URL:
https://api.perplexity.ai. Auth:Authorization: Bearer <PERPLEXITY_API_KEY>. Branding follows the Perplexity guidelines — never "Sonar API".Pattern reference
This mirrors the Perplexity provider PR for Cline, adapted to Kilo Code's opencode-fork architecture (custom loaders +
patchCustomLoaderResultrather than a per-providerHandlerclass). The header injection follows the existingcerebrasX-Cerebras-3rd-Party-Integrationprecedent in the same file.Co-authored by mirroring sibling provider conventions in this repo.
Docs
sonar-proTest plan
bun test packages/opencode/test/kilocode/perplexity-provider.test.ts(added in this PR)PERPLEXITY_API_KEYand verifykilolistsperplexityprovider withsonar-promodelPERPLEXITY_API_KEY, setPPLX_API_KEY, confirm fallback path also auto-loadsX-Pplx-Integration: kilo-code/<version>is present