DAILY NEWS

Stay Ahead, Stay Informed – Every Day

Advertisement

Use a flat-priced, auto-routing LLM API in Aider or Cline — one npx command



Coding assistants like Aider, Cline, and Continue all speak the OpenAI wire protocol — point them at a base_url, give them an API key, done. That makes swapping in a different LLM backend trivial… if that backend uses Authorization: Bearer.

The flat-priced, auto-routing API I’d been using doesn’t. It’s distributed through RapidAPI, which authenticates with an X-RapidAPI-Key header instead of Bearer. So I couldn’t just drop it into Aider. The fix turned out to be ~120 lines, so I open-sourced it.

modelis-openai

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.

your tool ──OpenAI(Bearer)──▶ modelis-openai (localhost) ──X-RapidAPI-Key──▶ upstream ──▶ best model

Enter fullscreen mode

Exit fullscreen mode

Quickstart

npx modelis-openai

Enter fullscreen mode

Exit fullscreen mode

Then point any OpenAI-compatible tool at it:

Setting
Value

Base URL
http://127.0.0.1:8787/v1

API key
your RapidAPI key

Model
modelis-auto

Drop it into your tool

Aider

export OPENAI_API_BASE=http://127.0.0.1:8787/v1
export OPENAI_API_KEY=
aider –model openai/modelis-auto

Enter fullscreen mode

Exit fullscreen mode

Cline / Roo Code — API Provider OpenAI Compatible, Base URL http://127.0.0.1:8787/v1, Model ID modelis-auto.

Continue (~/.continue/config.yaml)

models:
– name: Modelis
provider: openai
model: modelis-auto
apiBase: http://127.0.0.1:8787/v1
apiKey:

Enter fullscreen mode

Exit fullscreen mode

Any OpenAI SDK

from openai import OpenAI
client = OpenAI(base_url=”http://127.0.0.1:8787/v1″, api_key=””)
print(client.chat.completions.create(
model=”modelis-auto”,
messages=({“role”: “user”, “content”: “Hello”}),
).choices(0).message.content)

Enter fullscreen mode

Exit fullscreen mode

How it works

Reads the key from Authorization: Bearer (or MODELIS_RAPIDAPI_KEY).
Rewrites the request model to modelis-auto (configurable).
Forwards to the RapidAPI gateway with X-RapidAPI-Key / X-RapidAPI-Host.
Relays the response — including SSE streams and rate-limit headers — unchanged.

It also answers GET /v1/models and GET /health so tools that probe on startup don’t choke.

Honest notes

It routes to a paid API (there’s a free tier to start). The point of the proxy is to remove the integration friction, not to give anything away.

Cursor isn’t supported — it sends requests from its own servers, so a localhost endpoint can’t be reached. This is for tools that call the API from your machine.

Links

If you try it in a tool I didn’t list, I’d love to hear how it goes.



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *