Skip to Content

OpenCode

OpenCode supports custom providers. This guide adds an OpenAI-compatible provider named fenno; it does not assume Fenno is built into the client catalog.

1. Prepare the environment

Follow the official installation instructions , then check the version and set the key in the launch terminal:

opencode --version export FENNO_API_KEY="<YOUR_FENNO_API_KEY>"

On Windows PowerShell, use $env:FENNO_API_KEY = "<YOUR_FENNO_API_KEY>". Desktop apps may not inherit shell variables; use custom provider settings or launch from an environment containing the variable.

2. Add the provider

Merge this into the project’s opencode.json, or global ~/.config/opencode/opencode.json:

opencode.json
{ "$schema": "https://opencode.ai/config.json", "model": "fenno/<YOUR_MODEL_ID>", "provider": { "fenno": { "npm": "@ai-sdk/openai-compatible", "name": "Fenno", "options": { "baseURL": "https://api.fenno.ai/v1", "apiKey": "{env:FENNO_API_KEY}" }, "models": { "<YOUR_MODEL_ID>": { "name": "Fenno coding model" } } } } }

Replace both occurrences of <YOUR_MODEL_ID> with the same exact model ID.

  • fenno under provider.fenno is a local OpenCode provider ID.
  • A key in models is the model ID sent to Fenno.
  • The top-level model uses provider-id/model-id, adding a local fenno/ prefix to the gateway model ID.
  • {env:FENNO_API_KEY} reads the key at startup, avoiding credentials in the repository.

3. Select and verify

Start opencode and use /models to select a Fenno model, or run this in a test project:

opencode run -m "fenno/<YOUR_MODEL_ID>" "Reply with OK only. Do not modify files."

Verify the request in the Fenno console, then test tool calling separately.

Chat Completions versus Responses

Protocolnpm settingFinal endpoint
Chat Completions@ai-sdk/openai-compatible/v1/chat/completions
Responses@ai-sdk/openai/v1/responses

Check model protocol support before changing adapters. A model with Codex in its name is not necessarily callable through Chat Completions.

If setting context or output limits, use the actual model limits rather than values copied from another provider.

Troubleshooting

SymptomAction
Model absent from /modelsCheck file location, JSON syntax and models keys
Provider / model not foundCheck the local provider ID and fenno/model-id format
401Check the launch environment; missing variables resolve to empty strings
404 / unsupported endpointCheck the adapter, protocol, base URL and model capabilities
Settings appear ignoredCheck whether project configuration overrides global configuration, then restart

See the official provider  and configuration  documentation.