Setup guide
OpenCode custom provider configuration
Yes. OpenCode works with Token Supply. Keep OpenCode's OpenAI, Anthropic, Gemini, or Grok preset. Replace baseURL and apiKey, set context limits, and use variants for reasoning effort.
~/.config/opencode/opencode.json · opencode.json
Preset, limits, variants
Create an API key
A new key works on every OpenCode preset. Older keys still only serve the plan they were created for.
Keep the preset
Do not invent a new provider id. Replace options on openai, anthropic, gemini, or grok.
Set limits
Custom models need limit.context and limit.output or OpenCode cannot size the window.
Pick a variant
Cycle variants in OpenCode to change reasoning effort. high is a solid default.
Who this is for
OpenCode users who keep the built-in OpenAI, Anthropic, Gemini, or Grok preset and only swap the host.
Where the file lives
OpenCode uses ~/.config/opencode/opencode.json. On Windows this is usually %USERPROFILE%\.config\opencode\opencode.json.
You can also create opencode.json in a project folder. OpenCode accepts JSON and JSONC.
Replace TOKEN_SUPPLY_API_KEY with the actual ts_live_... key. Use the plain key value, not {env:TOKEN_SUPPLY_API_KEY}.
OpenAI models
Use your Token Supply API key. baseURL is https://api.token-supply.com/v1. Set store: false on Responses-capable models.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"openai": {
"options": {
"baseURL": "https://api.token-supply.com/v1",
"apiKey": "TOKEN_SUPPLY_API_KEY"
},
"models": {
"gpt-6.1-sol": {
"name": "GPT-6.1 Sol (TS)",
"limit": { "context": 1050000, "output": 128000 },
"options": { "store": false },
"variants": { "low": {}, "medium": {}, "high": {}, "xhigh": {}, "max": {} }
},
"gpt-6-sol": {
"name": "GPT-6 Sol (TS)",
"limit": { "context": 1050000, "output": 128000 },
"options": { "store": false },
"variants": { "none": {}, "low": {}, "medium": {}, "high": {}, "xhigh": {}, "max": {} }
},
"gpt-6-luna": {
"name": "GPT-6 Luna (TS)",
"limit": { "context": 1050000, "output": 128000 },
"options": { "store": false },
"variants": { "none": {}, "low": {}, "medium": {}, "high": {}, "xhigh": {}, "max": {} }
},
"gpt-5.6-sol": {
"name": "GPT-5.6 Sol (TS)",
"limit": { "context": 1050000, "output": 128000 },
"options": { "store": false },
"variants": { "low": {}, "medium": {}, "high": {}, "xhigh": {}, "max": {}, "ultra": {} }
},
"gpt-5.5": {
"name": "GPT-5.5 (TS)",
"limit": { "context": 1050000, "output": 128000 },
"options": { "store": false },
"variants": { "low": {}, "medium": {}, "high": {}, "xhigh": {} }
}
}
}
}
}
Why this works: The OpenAI preset stays. baseURL and the model id are the only swaps.
Anthropic models
The same key works here. OpenCode's Anthropic preset expects /v1 in its base URL. Variants are high and max. This example uses claude-sonnet-5 and claude-haiku-4-5.
Claude Fable 5.1 (claude-fable-5-1), Opus 5.5 (claude-opus-5-5), and Haiku 5.5 (claude-haiku-5-5) can only be used inside the Claude Code CLI via Token Supply, due to Anthropic security settings. Claude Fable 5.2 (claude-fable-5-2) works with a universal key from OpenCode and SDK clients at default rates per million of $5.60 input, $28 output, $0.14 cache read, and $7 five-minute/$11.20 one-hour cache write.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"anthropic": {
"options": {
"baseURL": "https://api.token-supply.com/v1",
"apiKey": "TOKEN_SUPPLY_API_KEY"
},
"npm": "@ai-sdk/anthropic",
"models": {
"claude-sonnet-5": {
"name": "Claude Sonnet 5 (TS)",
"limit": { "context": 1000000, "output": 128000 },
"options": { "thinking": { "type": "enabled", "budgetTokens": 16000 } },
"variants": { "high": {}, "max": {} }
},
"claude-haiku-4-5": {
"name": "Claude Haiku 4.5 (TS)",
"limit": { "context": 1000000, "output": 128000 },
"options": { "thinking": { "type": "enabled", "budgetTokens": 16000 } },
"variants": { "high": {}, "max": {} }
}
}
}
}
}
Why this works: The Anthropic preset stays. The example ids are claude-sonnet-5 and claude-haiku-4-5. Claude Fable 5.1 (claude-fable-5-1), Opus 5.5 (claude-opus-5-5), and Haiku 5.5 (claude-haiku-5-5) can only be used inside the Claude Code CLI via Token Supply, due to Anthropic security settings. Claude Fable 5.2 (claude-fable-5-2) works from OpenCode and SDK clients with a universal key at default rates per million of $5.60 input, $28 output, $0.14 cache read, and $7 five-minute/$11.20 one-hour cache write.
Gemini models
The same key works here. OpenCode Gemini uses https://api.token-supply.com/v1beta.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"gemini": {
"options": {
"baseURL": "https://api.token-supply.com/v1beta",
"apiKey": "TOKEN_SUPPLY_API_KEY"
},
"npm": "@ai-sdk/google",
"models": {
"gemini-3.1-pro": {
"name": "Gemini 3.1 Pro (TS)",
"limit": { "context": 1048576, "output": 65536 },
"options": { "thinking": { "type": "enabled", "budgetTokens": 24576 } },
"variants": { "low": {}, "high": {} }
},
"gemini-3.1-pro-preview": {
"name": "Gemini 3.1 Pro (preview ID, TS)",
"limit": { "context": 1048576, "output": 65536 },
"options": { "thinking": { "type": "enabled", "budgetTokens": 24576 } },
"variants": { "low": {}, "high": {} }
},
"gemini-4-argon": {
"name": "Gemini 4 Argon (TS)",
"limit": { "context": 1048576, "output": 65536 },
"variants": { "low": {}, "high": {} }
},
"gemini-4-carbon": {
"name": "Gemini 4 Carbon (TS)",
"limit": { "context": 1048576, "output": 65536 },
"variants": { "low": {}, "high": {} }
},
"gemini-3.8-flash": {
"name": "Gemini 3.8 Flash (TS)",
"limit": { "context": 1048576, "output": 65536 },
"variants": { "low": {}, "high": {} }
},
"gemini-3.7-flash": {
"name": "Gemini 3.7 Flash (TS)",
"limit": { "context": 1048576, "output": 65536 },
"variants": { "low": {}, "high": {} }
},
"gemini-3.6-flash": {
"name": "Gemini 3.6 Flash (TS)",
"limit": { "context": 1048576, "output": 65536 },
"variants": { "low": {}, "high": {} }
},
"gemini-3-flash-preview": {
"name": "Gemini 3 Flash Preview (TS)",
"limit": { "context": 1048576, "output": 65536 },
"variants": { "low": {}, "high": {} }
}
}
}
}
}
Why this works: Gemini stays on the /v1beta host. The model ids are gemini-3.1-pro, its same-price alias gemini-3.1-pro-preview, gemini-4-argon, gemini-4-carbon, gemini-3.8-flash, gemini-3.7-flash, gemini-3.6-flash, and gemini-3-flash-preview.
Grok models
The same key works here. Keep the OpenAI-compatible preset and replace baseURL and apiKey.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"grok": {
"npm": "@ai-sdk/openai-compatible",
"name": "Grok (TS)",
"options": {
"baseURL": "https://api.token-supply.com/v1",
"apiKey": "TOKEN_SUPPLY_API_KEY"
},
"models": {
"grok-4.7": {
"name": "Grok 4.7 (TS)",
"limit": { "context": 500000, "output": 500000 },
"modalities": { "input": ["text", "image"], "output": ["text"] },
"variants": { "low": {}, "medium": {}, "high": {}, "xhigh": {} }
},
"grok-4.6": {
"name": "Grok 4.6 (TS)",
"limit": { "context": 500000, "output": 500000 },
"variants": { "low": {}, "medium": {}, "high": {}, "xhigh": {} }
}
}
}
}
}
Why this works: The Grok preset stays on the OpenAI-compatible host. The model id stays grok-4.7, grok-4.6, or grok-4.5.
- Replace TOKEN_SUPPLY_API_KEY with the actual ts_live_... key. Use the plain key value, not {env:TOKEN_SUPPLY_API_KEY}.
- gpt-6.1-terra is available on the OpenAI plan. The example models above stay as written. This block is not the full OpenAI catalog.
- Custom models need limit.context and limit.output. Cycle variants to change reasoning effort.
- Grok 4.7 and 4.6 use variants low, medium, high, and xhigh. high is the default and cannot be turned off. Do not send presence_penalty, frequency_penalty, or stop.
- Claude Fable 5.1 (claude-fable-5-1), Opus 5.5 (claude-opus-5-5), and Haiku 5.5 (claude-haiku-5-5) can only be used inside the Claude Code CLI via Token Supply, due to Anthropic security settings. Claude Fable 5.2 (claude-fable-5-2) works from OpenCode with a universal key; its default price per million is $5.60 input, $28 output, $0.14 cache read, and $7 five-minute/$11.20 one-hour cache write. This example uses claude-sonnet-5 and claude-haiku-4-5.
- OpenCode Anthropic uses /v1; OpenCode Gemini uses /v1beta.
- Add (TS) to model names to recognize these entries in the model picker.
Verify
Run /models after saving the file. Select a model this preset accepts, then pick a reasoning variant.
Details
- Does OpenCode work with Token Supply?
- Yes. OpenCode users who keep the built-in OpenAI, Anthropic, Gemini, or Grok preset and only swap the host.
- Why do custom models need limits?
- OpenCode cannot always detect the window behind a custom base URL. Set limit.context and limit.output.
- How do I change reasoning effort?
- Add variants on the model and cycle them in the OpenCode UI. high is a good default.
- Can one file hold several providers?
- Yes, if you have a key for each plan. Only call models that belong to the key you set on that provider.
Related
- Codex custom endpoint — config.toml, auth.json, and the Responses API.
- Claude Code custom endpoint — ANTHROPIC_BASE_URL, auth token, and settings.json.
- OpenAI SDK custom base URL — Point the OpenAI client at Token Supply.
- AI API token cost calculator — Compare listed Token Supply rates with public list prices.