OpenCode one-line setup: Claude + GPT via one API (macOS, Linux, Windows)
TL;DR: run curl -fsSL https://sh.flashapi.top/opencode.sh | bash (macOS / Linux) or irm https://sh.flashapi.top/opencode.ps1 | iex (Windows PowerShell), pick 3, paste your API key. Done.
One command installs OpenCode and adds Claude and GPT as custom providers through Flash API. The default model is flashapi-claude/claude-opus-5-5, with reasoning effort set to medium.
1. Run the setup command
curl -fsSL https://sh.flashapi.top/opencode.sh | bashirm https://sh.flashapi.top/opencode.ps1 | iexThe script speaks Chinese (for now)
The script's prompts are currently in Chinese. Pick 3 for a full install, then follow the prompts.
The menu has three options:
1: Install OpenCode only.2: Configure Flash API (Claude + GPT) only. Use this if OpenCode is already installed, or to swap keys later.3: Install everything. Pick this on your first run.
2. How it installs
- macOS / Linux: tries the official install script first (a standalone binary in
~/.opencode/bin, no Node.js needed). If that fails, it falls back tonpm i -g opencode-ai@latest, then to a mirror registry. - Windows: OpenCode has no official PowerShell installer, so the script tries npm, then a mirror registry, then scoop. Install Node.js first: Install Node.js.
- npm 11+ skips install scripts for global packages by default, which leaves OpenCode installed but unable to run. The setup script handles this for you. If you install by hand, use
npm i -g opencode-ai@latest --allow-scripts=opencode-ai.
About the two keys
Claude and GPT live in different pricing groups in the dashboard, so they use separate API keys. The script first asks which model families to configure:
1: Claude + GPT (default, just press Enter)2: Claude only3: GPT only
Then it asks for, in order:
- Your Claude-group API key
- Your GPT-group API key (press Enter to reuse the Claude key)
Each key is checked against /v1/models, and the models available in that group are pulled into the config.
Error: "Requests from the ... framework are not supported"
Your Claude key belongs to a pricing group that only accepts official Claude clients. Create a new key in a group that allows third-party tools at flashapi.top, then rerun the script and pick 2 (configure).
3. Files the script writes
Config file: ~/.config/opencode/opencode.json (%USERPROFILE%\.config\opencode\opencode.json on Windows). If you already have an opencode.jsonc, the script writes that instead. OPENCODE_CONFIG / OPENCODE_CONFIG_DIR take precedence when set.
{
"$schema": "https://opencode.ai/config.json",
"model": "flashapi-claude/claude-opus-5-5",
"provider": {
"flashapi-claude": {
"npm": "@ai-sdk/anthropic",
"name": "闪电API Claude",
"options": { "baseURL": "https://ai.flashapi.top/v1", "apiKey": "sk-YOUR_CLAUDE_KEY" },
"models": {
"claude-opus-5-5": {
"name": "Claude Opus 5.5",
"limit": { "context": 1000000, "output": 128000 },
"options": { "thinking": { "type": "adaptive", "display": "summarized" }, "effort": "medium" }
}
}
},
"flashapi-gpt": {
"npm": "@ai-sdk/openai",
"name": "闪电API GPT",
"options": { "baseURL": "https://ai.flashapi.top/v1", "apiKey": "sk-YOUR_GPT_KEY" },
"models": {
"gpt-6.1-sol": {
"name": "GPT-6.1 Sol",
"limit": { "context": 1050000, "output": 128000 },
"options": { "reasoningEffort": "medium", "reasoningSummary": "auto" }
}
}
}
}
}- The provider display names are written literally as
闪电API Claudeand闪电API GPT(Flash API Claude / Flash API GPT). - Note: in OpenCode the Claude URL does include
/v1. That's different from most other tools. - OpenCode has no global reasoning-effort setting, so it's set in each model's
options. PressCtrl+Tin a session, or pass--variant highon the command line, to change it temporarily. - Your other providers, plugins and settings stay untouched. The original is backed up as
opencode.json.bak.<timestamp>first. Comments in the original file are stripped (the backup keeps them).
4. Verify and use
opencode run -m flashapi-claude/claude-opus-5-5 "Reply with exactly: OK"
opencode run -m flashapi-gpt/gpt-6.1-sol "Reply with exactly: OK"- Start:
opencode - Switch models mid-session: type
/modelsand pick one - Make GPT the default: set
"model"in the config to"flashapi-gpt/gpt-6.1-sol" - An
opencode.jsoninside a project directory overrides the global default model. That's OpenCode's own precedence rule.
5. Roll back
Rename opencode.json.bak.<timestamp> back to the original filename.