Skip to main content
OC

OpenCode

Open-source AI coding agent — launch through AntSeed with `antseed opencode`.

Coding agentsOpenAI Chat Completions~2 min

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 opencode` creates that custom provider config in a temporary opencode.json, points OpenCode at it for the child process, and deletes it when the session exits. Manual project or global config still works if you want OpenCode to remember AntSeed outside the wrapper.

AntSeed plugs in as a custom provider using the @ai-sdk/openai-compatible adapter — the same one OpenCode recommends for any OpenAI-compatible endpoint (LM Studio, llama.cpp, Atomic Chat, etc.). No ANTHROPIC_BASE_URL: OpenCode reads provider config from JSON.

Each model you want to use must be listed under models. The id has to match what the buyer proxy returns from GET /v1/models — i.e. a service id advertised by your currently-pinned peer.

Run AntSeed first

Every integration assumes a buyer proxy at http://localhost:8377. One-time setup, ~2 minutes.

Step 1

Install OpenCode

  • Install OpenCode
    npm install -g opencode-ai
  • Verify it runs
    opencode --version

Step 2

Point OpenCode at AntSeed

antseed opencode --model gpt-oss-120b

Recommended: the wrapper resolves the proxy URL, writes a temporary OpenCode config with one AntSeed model, sets `OPENCODE_CONFIG` for the child process, and forwards extra OpenCode args.

opencode.json (project root, or ~/.config/opencode/opencode.json for global)
{ "$schema": "https://opencode.ai/config.json", "provider": { "antseed": { "npm": "@ai-sdk/openai-compatible", "name": "AntSeed (peer-to-peer)", "options": { "baseURL": "http://localhost:8377/v1", "apiKey": "antseed" }, "models": { "claude-sonnet-4-6": { "name": "Claude Sonnet 4.6 (via AntSeed)" }, "deepseek-v4-flash": { "name": "DeepSeek v4 Flash (via AntSeed)" }, "gpt-oss-120b": { "name": "gpt-oss 120B (via AntSeed)" } } } } }

Manual equivalent if you want OpenCode to keep AntSeed in its normal project or global config.

Step 3

Pick a model

claude-sonnet-4-6claude-opus-4-7deepseek-v4-flashgpt-oss-120b

`antseed opencode --model <service-id>` generates a temporary config for that one id. In manual config, the keys under `models` must exactly match service ids returned by `curl http://localhost:8377/v1/models`.

The exact list of models depends on which peer you pin. Run antseed network browse or open the live network page to see what's available right now.

Verify

Test it

  • Confirm the proxy lists the same ids your config references
    curl -s http://localhost:8377/v1/models | jq '.data[].id'
    Example response
    "claude-opus-4-7" "claude-sonnet-4-6" "deepseek-v4-flash" "gpt-oss-120b"

    Add or remove entries under `models` in `opencode.json` so they match this list.

  • Launch OpenCode through the wrapper
    antseed opencode --model gpt-oss-120b

    Extra OpenCode args are forwarded, so `antseed opencode --model gpt-oss-120b run` works too. Manual config equivalent: run `opencode`, then pick one of the AntSeed entries from `/models`.

How OpenCode talks to AntSeed

  • Wire format sent by OpenCode: OpenAI Chat Completions (hits /v1/chat/completions on the buyer proxy)
  • Best-fit services: any service whose protocols array contains openai-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> --json and look at providerServiceApiProtocols[provider].services[service]. The browse command exposes the same field per peer.
  • What happens when protocols don't match: AntSeed's @antseed/api-adapter translates between OpenAI Chat Completions and the service's native protocol on the fly. So a request from OpenCode can still reach a service that only advertises anthropic-messages — just with a small transform step.
  • One known caveat: services whose only advertised protocol is openai-responses require streaming. If OpenCode sends a non-streaming request and the proxy routes it to one of those services, the call fails with HTTP 400: Stream must be set to true. Pick a service whose protocols includes openai-chat-completions (or another non-responses protocol) to avoid this.

If it goes wrong

Troubleshooting

  • AntSeed doesn't appear in `/connect` or `/models`With `antseed opencode`, pass the service id via `--model`; the wrapper supplies a temporary config. With manual config, make sure `opencode.json` is in your project root (or `~/.config/opencode/opencode.json`) and that the JSON is valid — a stray comma silently disables the whole provider.
  • Model is listed but every call returns `model_not_found`The pinned peer doesn't advertise that service id. Run `antseed network peer <peerId>` to see what it actually offers, or pin a different peer.
  • OpenCode prompts for an API keyThe proxy ignores auth, but the AI SDK sometimes asks anyway. Either skip the prompt (press enter on empty input) or set `"apiKey": "antseed"` inside `options` in `opencode.json`.

Reference

Links

Same category

Related