OpenCode

OpenCode is the open-source AI coding agent.

1.1 API Configuration

Method 1: Interactive Setup (Recommended)

  1. Navigate to your project directory
  2. Launch OpenCode
  3. Run the /connect command
  4. Choose a provider type:
    • Select "Other" or "Custom Provider"
    • Or search for your provider name
  5. Enter your API details:
    • Base URL: https://api.rygen.io/v1
    • API Key: your-rygen-api-key
  6. 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

PriorityPathDescription
1OPENCODE_CONFIG env varCustom config file path
2OPENCODE_CONFIG_DIR env varCustom config directory
3<project>/opencode.jsonProject-level config
4~/.config/opencode/opencode.jsonGlobal 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/)