Connecting opencode to an API gateway in five minutes
opencode is an open-source terminal agent. It works with any compatible API — you just supply the address and key.
3 min · · Updated · opencode · harness · интеграции
opencode is an open-source terminal agent: it reads your project, edits files, runs commands. It runs over a plain API and is not tied to one vendor, so the model underneath is your choice.
What you need
An API key and a base URL. With Zukko the key looks like fetch_... and comes from your dashboard. The address for opencode is https://api.zukko.pro/v1, with /v1, including for the anthropic provider.
This is the single most common setup mistake, and it produces a confusing 404. opencode works through the AI SDK, whose anthropic provider appends only /messages to the address, not /v1/messages. Without /v1 the request goes to https://api.zukko.pro/messages and gets a 404. Don't confuse this with Claude Code and the official Anthropic SDK — those are the ones that need the address without /v1.
Config file
The most reliable route is the ~/.config/opencode/opencode.json file:
{
"provider": {
"anthropic": {
"options": {
"baseURL": "https://api.zukko.pro/v1",
"apiKey": "fetch_your_key"
}
}
}
}Then pick claude-opus-5-5 or claude-sonnet-5 as the model in opencode. Details are in the opencode docs.
The config lives in your home directory, not in the project, so it doesn't end up in git. Keeping the key in a file that ends up in git is a bad idea — that includes a project-level .env.
Choosing a model
The current list is always one request away:
curl https://api.zukko.pro/v1/models -H "Authorization: Bearer fetch_your_key"Models that are not responding right now are dropped from that list automatically — done specifically for agents: otherwise you pick the first entry, hit a refusal, and conclude the whole service is down.
For everyday agent work a sensible pair is claude-opus-5-5 for hard tasks and glm-5.3 for simple ones (note that GLM has a 128K context, not 1M). The price gap is real — $0.30 against $0.10 per million input tokens, and in an agent loop input tokens are usually the bulk of the bill. When comparing with vendor pricing, keep in mind that vendors charge about 10% of the input price for prompt-cache reads, while Zukko bills cached tokens at the regular price, so for an agent with a large repeated context the real difference is smaller than a head-to-head comparison suggests.
If it doesn't work
401 or "invalid api key". The key was truncated or placed in the wrong config field. Check for a trailing space — copying from a messenger adds one surprisingly often.
404 on the request. Almost certainly baseURL is missing the /v1. See above.
The agent answers in prose instead of reading files. Tool calls aren't getting through. Make sure the chosen model supports function calling and that tools aren't disabled in opencode's settings.
A very slow first reply. Some models spend tokens on internal reasoning before answering, and with a low limit the reply comes back empty. If the agent goes quiet, raise max_tokens or switch models.
What it costs
Billing is per token actually used, not per subscription. For an agent that matters: the number of requests inside one task is unknown up front, so a subscription either caps you or overcharges you.
Spend is visible in the dashboard broken down by model, so you can see which part of the work costs what and move the routine onto something cheaper.
zukko
Pay 25×
less
for Claude Code & ChatGPT
One fetch_* key and base URL api.zukko.pro — for Cursor, Claude Code, Codex, and any SDK.
Related articles
- opencode agents: setting up roles, models and toolsA custom agent in opencode is a role, a model and a set of permissions. A working config where a cheap model handles routine work and a stronger one edits code.
- OpenAI API Keys in the Open: Why You Should Not Use ThemWhere free keys on GitHub come from, why using them is dangerous for you and for the owner, and how to protect your own key from the same leak.
- GLM API Errors: Why the Request Fails and How to Fix ItA wrong model id, an overflowing 128K context, the key, the balance, limits: the typical causes of GLM API errors and a quick way to find yours.
- Plan mode in Claude Code: plan first, then edit the codeIn plan mode Claude Code reads your code and proposes a plan but edits nothing until you agree. How to enable it, use it and what it costs.