OpenCode is an AI coding agent that runs in the terminal, supporting multiple model providers through a provider mechanism. This guide covers configuring OpenCode to use ShopAIKey's OpenAI-compatible API.
Endpoint
https://api.shopaikey.com/v1
1. Install OpenCode
Install via npm:
npm install -g opencode
Or via Homebrew on macOS/Linux:
brew install opencode-ai/tap/opencode
Verify after installation:
opencode --version
2. Add API Key to OpenCode
Run:
opencode auth login
Select Other, then enter the provider id:
shopaikey
Then enter your ShopAIKey API key.
The provider id
shopaikeymust match the key in theopencode.jsonfile in the next step.
3. Create opencode.json
In the project directory where you want to use OpenCode, create or update the file:
opencode.json
Sample content:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"shopaikey": {
"npm": "@ai-sdk/openai-compatible",
"name": "ShopAIKey",
"options": {
"baseURL": "https://api.shopaikey.com/v1"
},
"models": {
"gpt-5.2": {
"name": "GPT-5.2"
},
"gpt-5.3-codex": {
"name": "GPT-5.3 Codex"
},
"claude-sonnet-4-5": {
"name": "Claude Sonnet 4.5"
},
"claude-opus-4-5": {
"name": "Claude Opus 4.5"
}
}
}
}
}
4. Select a Model
Launch OpenCode:
opencode
In the OpenCode interface, run:
/models
Select the ShopAIKey provider and the model you want to use.
5. Configure API Key Directly in the File
If you prefer not to use opencode auth login, you can set the key via an environment variable.
macOS / Linux
export SHOPAIKEY_API_KEY="sk-your-api-key"
Windows PowerShell
$env:SHOPAIKEY_API_KEY = "sk-your-api-key"
Then edit opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"shopaikey": {
"npm": "@ai-sdk/openai-compatible",
"name": "ShopAIKey",
"options": {
"baseURL": "https://api.shopaikey.com/v1",
"apiKey": "{env:SHOPAIKEY_API_KEY}"
},
"models": {
"gpt-5.2": {
"name": "GPT-5.2"
}
}
}
}
}
6. Notes
- Use
@ai-sdk/openai-compatiblefor endpointhttps://api.shopaikey.com/v1. - If you change
opencode.json, restart OpenCode to ensure the new configuration is loaded. - Model IDs must match the models currently supported by ShopAIKey.
- If you encounter an
Invalid API Keyerror, check that the key has credit and hasn't been revoked. - If you encounter a
Model Not Founderror, try switching to another model from the Models page.
7. Quick Test
In your project directory, run:
opencode
Send a test request:
Explain this project's structure and suggest areas for improvement.
If the response comes back normally, the configuration is working.