Kilo Code + OpenRouter: Setup, Model Routing, and Free Models
OpenRouter ·
On this page
Kilo Code runs the coding session: chat, edits, context, modes, and the model picker inside your editor or terminal. It doesn’t ship its own models. It expects you to bring a provider.
OpenRouter is that provider layer. Add it and Kilo gets one API key for 300+ models across 60+ providers, plus routing rules, failover, and billing in one place. Kilo also offers Kilo Gateway, its own managed-billing path, which we compare below. The whole setup is three steps, and the routing controls live in one config file.
Add OpenRouter to Kilo Code in three steps
First, create a key on your API Keys page. Sign in with Google or GitHub. Load credits on the pricing page unless you’re sticking to free models. There’s no minimum spend on pay-as-you-go.
Second, open Settings in Kilo Code from the gear icon, go to the Providers tab, click Connect on OpenRouter, paste the key, and save.
Third, open the model picker and type a name or slug to switch models. Browse the live list at openrouter.ai/models, since the catalog changes as providers ship new models.
Kilo writes that provider setup to kilo.json (or ~/.config/kilo/kilo.json), so the VS Code extension and the CLI share one config. The Providers tab edits the file for you; CLI users can edit it directly. A saved key with no credits still fails on the first paid request, so load credits before testing a paid model.
Control routing and long prompts from kilo.json
Kilo forwards anything under a model’s options straight to OpenRouter as providerOptions.openrouter, without validating it. That pass-through is what gives you OpenRouter’s provider routing inside Kilo. Put the provider block under models.{modelId}.options:
{
"provider": {
"openrouter": {
"models": {
"anthropic/claude-sonnet-4.5": {
"options": {
"provider": {
"sort": "price",
"order": ["Anthropic", "Google"],
"only": ["Anthropic"],
"data_collection": "deny",
"zdr": true
}
}
}
}
}
}
}
Each field maps to an OpenRouter routing parameter: sort by price, throughput, or latency; order to set provider preference; only to fail rather than leave an approved list; data_collection and zdr for data policy. The nesting has to be exact. A provider block at the root provider.openrouter level does nothing, and because Kilo passes fields through unvalidated, a misspelled field is ignored with no error. Match the path above exactly.
For prompts that run past a model’s context window, OpenRouter’s middle-out transform drops content from the middle, where models pay the least attention, instead of rejecting the request. Turn it on in the same options block:
{ "options": { "transforms": ["middle-out"] } }
Run free models inside Kilo
OpenRouter has 20+ free models. Filter for them by typing free in Kilo’s model picker. With no credits loaded, free models run at 50 requests per day and 20 per minute. Add $10 or more in credits and that daily cap rises to 1,000.
Keep the two free paths straight. OpenRouter free models use your OpenRouter account and rate limits. Kilo’s kilo-auto/free, served through Kilo Gateway, doesn’t touch your OpenRouter credits or routing rules.
One caveat for private code: free endpoints can log prompts, so they’re a poor fit for proprietary source unless the data policy works for you. Add data_collection: "deny" to narrow eligible providers.
Choose OpenRouter or Kilo Gateway
Both put models in front of Kilo Code, so the choice comes down to what your team already runs.
Reach for OpenRouter when you already use it across tools, want provider routing controls, or want one account and one bill spanning every AI tool you run. It charges 5.5% on credit purchases with no provider markup, and BYOK lets you route through your own provider key for 5% of what the provider would bill, waived for the first 1M requests each month.
Kilo Gateway is the native path: Kilo markets it as zero-markup, billing lands in your Kilo account, and routing is Kilo-managed. If Kilo Code is your only AI surface and it carries the exact model you need, compare that model in Kilo Gateway before taking on the OpenRouter fee. It mostly comes down to account gravity. If OpenRouter already sits in your stack, add it to Kilo and keep one routing policy.
Frequently asked questions
Is OpenRouter free with Kilo Code?
Partly. OpenRouter has 20+ free models you can use inside Kilo Code, capped at 50 requests per day and 20 per minute with no credits loaded. Add $10 or more in credits and the free-model cap rises to 1,000 requests per day. Kilo’s own kilo-auto/free option is separate and runs through Kilo Gateway.
What is the difference between Kilo Code and OpenRouter?
Kilo Code is the coding agent that runs in your editor or terminal. OpenRouter is a provider you add inside Kilo Code to reach 300+ models from 60+ providers through one API key. You use them together.
How do I set the OpenRouter provider order in Kilo Code?
Add an order array under models.{modelId}.options.provider in kilo.json, listing provider names in preference order such as ["Anthropic", "Google"]. Add only to restrict requests to an approved list. Kilo forwards these fields to OpenRouter without validating them.
Does OpenRouter cost more than Kilo’s own gateway?
OpenRouter charges a 5.5% fee on credit purchases and doesn’t mark up provider prices. Kilo markets Kilo Gateway as zero-markup. OpenRouter is often the better operational choice when you already use it across tools or need provider routing controls.
Can I use OpenRouter with the Kilo CLI?
Yes. The CLI reads the same kilo.json config, so you can add the OpenRouter provider block and routing options directly. The VS Code Providers tab writes to the same file.