Documentation Index
Fetch the complete documentation index at: https://docs.perplexity.ai/llms.txt
Use this file to discover all available pages before exploring further.
Overview
OpenCode is an open-source AI coding agent for your terminal, IDE, or desktop. The Perplexity Agent API is OpenAI-compatible and exposes frontier models from OpenAI, Anthropic, Google, xAI, and Perplexity through a single endpoint, with optionalweb_search and fetch_url tools and Perplexity’s research presets.
Wiring OpenCode to the Agent API means you can swap any frontier model into your coding agent or research subagent — without juggling separate provider accounts.
OpenCode ships with multi-agent orchestration: you can configure a
primary agent for coding and subagent agents for specialized tasks. Learn more at opencode.ai.Setup
The Agent API is OpenAI-compatible, so you configure it in OpenCode as a custom provider using@ai-sdk/openai-compatible.
Install OpenCode
Follow the OpenCode install guide for your platform (macOS, Linux, Windows).
Get a Perplexity API key
Get API Key
Generate your Perplexity API key from the API portal.
Configure OpenCode
Add the Perplexity Agent API as a provider in your
opencode.json (or ~/.config/opencode/config.json). See the configuration below.Provider Configuration
OpenCode supports OpenAI-compatible providers out of the box. Point it athttps://api.perplexity.ai/v1 and declare the models you want available in the model picker:
Available Models
The Agent API routes to models from multiple providers. The full canonical list lives on the models page; the most useful identifiers for coding work:| Model ID | Best for |
|---|---|
openai/gpt-5.2 | Deep reasoning, long-horizon coding tasks |
openai/gpt-5.1 | General-purpose coding agent |
openai/gpt-5-mini | Fast, cheap coding completions |
anthropic/claude-opus-4-7 | Highest-quality code review and architecture |
anthropic/claude-sonnet-4-6 | Balanced coding + tool use |
google/gemini-3.1-pro-preview | Long-context refactors |
xai/grok-4.20-non-reasoning | Low-latency edits |
fast-search, pro-search, deep-research, advanced-deep-research) as model IDs to get pre-tuned web-search behavior.
Use as a Primary Coding Model
Set any Agent API model as your default inopencode.json:
<providerId>/<modelId>, so the full identifier is perplexity-agent/anthropic/claude-opus-4-7.
Multi-Agent Setup: Research Subagent with Web Tools
The Agent API’sweb_search and fetch_url tools make it a strong fit for a dedicated research subagent. The coder owns the filesystem; the researcher owns the open web.
deep-research preset, every web lookup includes citations, multi-step retrieval, and the fetch_url tool for reading specific docs pages. The coder calls into it whenever it needs current documentation or API references.
Verify the wiring:
Why the Agent API
The Agent API is purpose-built for agent loops:- One key, every model — switch between OpenAI, Anthropic, Google, and xAI without managing separate accounts.
- OpenAI-compatible — drop-in for any OpenCode provider slot that speaks
/v1/responsesor/v1/chat/completions. - Built-in web tools — opt into
web_searchandfetch_urlper request, no MCP setup required. - Research presets —
pro-search,deep-research,advanced-deep-researchgive your subagents tuned retrieval behavior out of the box.
Links & Resources
Agent API Quickstart
Send your first Agent API request.
Agent API Models
Full model catalog with pricing.
Research Presets
Pre-tuned model + tool configurations.
OpenAI Compatibility
Use Agent API with any OpenAI SDK.
OpenCode Providers
OpenCode custom provider reference.
OpenCode Docs
Official OpenCode documentation.
Support
Need help with the integration?- Browse the OpenCode documentation
- Review our FAQ