Connect opencode
Run opencode on Gigatoken
opencode is a terminal-based AI coding agent. It is model-agnostic: each provider is an AI SDK provider described in opencode.json. This guide adds a Gigatoken provider so opencode runs on a catalog model served by a provider device, using the same inference key as any other Gigatoken client.
What you'll need
- opencode installed. These steps were verified with opencode
1.15.13(npm install -g opencode-ai@1.15.13, or the installer at opencode.ai/docs). - A Gigatoken inference key. Provider keys are rejected by inference endpoints.
Get an inference key
Generate an inference key from the Inference console API keys page. Gigatoken shows the full key value only once, at generation time. Export it in the shell you run opencode from:
export GIGATOKEN_INFERENCE_KEY="gt_your_inference_key"Use the Responses API package
Gigatoken implements the OpenResponses API (POST /v1/responses) and does not serve /v1/chat/completions. opencode chooses the wire protocol from the provider's npm package, so set it to "@ai-sdk/openai", which speaks the Responses API and ships bundled with opencode. The usual "@ai-sdk/openai-compatible" package only calls /v1/chat/completions and fails against Gigatoken with Error: Not Found.
If you prefer the provider purpose-built for the OpenResponses spec, "@ai-sdk/open-responses" also works. It is not bundled (opencode fetches it on first use) and takes the full endpoint as url instead of baseURL:
"gigatoken": {
"npm": "@ai-sdk/open-responses",
"name": "Gigatoken",
"options": {
"name": "gigatoken",
"url": "https://coordinator.gigatoken.baremetallabs.ai/v1/responses",
"apiKey": "{env:GIGATOKEN_INFERENCE_KEY}"
},
"models": {
"qwen/qwen3.6-35b-a3b": {
"name": "qwen/qwen3.6-35b-a3b (Gigatoken)",
"limit": { "context": 256000, "output": 8192 }
}
}
}Configure the Gigatoken provider
Add the provider to opencode.json — in your project root, or globally at ~/.config/opencode/opencode.json. The apiKey reads the {env:GIGATOKEN_INFERENCE_KEY} environment variable, so the secret never lives in the file.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"gigatoken": {
"npm": "@ai-sdk/openai",
"name": "Gigatoken",
"options": {
"baseURL": "https://coordinator.gigatoken.baremetallabs.ai/v1",
"apiKey": "{env:GIGATOKEN_INFERENCE_KEY}"
},
"models": {
"qwen/qwen3.6-35b-a3b": {
"name": "qwen/qwen3.6-35b-a3b (Gigatoken)",
"limit": { "context": 256000, "output": 8192 }
}
}
}
}
}Set limit.context to the window Gigatoken actually serves for your model. Each model advertises this at runtime as max_served_context_length in GET /v1/models (the example value 256000 is the highest served tier allowed by qwen/qwen3.6-35b-a3b's catalog context). Treat the live /v1/models response as the source of truth. The model key under models must be the exact catalog alias — opencode passes it through unchanged as the request model.
Run a one-shot inference
Verify the provider end to end with a single non-interactive run. The model reference is gigatoken/<alias> — the provider id followed by the catalog alias:
opencode run --model gigatoken/qwen/qwen3.6-35b-a3b \
"Reply with exactly one word: pong"A successful run prints the model's reply. run drives the full agent loop (system prompt, tools, and reasoning), so the same provider serves both quick prompts and agentic coding turns.
Use it interactively
Launch the TUI from a project directory and select the Gigatoken model with the model switcher (/models), or start pinned to it:
opencode --model gigatoken/qwen/qwen3.6-35b-a3bTo make Gigatoken the default for every session, set it as the top-level model in opencode.json: "model": "gigatoken/qwen/qwen3.6-35b-a3b".
Notes and troubleshooting
- Pick a served model. List what is currently routable with
curl -H "Authorization: Bearer $GIGATOKEN_INFERENCE_KEY" https://coordinator.gigatoken.baremetallabs.ai/v1/models, and set the model key and--modelalias to a live one. A model is only routable while a provider device is serving it. - "Error: Not Found." The provider is calling
/v1/chat/completions. Confirmnpmis"@ai-sdk/openai"(or"@ai-sdk/open-responses"), not"@ai-sdk/openai-compatible". Restart opencode after editing provider config. - Model not found / wrong id. opencode sends the model key verbatim, so it must match the catalog alias exactly (for example
qwen/qwen3.6-35b-a3b), including the slash. - 401 / 403. Use an inference key (
gt_…) from the Inference console; provider keys are not accepted on inference endpoints.