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.
For abilities as well as models, such as reading pages and making images, add the Flux tools server with the same key if your version of the tool supports remote MCP servers.
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.