Skip to main content

OpenCode

1.1 API Configuration

  1. Enter project directory

  2. Start OpenCode

  3. Run /connect command

  4. Select provider type

    • Choose "Other" or "Custom Provider"

    • Or search for provider name

  5. Enter URL and API Key

  6. Select model

Method 2: Config File

Step 1: Create Config

Create or edit ~/.config/opencode/config.json:

{
"$schema": "https://opencode.ai/config.json",
"provider": {
"hpc-ai": {
"npm": "@ai-sdk/openai-compatible",
"name": "HPC-AI Tech",
"options": {
"baseURL": "https://api.hpc-ai.com/inference/v1",
"apiKey": "{env:HPC_AI_API_KEY}"
},
"models": {
"minimax/minimax-m2.5": {
"name": "HPC-AI Tech"
}
}
}
},
"model": "minimax/minimax-m2.5"
}

Step 2: Add API Key

Create or edit ~/.local/share/opencode/auth.json:

{
"hpc-ai": {
"type": "api",
"key": "sk-your-hpc-ai-api-key"
}
}

Config Priority

PriorityConfig PathDescription
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 HPC_AI_API_KEY="sk-your-hpc-ai-api-key"
export OPENAI_API_BASE="https://api.hpc-ai.com/inference/v1"

1.2 References