OpenCode
Configure OpenCode to route Chat Completions or Responses calls through HeyEly.
OpenCode connects to OpenAI-compatible gateways via @ai-sdk/ over Chat Completions at https://heyely.si/v1. The snippet below follows OpenCode's 1.x config schema.
Set up
- Create an API key in Developers and export it as
HEYELY_API_KEYin the shell launching OpenCode. - Add HeyEly to a project-level
opencode.json, or configure it globally in~/(on Windows,. config/ opencode/ opencode. json %USERPROFILE%\).. config\ opencode\ opencode. jsonc
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"heyely": {
"npm": "@ai-sdk/openai-compatible",
"name": "HeyEly",
"options": {
"baseURL": "https://heyely.si/v1",
"apiKey": "{env:HEYELY_API_KEY}"
},
"models": {
"anthropic/claude-sonnet-5.5": {
"name": "Claude Sonnet 5.5",
"limit": { "context": 1000000, "output": 128000 }
}
}
}
},
"model": "heyely/anthropic/claude-sonnet-5.5"
}
- Launch
opencode.
Prefer storing your key inside OpenCode instead of exporting an env var? Run /connect, select Other, type heyely as the provider ID, and paste your key. OpenCode saves it to ~/.
Verify
- Run
opencode models heyelyto verify your configured entries show up. - Send a quick one-off verification prompt:
opencode run -m heyely/anthropic/claude-sonnet-5.5 \
"Reply with exactly: gateway-ok"
- Open Credit and usage to confirm the call appears at the top of Spend under your selected model.
Note that opencode auth list only displays keys saved through /connect, not keys resolved dynamically from {env:HEYELY_API_KEY}.
Pick a model
- Add every model you want under
modelskeyed by its exact HeyEly catalog ID, then select it with-m heyely/<id>, themodelfield, or/models. - OpenCode splits
provider/modelon the very first slash, so catalog IDs containing slashes work seamlessly afterheyely/. - Always specify
limit.contextandlimit.outputon custom provider entries; OpenCode only auto-populates limits for its built-in registry providers. - For models that run over
POST /v1/responses, switch thenpmpackage to@ai-sdk/openai(which can also be set per model). - OpenCode 2 introduces renamed config keys; stick to one schema version per file and consult OpenCode's upgrade notes when moving to 2.x.
Troubleshooting
| You see | Cause | Fix |
|---|---|---|
ProviderModelNotFoundError | Missing provider/model prefix or model omitted from models | Run opencode models and copy the exact reference |
| Model missing from picker | Not declared under models | Add an entry keyed by the exact catalog ID |
401 missing_api_key | HEYELY_API_KEY not exported in OpenCode's shell | Export HEYELY_API_KEY before starting OpenCode |
| Config file ignored | JSON syntax error | Validate quotes and trailing commas |
AI_APICallError after updating | Stale cached provider package | Remove ~/.cache/opencode and relaunch |
404 model_not_found | Key under models does not match HeyEly's catalog | Copy the exact ID from the Models page |