Run OpenCode on any model
Open-source AI coding agent - add your Antseed gateway as a custom provider, or launch it with antseed opencode.
OpenCode is an MIT-licensed terminal coding agent built on the Vercel AI SDK. It supports 75+ providers out of the box and lets you register custom ones via opencode.json.
Antseed plugs in as a custom provider using the @ai-sdk/openai-compatible adapter - the same one OpenCode recommends for any OpenAI-compatible endpoint. The recommended endpoint is a gateway: set its URL as baseURL and read its key from ANTSEED_API_KEY, and OpenCode works from any machine with its own budget and usage log.
When OpenCode runs on the same computer as a buyer, antseed opencode writes a temporary opencode.json that points at the local buyer proxy, uses it for the child process, and deletes it when the session exits.
Each model you want to use must be listed under models. The id has to match one returned by GET /v1/models - the network-wide model list, aggregated across all sellers.
Run Antseed first
Every integration needs an Antseed endpoint: a gateway, best on a small server so every tool on every machine can reach it, or the local buyer proxy (same computer only). One-time setup, a few minutes.
Step 1
Install OpenCode
- Install OpenCodenpm install -g opencode-ai
- Verify it runsopencode --version
Step 2
Point OpenCode at Antseed
Recommended: a gateway
| ANTSEED_BASE_URL | https://gateway.example.com/v1 |
| ANTSEED_API_KEY | antseed_… |
Show as shell exports
Your gateway's base URL, ending in /v1, and an API key from the Keys page of its console. Recommended: a gateway on a server, which every machine can reach. A gateway on this computer is http://localhost:8379/v1; publish it with a tunnel (antseed tunnel start) for other machines. No gateway yet: see Run Antseed first above. Export both in the shell that starts OpenCode.
Set baseURL to your gateway URL ending in /v1, and limit.context to each model's context length: OpenCode uses it to decide when to compact the conversation. {env:ANTSEED_API_KEY} makes OpenCode read the key from the environment, so it stays out of the file. For the local buyer proxy, use http://localhost:8377/v1 and "apiKey": "antseed".
Same computer, no gateway: the local buyer proxy
The wrapper resolves the local proxy URL, writes a temporary OpenCode config with one Antseed model, sets OPENCODE_CONFIG for the child process, and forwards extra OpenCode args. It always targets a buyer proxy; for a gateway use the config above.
Step 3
Pick a model
Use model ids returned by GET /v1/models as the keys under models. antseed opencode --model <model-id> generates a temporary config for that one id. Route to a specific peer by prefixing its advertised service id: <peerId>@<service-id>.
The full list is every model on the network. Run GET /v1/models on your endpoint, antseed network browse, or open the live network page to see what's available right now.
Verify
Test it
- Confirm the endpoint lists the same ids your config referencescurl -s "$ANTSEED_BASE_URL/models" -H "Authorization: Bearer $ANTSEED_API_KEY" | jq '.data[].id'Example response"deepseek/deepseek-v4.1-flash" "moonshotai/kimi-k3" "z-ai/glm-5.2" "z-ai/glm-5.3-flash"
Add or remove entries under
modelsinopencode.jsonso they match this list. Against the local buyer proxy:curl -s http://localhost:8377/v1/models. - Launch OpenCode and pick an Antseed modelopencode
Pick one of the Antseed entries from
/models. Through the local buyer proxy instead:antseed opencode --model deepseek-v4.1-flash(extra OpenCode args are forwarded, soantseed opencode --model deepseek-v4.1-flash runworks too).
How OpenCode talks to Antseed
- Wire format sent by OpenCode:
OpenAI Chat Completions(hits/v1/chat/completionson your gateway or buyer proxy) - Best-fit services: any service whose
protocolsarray containsopenai-chat-completions. That's what the peer advertises as natively-supported - zero translation overhead, no transform edge cases. - How to check a peer: run
antseed network peer <peerId> --jsonand look atproviderServiceApiProtocols[provider].services[service]. The browse command exposes the same field per peer. - What happens when protocols don't match: Antseed's
@antseed/api-adaptertranslates between OpenAI Chat Completions and the service's native protocol on the fly, inside the buyer. So a request from OpenCode can still reach a service that only advertisesanthropic-messages- just with a small transform step. - One known caveat: services whose only advertised protocol is
openai-responsesrequire streaming. If OpenCode sends a non-streaming request and Antseed routes it to one of those services, the call fails withHTTP 400: Stream must be set to true. Pick a service whoseprotocolsincludesopenai-chat-completions(or another non-responses protocol) to avoid this.
If it goes wrong
Troubleshooting
- Antseed doesn't appear in
/connector/modelsMake sureopencode.jsonis in your project root (or~/.config/opencode/opencode.json) and that the JSON is valid - a stray comma silently disables the whole provider. Withantseed opencode, pass a catalog model id via--model. 401from the gatewayExportANTSEED_API_KEYwith your gateway key in the shell that starts OpenCode, and keep"apiKey": "{env:ANTSEED_API_KEY}"inoptions.- Model is listed but every call returns
model_not_foundNo seller your routing policy allows currently offers that model. CheckGET /v1/modelsand update themodelskeys inopencode.jsonto match.
Reference
Links
Same category