opencode
Add FluxRouter as a custom provider in opencode.json using the OpenAI-compatible AI SDK.
opencode adds providers through its config file using the OpenAI-compatible AI SDK. Define a FluxRouter provider once and route every model through your single Flux key.
One-click with Flux Desktop
Flux Desktop can write this configuration for you. The manual steps below show what it sets.
Manual config
Add a flux provider to opencode.json (project root) or ~/.config/opencode/opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"flux": {
"npm": "@ai-sdk/openai-compatible",
"name": "FluxRouter",
"options": {
"baseURL": "https://api.fluxrouter.ai/v1",
"apiKey": "{env:FLUX_API_KEY}"
},
"models": {
"flux-auto": {
"name": "Flux Auto",
"limit": { "context": 200000, "output": 65536 }
}
}
}
}
}
The baseURL ends at /v1 (not /v1/chat/completions). The model key must match what FluxRouter accepts in the model field.
Then set your key in the environment:
export FLUX_API_KEY="sk-YOUR-FLUX-KEY"
Test it
Run opencode, select the Flux Auto model under the FluxRouter provider, and send a prompt. A reply confirms the connection. Check your FluxRouter dashboard to see the request.