Integrations

LiteLLM

Reach every MiniRouter model from the LiteLLM SDK or proxy.

LiteLLM is a Python SDK and proxy with one OpenAI-style interface. Add MiniRouter once and every app behind it reaches the catalog, routers and your presets, on one balance.

1. Install the proxy

Terminal
pip install 'litellm[proxy]'

2. Export your key

Create a key, then export it where the proxy runs.

~/.zshrc or ~/.bashrc
export MINIROUTER_API_KEY=mr-live-YOUR-KEY-HERE

3. Add a model

config.yaml
model_list:
  - model_name: glm-5.3-flash
    litellm_params:
      model: openai/zai/glm-5.3-flash
      api_base: https://api.minirouter.sh/v1
      api_key: os.environ/MINIROUTER_API_KEY

Clients of the proxy call the model_name. litellm_params.model is what MiniRouter receives.

4. Start and verify

Terminal
litellm --config config.yaml
Second terminal
curl http://0.0.0.0:4000/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"glm-5.3-flash","messages":[{"role":"user","content":"Hello"}]}'

Open Activity. The request lists its model, tokens and exact cost.

Call from the Python SDK

No proxy needed. Pass the base URL and key on each call.

Python
import os
from litellm import completion

response = completion(
    model="openai/zai/glm-5.3-flash",
    api_base="https://api.minirouter.sh/v1",
    api_key=os.environ["MINIROUTER_API_KEY"],
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)

Add routers and presets

Each entry becomes one model_name for proxy clients.

config.yaml
model_list:
  - model_name: auto-code
    litellm_params:
      model: openai/minirouter/auto:code
      api_base: https://api.minirouter.sh/v1
      api_key: os.environ/MINIROUTER_API_KEY
  - model_name: my-preset
    litellm_params:
      model: openai/@preset/your-slug
      api_base: https://api.minirouter.sh/v1
      api_key: os.environ/MINIROUTER_API_KEY
openai/minirouter/auto:code
A tool-capable model Auto picks.
openai/minirouter/fusion
The model and effort Fusion picks.
openai/@preset/your-slug
Your saved preset, editable from the dashboard.

Keep spend in check

Restrict models or filter content with Guardrails.

Troubleshooting

404 from the gateway

Set api_base to https://api.minirouter.sh/v1 exactly. LiteLLM's OpenAI transport does not add /v1 for a custom api_base, so include it yourself and nothing after it.

Error: 400 invalid_request.

Cost tracking shows $0 for every request

LiteLLM prices from its own model table, which does not list our ids. Billing on our side is unaffected; read the x-minirouter-balance-usd header for the truth.

401 on every request

Wrong or rotated key. Keys start with mr-live-; after a rotation the old key keeps working for 24 hours, then dies.

Error: 401 invalid_api_key.

402 before any tokens arrive

Balance below the estimated cost of the request. Top up (from $0.50 with direct Solana payments) — and watch the x-minirouter-balance-usd header, the low-balance signal every response carries.

Error: 402 insufficient_credits.

Every error code, with its fix: Errors.

Next steps

Esc