1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5633],{48059:(e,t,n)=>{"use strict";n.r(t),n.d(t,{includes:()=>r,upper:()=>o});let r={transform(e){let[t,n]=Object.values(e);return!!Array.isArray(t)&&t.includes(n)}},o={transform(e){let t=e[0];return"string"==typeof t?t.toUpperCase():t}}},50657:(e,t,n)=>{"use strict";n.r(t),n.d(t,{__N_SSG:()=>f,default:()=>m,markdoc:()=>y});var r=n(11872),o=n(34904),i=n(92130),a=n(9760),s=n(90102),d=n(89966),p=n(48059);let l={tags:(0,a.X)(s),nodes:(0,a.X)(d),functions:(0,a.X)(p),...(0,a.X)({})},u=new i.Ay.Tokenizer({allowComments:!0}).tokenize('---\ntitle: "Using OpenRouter with Kilo Code | Unified AI API"\ndescription: "Access hundreds of AI models through a single API by configuring OpenRouter in Kilo Code. Setup guide for VS Code and the CLI."\nsidebar_label: OpenRouter\n---\n\n# Using OpenRouter With Kilo Code\n\nOpenRouter 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.\n\n**Website:** [https://openrouter.ai/](https://openrouter.ai/)\n\n## Getting an API Key\n\n1. **Sign Up/Sign In:** Go to the [OpenRouter website](https://openrouter.ai/). Sign in with your Google or GitHub account.\n2. **Get an API Key:** Go to the [keys page](https://openrouter.ai/keys). You should see an API key listed. If not, create a new key.\n3. **Copy the Key:** Copy the API key.\n\n## Configuration in Kilo Code\n\n{% tabs %}\n{% tab label="VSCode" %}\n\nOpen **Settings** (gear icon) and go to the **Providers** tab to add OpenRouter and enter your API key.\n\nThe 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.\n\n{% /tab %}\n{% tab label="CLI" %}\n\nSet the API key as an environment variable or configure it in your `kilo.json` config file:\n\n**Environment variable:**\n\n```bash\nexport OPENROUTER_API_KEY="your-api-key"\n```\n\n**Config file** (`~/.config/kilo/kilo.json` or `./kilo.json`):\n\n```jsonc\n{\n "provider": {\n "openrouter": {\n "env": ["OPENROUTER_API_KEY"],\n },\n },\n}\n```\n\nThen set your default model:\n\n```jsonc\n{\n "model": "openrouter/anthropic/claude-sonnet-4-20250514",\n}\n```\n\n{% /tab %}\n{% /tabs %}\n\n## Supported Transforms\n\nOpenRouter provides an [optional "middle-out" message transform](https://openrouter.ai/docs/guides/features/message-transforms) to help with prompts that exceed the maximum context size of a model.\n\nThe 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`:\n\n```jsonc\n{\n "provider": {\n "openrouter": {\n "models": {\n "anthropic/claude-sonnet-4-20250514": {\n "options": {\n "transforms": ["middle-out"],\n },\n },\n },\n },\n },\n}\n```\n\n## Provider Routing\n\nOpenRouter can route to many different inference providers. This can be controlled directly via OpenRouter\'s [`provider` routing parameter](https://
1openrouter.ai/docs/guides/routing/provider-selection).\n\nProvider 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](https://openrouter.ai/docs/guides/routing/provider-selection) can be used.\n\n```jsonc\n{\n "provider": {\n "openrouter": {\n "models": {\n "anthropic/claude-sonnet-4-20250514": {\n "options": {\n "provider": {\n "sort": "price", // "price" | "throughput" | "latency"\n "order": ["Anthropic", "Google"], // specific provider preference\n "only": ["Anthropic"], // restrict to listed providers\n "data_collection": "deny", // "allow" | "deny"\n "zdr": true, // zero data retention\n },\n },\n },\n },\n },\n },\n}\n```\n\nOmit 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.\n\n## Tips and Notes\n\n- **Model Selection:** OpenRouter offers a wide range of models. Experiment to find the best one for your needs.\n- **Pricing:** OpenRouter charges based on the underlying model\'s pricing. See the [OpenRouter Models page](https://openrouter.ai/models) for details.\n- **Prompt Caching:** Some providers support prompt caching. See the OpenRouter documentation for supported models.\n'),c=i.Ay.parse(u,{slots:!1}),g=c.attributes.frontmatter?o.Ay.load(c.attributes.frontmatter):{},{components:h}=(0,a._)(l);var f=!0;let y={frontmatter:g};function m(e){let t=e.markdoc;return i.ZR.react(t.content,r,{components:{...h,...e.components}})}},74208:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/ai-providers/openrouter",function(){return n(50657)}])},89966:(e,t,n)=>{"use strict";n.r(t),n.d(t,{fence:()=>i,heading:()=>s,table:()=>p,tbody:()=>u,td:()=>h,th:()=>g,thead:()=>l,tr:()=>c});var r=n(92130),o=n(62968);let i={render:o.NG,attributes:r.a9.fence.attributes};function a(e){return"string"==typeof e?e:r.vw.isTag(e)?e.children.map(a).join(" "):""}let s={render:o.DZ,children:["inline"],attributes:{id:{type:String},level:{type:Number,required:!0,default:1},className:{type:String}},transform(e,t){let n=e.transformAttributes(t),o=e.transformChildren(t),i=n.id&&"string"==typeof n.id?n.id:o.map(a).join(" ").replace(/[?/]/g,"").replace(/\s+/g,"-").toLowerCase();return new r.vw(this.render,{...n,id:i},o)}};var d=n(17499);let p={...r.a9.table,render:d.XI},l={...r.a9.thead,render:d.D1},u={...r.a9.tbody,render:d.vc},c={...r.a9.tr,render:d.Tr},g={...r.a9.th,render:d.Th,attributes:{...r.a9.th.attributes,width:{type:String}}},h={...r.a9.td,render:d.Td,attributes:{...r.a9.td.attributes,colspan:{type:Number},rowspan:{type:Number}}}},90102:(e,t,n)=>{"use strict";n.r(t),n.d(t,{browserFrame:()=>y,callout:()=>o,codicon:()=>i,copyLine:()=>a,flowDiagram:()=>f,icon:()=>p,image:()=>l,imageGallery:()=>u,kiloCodeIcon:()=>c,linebreak:()=>m,tab:()=>d,tabs:()=>s,video:()=>g,youtube:()=>h});var r=n(62968);let o={render:r.Pq,children:["paragraph","tag","list"],attributes:{title:{type:String,description:"Optional custom title for the callout"},type:{type:String,default:"note",matches:["generic","note","tip","info","warning","danger"],description:"The type of callout: generic (no icon/title), note, tip, info, warning, or danger"},collapsed:{type:Boolean,default:!1,description:"When true, the callout starts collapsed and can be expanded by clicking the header"}}},i={render:r.W6,selfClosing:!0,attributes:{name:{type:String,required:!0,description:"The name of the VS Code codicon (e.g., 'send', 'check', 'warning')"},size:{type:String,default:"1em",description:"The size of the icon (CSS font-size value)"},className:{type:String,default:"",description:"Additional CSS classes to apply to the icon"}}},a={render:r.a7,selfClosing:!0,attributes:{text:{type:String,required:!0,description:"The exact one-line text to display and copy"}}},s={render:r.tU,children:["tab"],attributes:{}},d={render:r.oz,children:["paragraph","tag","list","fence","heading"],attributes:{label:{type:String,required:!0,description:"The label shown on the tab button"}}},p={render:r.In,selfClosing:!0,attributes:{src:{type:String,required:!0},srcDark:{type:String,description:"Optional image source for dark mode. Falls back to src if not provided."},alt:{type:String,default:"icon"},size:{type:String,default:"1.2em"}}},l={render:r._V,selfClosing:!0,attributes:{src:{type:String,required:!0,description:"The image source URL"},alt:{type:String,required:!0,description:"Alternative text for the image"},width:{type:String,description:"Width of the image (e.g., '500px', '80%')"},height:{type:String,description:"Height of the image (e.g., '300px', 'auto')"},caption:{type:String,description:"Optional caption displayed below the image"}}},u={render:r.i_,children:["tag"],attributes:{columns:{type:String,description:"Preferred number of image columns on wide screens"},width:{type:String,description:"Preferred width of each gallery image"}}},c={render:r.kz,selfClosing:!0,attributes:{size:{type:String,default:"1.2em",description:"Size of the icon (CSS height value)"}}},g={render:r.n5,selfClosing:!0,attributes:{url:{type:String,required:!0,description:"The YouTube video URL"},title:{type:String,description:"Accessible title for the video iframe"},caption:{type:String,description:"Optional caption to display below the video"}}},h={render:r.Yu,selfClosing:!0,attributes:{url:{type:String,required:!0,description:"The YouTube video URL"},title:{type:String,description:"Accessible title for the video iframe"},caption:{type:String,description:"Optional caption to display below the video"}}},f={render:r.Cb,selfClosing:!0,attributes:{name:{type:String,required:!0,description:"Name of the diagram to render (must match a key in diagrams/index.ts)"},height:{type:String,default:"400px",description:"Height of the diagram container"}}},y={render:r.AR,children:["paragraph","tag","list"],attributes:{url:{type:String,description:"Optional URL to display in the address bar"},caption:{type:String,description:"Optional caption below the frame"}}},m={render:"br",selfClosing:!0}}},e=>{e.O(0,[8228,2775,636,6593,8792],()=>e(e.s=74208)),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.