{"id":5966,"date":"2026-06-23T11:08:14","date_gmt":"2026-06-23T04:08:14","guid":{"rendered":"https:\/\/daiilynews.cu.ma\/?p=5966"},"modified":"2026-06-23T11:08:14","modified_gmt":"2026-06-23T04:08:14","slug":"use-a-flat-priced-auto-routing-llm-api-in-aider-or-cline-one-npx-command","status":"publish","type":"post","link":"https:\/\/daiilynews.cu.ma\/?p=5966","title":{"rendered":"Use a flat-priced, auto-routing LLM API in Aider or Cline \u2014 one npx command"},"content":{"rendered":"<p> <br \/>\n<br \/>\n                Coding assistants like Aider, Cline, and Continue all speak the OpenAI wire protocol \u2014 point them at a base_url, give them an API key, done. That makes swapping in a different LLM backend trivial&#8230; if that backend uses Authorization: Bearer.<\/p>\n<p>The flat-priced, auto-routing API I&#8217;d been using doesn&#8217;t. It&#8217;s distributed through RapidAPI, which authenticates with an X-RapidAPI-Key header instead of Bearer. So I couldn&#8217;t just drop it into Aider. The fix turned out to be ~120 lines, so I open-sourced it.<\/p>\n<p>  modelis-openai<\/p>\n<p>A zero-dependency local proxy (MIT, Node 18+). It listens on 127.0.0.1, speaks plain OpenAI, rewrites the auth header, and forwards to the upstream gateway. Streaming (stream: true) is piped straight through, so token-by-token output works exactly as with the OpenAI API.<\/p>\n<p>your tool \u2500\u2500OpenAI(Bearer)\u2500\u2500\u25b6 modelis-openai (localhost) \u2500\u2500X-RapidAPI-Key\u2500\u2500\u25b6 upstream \u2500\u2500\u25b6 best model<\/p>\n<p>    Enter fullscreen mode<\/p>\n<p>    Exit fullscreen mode<\/p>\n<p>  Quickstart<\/p>\n<p>npx modelis-openai<\/p>\n<p>    Enter fullscreen mode<\/p>\n<p>    Exit fullscreen mode<\/p>\n<p>Then point any OpenAI-compatible tool at it:<\/p>\n<p>Setting<br \/>\nValue<\/p>\n<p>Base URL<br \/>\nhttp:\/\/127.0.0.1:8787\/v1<\/p>\n<p>API key<br \/>\nyour RapidAPI key<\/p>\n<p>Model<br \/>\nmodelis-auto<\/p>\n<p>  Drop it into your tool<\/p>\n<p>Aider<\/p>\n<p>export OPENAI_API_BASE=http:\/\/127.0.0.1:8787\/v1<br \/>\nexport OPENAI_API_KEY=<br \/>\naider &#8211;model openai\/modelis-auto<\/p>\n<p>    Enter fullscreen mode<\/p>\n<p>    Exit fullscreen mode<\/p>\n<p>Cline \/ Roo Code \u2014 API Provider OpenAI Compatible, Base URL http:\/\/127.0.0.1:8787\/v1, Model ID modelis-auto.<\/p>\n<p>Continue (~\/.continue\/config.yaml)<\/p>\n<p>models:<br \/>\n  &#8211; name: Modelis<br \/>\n    provider: openai<br \/>\n    model: modelis-auto<br \/>\n    apiBase: http:\/\/127.0.0.1:8787\/v1<br \/>\n    apiKey: <\/p>\n<p>    Enter fullscreen mode<\/p>\n<p>    Exit fullscreen mode<\/p>\n<p>Any OpenAI SDK<\/p>\n<p>from openai import OpenAI<br \/>\nclient = OpenAI(base_url=&#8221;http:\/\/127.0.0.1:8787\/v1&#8243;, api_key=&#8221;&#8221;)<br \/>\nprint(client.chat.completions.create(<br \/>\n    model=&#8221;modelis-auto&#8221;,<br \/>\n    messages=({&#8220;role&#8221;: &#8220;user&#8221;, &#8220;content&#8221;: &#8220;Hello&#8221;}),<br \/>\n).choices(0).message.content)<\/p>\n<p>    Enter fullscreen mode<\/p>\n<p>    Exit fullscreen mode<\/p>\n<p>  How it works<\/p>\n<p>Reads the key from Authorization: Bearer  (or MODELIS_RAPIDAPI_KEY).<br \/>\nRewrites the request model to modelis-auto (configurable).<br \/>\nForwards to the RapidAPI gateway with X-RapidAPI-Key \/ X-RapidAPI-Host.<br \/>\nRelays the response \u2014 including SSE streams and rate-limit headers \u2014 unchanged.<\/p>\n<p>It also answers GET \/v1\/models and GET \/health so tools that probe on startup don&#8217;t choke.<\/p>\n<p>  Honest notes<\/p>\n<p>It routes to a paid API (there&#8217;s a free tier to start). The point of the proxy is to remove the integration friction, not to give anything away.<\/p>\n<p>Cursor isn&#8217;t supported \u2014 it sends requests from its own servers, so a localhost endpoint can&#8217;t be reached. This is for tools that call the API from your machine.<\/p>\n<p>  Links<\/p>\n<p>If you try it in a tool I didn&#8217;t list, I&#8217;d love to hear how it goes.<\/p>\n<p><br \/>\n<br \/><a href=\"https:\/\/dev.to\/chenxiao5580cmd\/use-a-flat-priced-auto-routing-llm-api-in-aider-or-cline-one-npx-command-3k5l\">Source link <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Coding assistants like Aider, Cline, and Continue all speak the OpenAI wire protocol \u2014 point them at a base_url, give them an API key, done. That makes swapping in a different LLM backend trivial&#8230; if that backend uses Authorization: Bearer. The flat-priced, auto-routing API I&#8217;d been using doesn&#8217;t. It&#8217;s distributed through RapidAPI, which authenticates with [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5967,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[676],"tags":[835,761,765,762,763,764,1523,937,760,795],"class_list":["post-5966","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech-ai","tag-ai","tag-coding","tag-community","tag-development","tag-engineering","tag-inclusive","tag-llm","tag-opensource","tag-software","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=\/wp\/v2\/posts\/5966","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5966"}],"version-history":[{"count":0,"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=\/wp\/v2\/posts\/5966\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=\/wp\/v2\/media\/5967"}],"wp:attachment":[{"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}