Skip to content

OpenCode

Configure OpenCode to route Chat Completions or Responses calls through HeyEly.

OpenCode connects to OpenAI-compatible gateways via @ai-sdk/openai-compatible over Chat Completions at https://heyely.si/v1. The snippet below follows OpenCode's 1.x config schema.

Set up

  1. Create an API key in Developers and export it as HEYELY_API_KEY in the shell launching OpenCode.
  2. Add HeyEly to a project-level opencode.json, or configure it globally in ~/.config/opencode/opencode.json (on Windows, %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"
}
  1. 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 ~/.local/share/opencode/auth.json.

Verify

  1. Run opencode models heyely to verify your configured entries show up.
  2. Send a quick one-off verification prompt:
opencode run -m heyely/anthropic/claude-sonnet-5.5 \
  "Reply with exactly: gateway-ok"
  1. 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 models keyed by its exact HeyEly catalog ID, then select it with -m heyely/<id>, the model field, or /models.
  • OpenCode splits provider/model on the very first slash, so catalog IDs containing slashes work seamlessly after heyely/.
  • Always specify limit.context and limit.output on custom provider entries; OpenCode only auto-populates limits for its built-in registry providers.
  • For models that run over POST /v1/responses, switch the npm package 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 seeCauseFix
ProviderModelNotFoundErrorMissing provider/model prefix or model omitted from modelsRun opencode models and copy the exact reference
Model missing from pickerNot declared under modelsAdd an entry keyed by the exact catalog ID
401 missing_api_keyHEYELY_API_KEY not exported in OpenCode's shellExport HEYELY_API_KEY before starting OpenCode
Config file ignoredJSON syntax errorValidate quotes and trailing commas
AI_APICallError after updatingStale cached provider packageRemove ~/.cache/opencode and relaunch
404 model_not_foundKey under models does not match HeyEly's catalogCopy the exact ID from the Models page