opencode.json, adding the provider, configuring the API key, selecting a model, and troubleshooting common connection errors. It does not cover other clients or desktop applications.
Prerequisites
OpenCode CLI is installed. Download it from opencode.ai. On Linux/WSL, use the official installer:- You have an A2Agent API key. Register at a2agent.me/register, then create a key in the A2Agent dashboard.
- A model ID listed on the A2Agent Models page
A2Agent connection values
For an OpenAI-compatible
/v1/chat/completions endpoint, OpenCode’s provider documentation uses @ai-sdk/openai-compatible with the provider’s options.baseURL setting.
Setup
1
Go to your project directory
In a terminal, enter the project where you want to use OpenCode:
2
Open or create opencode.json
From the project root, run:If the file does not exist,
nano creates it. If it exists, nano opens it for editing.3
Paste the A2Agent provider configuration
If this is a new Replace:
opencode.json, paste the following:YOUR_A2AGENT_API_KEYwith your real A2Agent API key.YOUR_MODEL_ID_1,YOUR_MODEL_ID_2, andYOUR_MODEL_ID_3with exact model IDs listed on the A2Agent Models pageA2Agent Model 1and the other display names if desired.
opencode.json4
Start OpenCode CLI
Still in the project directory, run:Inside the OpenCode session, enter:Select a model under
a2agent.Troubleshooting
The provider does not appear in /models
The provider does not appear in /models
Check:Confirm that:
- The top-level field is
provider, notproviders. - The provider ID is
a2agent. npmis@ai-sdk/openai-compatible.options.baseURLishttps://api.a2agent.me/v1.modelscontains at least one model ID.- You start OpenCode from the directory that contains this
opencode.json.
404 or endpoint path errors
404 or endpoint path errors
Use this standard Base URL:For an OpenAI Chat Completions-compatible endpoint, use:Do not use a Markdown-formatted URL or duplicate
/v1 in the address.Model not found
Model not found
Copy the current model ID from A2Agent Models, replace the corresponding key under Model IDs are examples only. Model availability, limits, and pricing can change; when adding or replacing a model, use the exact ID currently shown in your A2Agent account.
models, restart OpenCode, and run: