Prerequisites
- OpenCode installed
- An AIOHub
sk-API key - A group assigned to the API key that can access the model you want to use
- A positive account balance
Config location
OpenCode supports global and project config. Use global config for your personal defaults and project config when you want to share model IDs with a repository.| Use case | File |
|---|---|
| User-wide config | ~/.config/opencode/opencode.json |
| Current project config | opencode.json |
Project
opencode.json overrides matching fields from global config. Do not commit real API keys. For shared project config, save credentials locally with /connect or reference an environment variable.Configure Chat Completions models
OpenCode uses@ai-sdk/openai-compatible for OpenAI Chat Completions-compatible models. Set the Base URL to https://api.aiohub.org/v1, not a full endpoint URL.
1. Add the credential
In the OpenCode TUI, run:2. Add the provider config
Add this toopencode.json:
gpt-4o with a Chat Completions model available to the group assigned to your API key. If you want a lightweight model for smaller tasks, add small_model:
Configure Responses models
If you want to use a model or workflow that requires OpenAI Responses, use@ai-sdk/openai. A separate provider ID keeps the Chat Completions and Responses paths clear.
Put the API key in an environment variable:
You can keep multiple providers in one OpenCode config. Chat Completions and Responses use different request paths. If a model fails with endpoint or response-format errors, check that the
npm package matches the model protocol.Verify
Open OpenCode:aiohub/... or aiohub-responses/..., then send a short message. A normal reply means the setup is working.
You can also verify API key and model visibility with HTTP:
Troubleshooting
AIOHub does not appear in the model list
AIOHub does not appear in the model list
Confirm the provider ID entered through
/connect exactly matches the provider key in opencode.json, for example aiohub. Restart OpenCode after editing config.404 or duplicated path
404 or duplicated path
Set the Base URL to
https://api.aiohub.org/v1. Do not set it to https://api.aiohub.org/v1/chat/completions or https://api.aiohub.org/v1/responses.API key is not used
API key is not used
If you use
/connect, confirm the credential is saved under the same provider ID. If you use an environment variable, run test -n "$AIOHUB_API_KEY" && echo "api key configured" before starting OpenCode.Responses model returns a format error
Responses model returns a format error
Confirm the provider uses
@ai-sdk/openai, not @ai-sdk/openai-compatible. If you only need basic chat, verify basic connectivity with a Chat Completions model first.