OpenCode is the open-source AI coding agent.
1.1 API Configuration
Method 1: Interactive Setup (Recommended)
- Navigate to your project directory
- Launch OpenCode
- Run the
/connectcommand - Choose a provider type:
- Select "Other" or "Custom Provider"
- Or search for your provider name
- Enter your API details:
- Base URL:
https://api.rygen.io/v1 - API Key: your-rygen-api-key
- Base URL:
- Select the model you want to use
Method 2: Configuration File
Step 1: Create or Update Config
Edit ~/.config/opencode/config.json:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"rygen": {
"npm": "@ai-sdk/openai-compatible",
"name": "rygen.io API",
"options": {
"baseURL": "https://api.rygen.io/v1",
"apiKey": "{env:RYGEN_API_KEY}"
},
"models": {
"minimax/minimax-m2.5": {
"name": "rygen.io Model"
}
}
}
},
"model": "minimax/minimax-m2.5"
}Step 2: Add API Key
Edit ~/.local/share/opencode/auth.json:
{
"rygen": {
"type": "api",
"key": "sk-your-rygen-api-key"
}
}Config Priority
| Priority | Path | Description |
|---|---|---|
| 1 | OPENCODE_CONFIG env var | Custom config file path |
| 2 | OPENCODE_CONFIG_DIR env var | Custom config directory |
| 3 | <project>/opencode.json | Project-level config |
| 4 | ~/.config/opencode/opencode.json | Global config |
Method 3: Environment Variables
export RYGEN_API_KEY="sk-your-rygen-api-key"
export OPENAI_API_BASE="https://api.rygen.io/v1"1.2 References
Refer to the official OpenCode provider documentation for more details. (https://opencode.ai/docs/providers/)

