Skip to main content
This guide covers OpenCode CLI / TUI only. It includes OpenCode installation, creating or editing 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:
Or install with npm:

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 opencode.json, paste the following:
Replace:
  • YOUR_A2AGENT_API_KEY with your real A2Agent API key.
  • YOUR_MODEL_ID_1, YOUR_MODEL_ID_2, and YOUR_MODEL_ID_3 with exact model IDs listed on the A2Agent Models page
  • A2Agent Model 1 and the other display names if desired.
Then save opencode.json
4

Start OpenCode CLI

Still in the project directory, run:
Inside the OpenCode session, enter:
Select a model under a2agent.

Troubleshooting

Check that:
  • The key came from the A2Agent dashboard.
  • The key was pasted completely, without leading/trailing spaces or line breaks.
  • You did not enter a login password, an OpenCode key, or a key from another provider.
  • If you use an environment variable, A2AGENT_API_KEY exactly matches {env:A2AGENT_API_KEY}.
Check:
Confirm that:
  • The top-level field is provider, not providers.
  • The provider ID is a2agent.
  • npm is @ai-sdk/openai-compatible.
  • options.baseURL is https://api.a2agent.me/v1.
  • models contains at least one model ID.
  • You start OpenCode from the directory that contains this opencode.json.
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.
Copy the current model ID from A2Agent Models, replace the corresponding key under models, restart OpenCode, and run:
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.

Official references