OpenRouter now supports presets, which can be used to fine tune model access. Such as requesting GLM-4.5 Air (free) and falling through to GLM 4.7 Flash when free inference is limited.
OpenCode can connect to presets via config like the following
{
"provider": {
"openrouter": {
"npm": "@ai-sdk/openai-compatible",
"name": "OpenRouter (external)",
"options": {
"baseURL": "https://openrouter.ai/api/v1"
},
"models": {
"@preset/free-then-cheap": {
"name": "Free then Cheap (OpenRouter)"
}
}
}
}
}
However OpenRouter does not list presets in calls to https://openrouter.ai/api/v1/models, even with the appropriate Auth token, so they have to selected manually.
Provide support to list list in ~/.config/Code/User/chatLanguageModels.json, e.g.
[
{
"name": "OpenRouter",
"vendor": "openrouter",
"apiKey": "<api_key>",
"models": [
{
"id": "@preset/free-then-cheap",
"name": "Free then Cheap",
"url": "https://openrouter.ai/api/v1/chat/completions",
"toolCalling": true,
"vision": false,
"maxInputTokens": 128000,
"maxOutputTokens": 16000
}
]
},
]
OpenRouter now supports presets, which can be used to fine tune model access. Such as requesting GLM-4.5 Air (free) and falling through to GLM 4.7 Flash when free inference is limited.
OpenCode can connect to presets via config like the following
{ "provider": { "openrouter": { "npm": "@ai-sdk/openai-compatible", "name": "OpenRouter (external)", "options": { "baseURL": "https://openrouter.ai/api/v1" }, "models": { "@preset/free-then-cheap": { "name": "Free then Cheap (OpenRouter)" } } } } }However OpenRouter does not list presets in calls to https://openrouter.ai/api/v1/models, even with the appropriate Auth token, so they have to selected manually.
Provide support to list list in
~/.config/Code/User/chatLanguageModels.json, e.g.[ { "name": "OpenRouter", "vendor": "openrouter", "apiKey": "<api_key>", "models": [ { "id": "@preset/free-then-cheap", "name": "Free then Cheap", "url": "https://openrouter.ai/api/v1/chat/completions", "toolCalling": true, "vision": false, "maxInputTokens": 128000, "maxOutputTokens": 16000 } ] }, ]