OpenCode Guide
OpenCode is an open-source AI coding assistant framework. It supports integration with multiple AI models, including code generation, modification, and review workflows.
This test covered only manual configuration and regular-key requests in the macOS CLI. Composite keys, CC-Switch configuration, and installation on other operating systems were not tested in this run.
Installation
Choose an installation method based on your workflow.
macOS / Linux
curl -fsSL https://opencode.ai/install | bashWindows PowerShell
Using WSL is recommended. Install it with the macOS / Linux method above inside WSL.
Connect to TokenFlux
After installation, choose one of the following methods to connect OpenCode to TokenFlux.
Using CC-Switch is recommended for centralized configuration.
Steps:
- Follow Create API Key to generate an API key.
- Select
OpenCodein theCC-Switchsidebar, click "+" to add a provider, and fill inAPI URLhttps://tokenflux.dev/v1, the API key and a model. "Import to CCS" does not coverOpenCode; see CC-Switch for details. - After saving, click "Add" on the provider card, then restart
OpenCode.
Use a Composite Key
A composite key requires a group prefix in the requested model ID. If you have mapped the GPT prefix to a group that supports gpt-6-astra, you can use this opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"model": "tokenflux/GPT/gpt-6-astra",
"provider": {
"tokenflux": {
"npm": "@ai-sdk/openai",
"name": "TokenFlux",
"options": {
"baseURL": "https://tokenflux.dev/v1",
"apiKey": "YOUR_API_KEY"
},
"models": {
"GPT/gpt-6-astra": {
"name": "GPT-6 Astra (TokenFlux)",
"reasoning": true,
"tool_call": true,
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"limit": {
"context": 128000,
"output": 32768
}
}
}
}
}
}Replace YOUR_API_KEY with your composite key and GPT with the prefix configured on that key. tokenflux is the provider ID within OpenCode; the model ID sent in the request is GPT/gpt-6-astra.
The limit values are example client token budgets; adjust them to the capabilities of your model and group. When adding other models, also specify their tool calling, input types, and reasoning capabilities. See the OpenCode custom provider documentation for the fields.
Verify the Setup
Test the regular-key configuration above with:
opencode models
opencode run -m openai/gpt-6-astra "Reply with OK only"For the composite-key example, use:
opencode run -m tokenflux/GPT/gpt-6-astra "Reply with OK only"opencode models displays the client's model catalog; it does not validate your TokenFlux API key, URL, or model permissions. opencode run makes a real, billed call. After receiving a reply, confirm the request in the usage logs.
If the commands fail or the model list is empty, first rule the client out with Test the Key and Endpoint on Their Own, then review opencode.json.
Related Pages
- Create API Key - pick a group and generate a key
- API Endpoints - address and protocol format
- Troubleshooting - locate a problem by symptom