packages/kilo-docs/pages/ai-providers/openrouter.md
OpenRouter is an AI platform that provides access to a wide variety of language models from different providers, all through a single API. This can simplify setup and allow you to easily experiment with different models.
Website: https://openrouter.ai/
{% tabs %} {% tab label="VSCode" %}
Open Settings (gear icon) and go to the Providers tab to add OpenRouter and enter your API key.
The extension stores this in your kilo.json config file. You can also edit the config file directly — see the CLI tab for the file format.
{% /tab %} {% tab label="CLI" %}
Set the API key as an environment variable or configure it in your kilo.json config file:
Environment variable:
export OPENROUTER_API_KEY="your-api-key"
Config file (~/.config/kilo/kilo.json or ./kilo.json):
{
"provider": {
"openrouter": {
"env": ["OPENROUTER_API_KEY"],
},
},
}
Then set your default model:
{
"model": "openrouter/anthropic/claude-sonnet-4-20250514",
}
{% /tab %} {% tab label="VSCode (Legacy)" %}
{% /tab %} {% /tabs %}
OpenRouter provides an optional "middle-out" message transform to help with prompts that exceed the maximum context size of a model.
{% tabs %} {% tab label="VSCode & CLI" %}
The middle-out transform is not exposed as a dedicated UI control in the VS Code extension. To enable it, set transforms on the model's options in your kilo.json config file. Anything under options is forwarded verbatim to the OpenRouter AI SDK as providerOptions.openrouter:
{
"provider": {
"openrouter": {
"models": {
"anthropic/claude-sonnet-4-20250514": {
"options": {
"transforms": ["middle-out"],
},
},
},
},
},
}
{% /tab %} {% tab label="VSCode (Legacy)" %}
The legacy extension does not expose a control for the middle-out transform, and it does not read configuration from kilo.json. To use this option, switch to the new VS Code extension or the CLI.
{% /tab %} {% /tabs %}
OpenRouter can route to many different inference providers. This can be controlled directly via OpenRouter's provider routing parameter.
{% tabs %} {% tab label="VSCode & CLI" %}
Provider routing is not exposed as dedicated UI controls in the VS Code extension. To configure it, set OpenRouter's provider routing fields under the model's options in your kilo.json config file. Everything under options is forwarded to the OpenRouter AI SDK as providerOptions.openrouter, so any field from the OpenRouter provider routing docs can be used.
{
"provider": {
"openrouter": {
"models": {
"anthropic/claude-sonnet-4-20250514": {
"options": {
"provider": {
"sort": "price", // "price" | "throughput" | "latency"
"order": ["Anthropic", "Google"], // specific provider preference
"only": ["Anthropic"], // restrict to listed providers
"data_collection": "deny", // "allow" | "deny"
"zdr": true, // zero data retention
},
},
},
},
},
},
}
Omit any field to fall back to your OpenRouter account's default. Fields are passed through without validation — see OpenRouter's docs for the full list of supported values.
{% /tab %} {% tab label="VSCode (Legacy)" %}
The legacy settings UI exposes Provider Routing as two dropdowns under Provider Routing:
Provider Sorting
Data Policy
{% /tab %} {% /tabs %}