Dev.to AI 🤖 Ai 👁 0 📖 2 min read

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

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

Quickstart

npx modelis-openai

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=<your-rapidapi-key>
aider --model openai/modelis-auto

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: <your-rapidapi-key>

Any OpenAI SDK

from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:8787/v1", api_key="<your-rapidapi-key>")
print(client.chat.completions.create(
    model="modelis-auto",
    messages=[{"role": "user", "content": "Hello"}],
).choices[0].message.content)

How it works

  1. Reads the key from Authorization: Bearer <key> (or MODELIS_RAPIDAPI_KEY).
  2. Rewrites the request model to modelis-auto (configurable).
  3. Forwards to the RapidAPI gateway with X-RapidAPI-Key / X-RapidAPI-Host.
  4. 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.

📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.