OpenCode
OpenCode talks to codexkey through two providers: Claude goes through one, the other models through the second. The key is shared.
Setup
- Install it:
npm install -g opencode-ai. Check the version:opencode --version. - Open the file
~/.config/opencode/opencode.json(on Windows%USERPROFILE%\.config\opencode\opencode.json) and paste the configuration:
{
"$schema": "https://opencode.ai/config.json",
"model": "codexkey-claude/claude-sonnet-5",
"provider": {
"codexkey-claude": {
"npm": "@ai-sdk/anthropic",
"name": "codexkey · Claude",
"options": { "baseURL": "https://api.codexkey.online/v1", "apiKey": "sk_cdx_YOUR_KEY" },
"models": {
"claude-opus-5-5": { "name": "Claude Opus 5.5", "limit": { "context": 1000000, "output": 128000 } },
"claude-sonnet-5": { "name": "Claude Sonnet 5", "limit": { "context": 1000000, "output": 32000 } }
}
},
"codexkey": {
"npm": "@ai-sdk/openai-compatible",
"name": "codexkey · GPT, Gemini and others",
"options": { "baseURL": "https://api.codexkey.online/v1", "apiKey": "sk_cdx_YOUR_KEY" },
"models": {
"gpt-6-astra": { "name": "GPT-6 Astra", "limit": { "context": 1000000, "output": 128000 } },
"gemini-3.1-pro": { "name": "Gemini 3.1 Pro", "limit": { "context": 1000000, "output": 65000 } },
"deepseek-v4.1-flash": { "name": "DeepSeek V4.1 Flash", "limit": { "context": 1000000, "output": 131072 } }
}
}
}
}- Start
opencode, then pick a model, for examplecodexkey/gpt-6-astra.
Keep the limit block: without it OpenCode does not know the context size and does not compact history. Any model from the catalog can be added following the same pattern.
OpenCode 2: the configuration above and the install from step 1 were written for OpenCode 1 (npm install -g opencode-ai). OpenCode 2 has its own schema: providers instead of provider, with the address and key set in settings.baseURL and settings.apiKey. According to the OpenCode documentation, the V1 format is still supported in OpenCode 2 and is read from the same files, so this config should work there too. OpenCode 2 is installed with curl -fsSL https://opencode.ai/v2/install | bash or npm install -g @opencode/cli; migration is covered at opencode.ai/v2/docs/migrate-v1.
Tips
- The file can be called
opencode.jsonc, a format that allows comments. - In OpenCode a model is given as provider/name. Claude sits under the
codexkey-claudeprovider, the other models undercodexkey.