Know which account pays
AIGHQ_API_KEY identifies the gateway workload. It does not reuse a Zen, Go, Anthropic, OpenAI, or other saved OpenCode credential; billing follows the provider account or prepaid managed route selected in AI Gateway HQ.
Give OpenCode one workload key and one approved model alias. Keep provider keys off developer machines, cap the workload, and change compatible backends behind the route.
Add a dedicated OpenAI-compatible provider entry that reads its workload key from the environment.
Give each environment or agent its own key. Set the OpenCode budget, rate limit, route, and fallback first.
Store the OpenCode workload key in a keychain, CI secret, or secrets manager. The example contains no real credential.
Send a small OpenCode request and inspect its receipt. Test OpenCode's zero-balance stop and provider fallback too.
OpenCode uses an AI Gateway HQ workload key. Requests from OpenCode charge the BYOK provider account or prepaid Bedrock balance selected by the route, not a personal subscription allowance.
{
"$schema": "https://opencode.ai/config.json",
"model": "aighq/company-approved-fast",
"enabled_providers": ["aighq"],
"provider": {
"aighq": {
"name": "AI Gateway HQ",
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://api.aigatewayhq.com/v1",
"apiKey": "{env:AIGHQ_API_KEY}"
},
"models": {
"company-approved-fast": {
"name": "Company approved fast",
"limit": {
"context": 131072,
"output": 16384
}
}
}
}
}
}Use the OpenCode production URL shown. For OpenCode, replace only the workload key and approved alias from the customer console.
This OpenCode setup was checked against the vendor's published interface. Before a broad OpenCode rollout, review the primary documentation because the vendor can change its interface.
Test the installed OpenCode version, resolved config, provider allowlist, model selection, streamed text, tool round trips, hard budget stop, and compatible fallback. For an enforceable company setting, deploy OpenCode's managed config or MDM preference rather than relying on a project file alone.
AIGHQ_BASE_URL=https://api.aigatewayhq.com/v1
AIGHQ_API_KEY=from-your-workspace
AIGHQ_MODEL=company-approved-fastOpenCode sends Chat Completions traffic to the aighq provider only when the selected model begins with aighq/. AI Gateway HQ can change a compatible backend behind that stable alias, but it cannot govern calls that a user sends directly to another OpenCode provider.
Add the aighq custom provider, read its workload key from AIGHQ_API_KEY, and select aighq/company-approved-fast. The example uses OpenCode's documented OpenAI-compatible package for /v1/chat/completions; Responses-based routes require a different client package and separate acceptance.
Compatibility follows the provider's current published interface. Review the provider documentation before approving OpenCode for production.