Run Kilo Code on any catalog model via OpenAI Compatible.
Updated 2026-07-16
Kilo Code ships a custom-provider flow built for gateways: pick OpenAI Compatible as the Provider API, set Base URL to https://api.apisrouter.com/v1, paste one key, and Kilo auto-fetches the model list from /v1/models. Claude, Kimi, and Codex-class ids become interchangeable backends for the agent.
Quick answer: one custom provider entry.
Open Kilo Code's settings via the gear icon, go to the Providers tab, and choose the custom provider option. Give it a Provider ID and display name, set Provider API to OpenAI Compatible, Base URL to https://api.apisrouter.com/v1, and paste your key. Once the Base URL and key are valid, Kilo queries the endpoint's /v1/models listing and presents a searchable picker of every available id, so you select claude-sonnet-4-6 or kimi-k2.7-code from a list instead of typing it blind. Models can also be added manually, and custom HTTP headers are supported as key-value pairs if you need them. Save, and the agent's next task routes through the gateway.
Provider ID: apisrouter
Display name: APIsRouter
Provider API: OpenAI Compatible
Base URL: https://api.apisrouter.com/v1
API key: sk-YOUR-APISROUTER-KEY
Models: pick from the auto-fetched list
(e.g. claude-sonnet-4-6, kimi-k2.7-code)How Kilo Code uses the provider.
Kilo Code (roughly 26K GitHub stars) is an open-source AI coding agent for VS Code: it plans, edits files, runs commands, and iterates on failures with approval gates, in the lineage of Roo and Cline. That loop has a specific traffic shape: long context in, tool calls and diffs out, many turns per task, which makes the backing model both the quality lever and the cost driver. The OpenAI Compatible provider sends that loop as standard chat completions to your Base URL, with the model id as a plain string. The wire format does not care about vendors, which is what makes real model shopping possible: claude-sonnet-4-6, kimi-k2.7-code, and gpt-5.3-codex-spark are interchangeable entries behind one provider, rather than three vendor accounts with three billing setups. For per-model tuning, token limits, tool-calling behavior, and variants live in the kilo.jsonc config file, which you can edit directly when a model needs settings the UI does not expose. Set declared limits from the model's documentation, not from optimism: the agent packs context aggressively, and an overstated window fails on exactly the largest tasks.
Choosing coding models for Kilo's loop.
Kilo's modes let different kinds of work carry different configuration, and the honest way to exploit that is empirical: run the same class of task on two ids for a week, then read per-model spend in the gateway console next to how often you had to intervene. Agent loops are the most token-intensive way to use a model, so the difference is measurable, not vibes.
- claude-sonnet-4-6 is the dependable default: strong tool calling, clean diffs, and good recovery when a command fails mid-task.
- kimi-k2.7-code is the volume pick for long agentic sessions, code-tuned and priced for the many-turn loop Kilo actually runs.
- gpt-5.3-codex-spark suits quick scoped edits and test-fixing runs where per-turn latency shapes the session.
- claude-opus-4-7 earns its rate on hard tasks: cross-file refactors, architecture work, debugging that needs the whole picture in context.
- gpt-5.5 is the frontier generalist to A/B against Claude on your own repository rather than on benchmark tables.
Pay-as-you-go · transparent per-model pricing
Selected models are priced below official list prices. Exact input, output, cache, and per-request prices are shown for each model.
| Model | Official Price | Our Price |
|---|---|---|
| Claude Sonnet 4.6 | $3.00 / $15.00 per M | $2.40 / $12.00 per M |
| Claude Opus 4.7 | $5.00 / $25.00 per M | $4.00 / $20.00 per M |
| Kimi K2.7 Code | $0.95 / $4.00 per M | $0.85 / $3.60 per M |
| GPT-5.3 Codex Spark | $1.75 / $14.00 per M | $1.40 / $11.20 per M |
| GPT-5.5 | $5.00 / $30.00 per M | $4.00 / $24.00 per M |
Failure modes specific to Kilo Code.
Debug in the standard order: curl the models listing, curl one completion with the exact id, and only then adjust Kilo's settings. Two commands split gateway problems from editor configuration cleanly.
- Model picker comes up empty: the Base URL or key is wrong, since the picker is populated from a live /v1/models call. Curl the listing with the same values to confirm.
- 404 on every request: Base URL lost its /v1, or you pasted a full /chat/completions path where a base belongs. Kilo accepts full endpoint URLs, but only if they point at the correct chat-completions route.
- Truncated or amnesiac behavior deep in a task: declared context limits in kilo.jsonc exceed what the model actually supports. Use documented values.
- Tool calls narrated instead of executed: the chosen id is weak at function calling. Rerun the task on claude-sonnet-4-6 to separate model choice from configuration before touching settings.
- Azure-specific note from the docs: Azure GPT-5 deployments reject the max_tokens field that custom OpenAI-compatible providers send, so Azure should use Kilo's native azure provider. Irrelevant for a gateway, but it explains a confusing error if you test both.
Who routes Kilo Code through a gateway.
- Developers who want Claude driving the agent without a separate Anthropic billing relationship, on a prepaid balance with a free, card-less start.
- Model shoppers using the auto-fetched picker to trial coding ids on real tasks in their real repository.
- Heavy users pairing a frontier model for planning-grade work with a volume model for long execution sessions.
- Teams metering agent spend per developer with per-key usage instead of reverse-engineering a shared vendor bill.
- People already routing other tools through a gateway who want the VS Code agent on the same key and usage log.
Verify the endpoint and run the first task.
Prove the gateway half with curl before configuring the editor: list the models, then send one completion with the id you intend to pick. When both pass, everything left is in the provider form. Then give Kilo a small real task with a clear goal and watch the first turns. Clean tool calls and sensible edits mean the id fits the loop; hard errors map to the three fields. Once tasks flow, the APIsRouter console shows per-request model, tokens, and spend, which is where a week of agent use becomes a concrete number per model.
curl -s https://api.apisrouter.com/v1/models \
-H "Authorization: Bearer $APISROUTER_API_KEY" | head -50
curl -s https://api.apisrouter.com/v1/chat/completions \
-H "Authorization: Bearer $APISROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"kimi-k2.7-code",
"messages":[{"role":"user","content":"ping"}]}'FAQ
How do I add an OpenAI-compatible provider to Kilo Code?
Settings gear → Providers tab → custom provider. Set Provider API to OpenAI Compatible, Base URL to https://api.apisrouter.com/v1, and paste your key. Kilo then auto-fetches the model list from /v1/models and you pick ids from a searchable list.
Can Kilo Code run Claude models through this provider?
Yes. The provider forwards the model id as a plain string over standard chat completions, so claude-sonnet-4-6 and claude-opus-4-7 work the same way GPT ids do, on one key, and switching vendors is a picker selection.
Why is the model list empty after I add the provider?
The auto-fetch populates from a live /v1/models call, so an empty list means the Base URL or key is wrong. Curl the listing with the same values; if that works, re-check what you actually saved in the provider form. Models can also be added manually.
Where do I set context window and token limits for a custom model?
In kilo.jsonc, Kilo's config file, which carries per-model token limits, tool-calling settings, and variants beyond what the provider form exposes. Use the model's documented values; overstated limits fail on the biggest tasks.
Does the API key have to go in the form?
The key field is the normal path, but it is optional if you handle authentication through custom headers, which the provider form supports as key-value pairs. For a standard gateway setup, the key field is the right choice.
How do I know what a week of Kilo Code costs?
Read the per-key usage view in the APIsRouter console: tokens and spend per request and per model. Agent tasks are dozens of requests each, so the log is the only honest measure of what your usage pattern costs.