Overview
OpenCode is an open-source AI coding agent for your terminal, IDE, or desktop. The Perplexity Agent API is compatible with the OpenAI Responses API and exposes frontier models from OpenAI, Anthropic, Google, xAI, and Perplexity through a single endpoint. 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 implements the OpenAI Responses API, so you configure it in OpenCode as a custom provider using@ai-sdk/open-responses pointed at Perplexity’s /v1/responses endpoint.
1
Install OpenCode
Follow the OpenCode install guide for your platform (macOS, Linux, Windows).
2
Get a Perplexity API key
Get API Key
Generate your Perplexity API key from the API portal.
3
Configure OpenCode
Add the Perplexity Agent API as a provider in your
opencode.json (or ~/.config/opencode/config.json). See the configuration below.4
Verify
Run
/models to confirm the Perplexity Agent models appear in the selector.Provider Configuration
The@ai-sdk/open-responses provider is built for servers that implement the OpenAI Responses API — exactly the dialect the Agent API speaks. Point its url at Perplexity’s /v1/responses endpoint and declare the models you want in the 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: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-8.
Multi-Agent Setup
Assign different Agent API models to different OpenCode agents — all through one Perplexity key. Here a primary coder delegates to a lighter, read-only subagent:coder owns the filesystem (write, edit, bash) while the read-only researcher runs on a separate model for analysis and summarization. Swap either model for any Agent API model.
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, xAI, and Perplexity without managing separate accounts.
- OpenAI Responses-compatible — drop-in for any OpenCode provider slot that speaks
/v1/responses.
Links & Resources
Agent API Quickstart
Send your first Agent API request.
Agent API Models
Full model catalog with pricing.
Perplexity SDK
Call the Agent API directly for presets, tools, and full control.
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