OpenCode install guide (Linux / WSL2)
Prefer one command?
The OpenCode one-line setup installs OpenCode and configures Claude and GPT for you.
0. Prerequisite: install Node.js
Install Node.js first: Node.js on Linux
1. Install OpenCode
Step 1: Install OpenCode globally
npm i -g opencode-ai@latestStep 2: Check the install
opencode --versionIf you see a version number, it worked.
2. Install the SDKs (required)
2.1 What's an SDK?
An SDK is the package that lets OpenCode talk to a given AI service. You need to install the matching one first.
2.2 Install the Claude SDK (recommended)
Step 1: Create the config directory
mkdir -p ~/.config/opencodeStep 2: Go into it
cd ~/.config/opencodeStep 3: Install the Anthropic SDK (for Claude models)
npm install @ai-sdk/anthropicWait for it to finish (it can take a few minutes).
2.3 Optional: install the OpenAI SDK
Want GPT models too? Install the OpenAI SDK as well:
npm install @ai-sdk/openaiTip: Flash API serves both Claude and GPT, so installing both SDKs saves you a trip later.
3. Configure OpenCode (connect to Flash API)
3.1 Where's the config file?
Config path: ~/.config/opencode/opencode.json
What that means:
~is your home directory- The full path is
/home/<your-username>/.config/opencode/opencode.json
3.2 Get your Flash API key
Step 1: Grab your API key from Flash API
- No account yet? Sign up first
- After logging in, find your API key in the dashboard and copy it
3.3 Write the config file
Here's a config for Claude models (replace the API key):
cat > ~/.config/opencode/opencode.json <<'EOF'
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"flashapi-claude": {
"npm": "@ai-sdk/anthropic",
"options": {
"apiKey": "YOUR_FLASH_API_KEY",
"baseURL": "https://ai.flashapi.top/v1"
},
"models": {
"claude-opus-5-5": {
"name": "Claude Opus 5.5",
"attachment": true
}
}
}
},
"model": "flashapi-claude/claude-opus-5-5"
}
EOFMust replace: swap YOUR_FLASH_API_KEY for the real key you copied from Flash API.
How to do it:
- Copy the whole command above
- Replace
YOUR_FLASH_API_KEYwith your real key - Paste it into the terminal and run it
3.4 Adding GPT models too
If you installed @ai-sdk/openai earlier, use this config instead (Claude and GPT side by side):
cat > ~/.config/opencode/opencode.json <<'EOF'
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"flashapi-claude": {
"npm": "@ai-sdk/anthropic",
"options": {
"apiKey": "YOUR_FLASH_API_KEY",
"baseURL": "https://ai.flashapi.top/v1"
},
"models": {
"claude-opus-5-5": {
"name": "Claude Opus 5.5",
"attachment": true
}
}
},
"flashapi-openai": {
"npm": "@ai-sdk/openai",
"options": {
"apiKey": "YOUR_FLASH_API_KEY",
"baseURL": "https://ai.flashapi.top/v1"
},
"models": {
"gpt-6.1-sol": {
"name": "GPT-6.1 Sol",
"attachment": true
}
}
}
},
"model": "flashapi-claude/claude-opus-5-5"
}
EOFWhat the config does:
"model"sets the default model- To default to GPT, change it to
"model": "flashapi-openai/gpt-6.1-sol" "attachment": trueenables file uploads (images, code files, etc.)
4. Start and verify
Step 1: Go to your project directory
cd /path/to/your/projectReplace /path/to/your/project with your actual project path.
Step 2: Start OpenCode
opencodeIf everything is configured correctly, OpenCode starts up connected to Flash API.