MACHINE-READABLE API REFERENCE

Build withModel Router.

One OpenAI-compatible endpoint. 39+ models — text, vision, image generation and video — with pay-as-you-go wallet billing and guaranteed structured output.

39+
models
$0.06/M
from
3 SDKs
OpenAI · Claude · cURL
99.9%
uptime target
01 — Overview

One endpoint. Every model.

Model Router routes your requests across 39+ state-of-the-art models with automatic failover, zero-buffering streaming and per-second video generation, speech-to-text and text-to-speech — all billed from one pay-as-you-go wallet.

quick start — works with any OpenAI SDK
curl https://api.modelrouter.in/v1/chat/completions \
  -H "Authorization: Bearer $MR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4-flash",
    "messages": [
      {"role": "user", "content": "Hello"}
    ],
    "max_tokens": 2000
  }'

Set base_url = "https://api.modelrouter.in/v1" in any OpenAI / Anthropic SDK. Auth accepts Bearer, X-Astra-Key or x-api-key.

02 — Auth

Three ways to pass your key.

Every endpoint accepts the same key in three header styles — pick whatever your SDK prefers.

Authorization
Bearer sk-...
X-Astra-Key
sk-...
x-api-key
sk-... (Claude SDKs)
03 — Models

39+ models. Zero lock-in.

Live list always available at GET /v1/models.

GLM-5.3-Flashflagship Zhipu GLM · reasoning-capable · best value
DeepSeek-V4.1-Flashfast general chat · deepseek-v4-pro for heavier tasks
Qwen3.8 / Qwen3-Max / Qwen3-CoderAlibaba Qwen family
kimi-k3 / kimi-k2.7-codeMoonshot Kimi · strong at code
minimax-m3 / M2.7MiniMax family
qwen3-next-80b / Qwen3.5-Flashmore Qwen tiers · 39 models live on the router
whisper-small / whisper-mediumspeech to text · 99 languages
dall-e-3 · flux-imageimage generation
kitten-tts / qwen3-ttstext to speech · 683 voices
04 — Endpoints

Everything, one base URL.

POST/v1/chat/completionsOpenAI-format chat · streaming · structured output
POST/v1/messagesAnthropic Claude format (x-api-key auth)
POST/v1/images/generationstext-to-image · b64_json or url
POST/v1/videosvideo job (async)
GET/v1/videos/{id}poll status · signed url when done
GET/v1/videos/{id}/contentdownload rendered MP4
POST/v1/audio/speechtext to speech · 683 voices · WAV 24kHz
POST/v1/audio/transcriptionsspeech to text · whisper · 99 languages
GET/v1/modelslist all models for your key
GET/v1/key/infobalance · usage · model access
GET/v1/infoaccount · plan · logins · wallet
05 — Vision & OCR

Send images. Get text back.

The vision model reads screenshots, scanned documents, handwriting, tables and receipts — pass an image inline (base64 data URL) or via a public URL in image_url. OCR is the same call: ask for the text or JSON you want.

1 · Vision request
POST /v1/chat/completions
curl https://api.modelrouter.in/v1/chat/completions \
  -H "Authorization: Bearer $MR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4-flash-vision-exp",
    "messages": [{
      "role": "user",
      "content": [
        {"type": "text", "text": "Extract all text from this image."},
        {"type": "image_url", "image_url": {"url": "data:image/png;base64,..."}}
      ]
    }],
    "max_tokens": 2000
  }'
2 · OCR prompt (same endpoint)
OCR — ask for structured output
"content": [
  {"type": "text", "text": "OCR this receipt. Return every line as JSON:
    [{\"item\": string, \"qty\": number, \"price\": number}]"},
  {"type": "image_url", "image_url": {"url": "https://example.com/receipt.jpg"}}
]
3 · Response
choices[0].message.content
{
  "items": [
    { "item": "Milk 1L", "qty": 2, "price": 58.0 },
    { "item": "Bread",   "qty": 1, "price": 35.0 }
  ],
  "total": 151.0
}
base64 data URLs
inline images — no separate upload endpoint needed
public URLs
any image_url the gateway can fetch works too
max_tokens ≥ 2000
the model reasons before answering — give it room
06 — Streaming

Token by token. SSE standard.

Add "stream": true and the response becomes text/event-stream — Server-Sent Events in the exact OpenAI wire format: data: lines with delta fields, zero buffering through the gateway. Works on /v1/chat/completions and every OpenAI SDK handles it natively.

POST /v1/chat/completions — stream
curl https://api.modelrouter.in/v1/chat/completions \
  -H "Authorization: Bearer $MR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4-flash",
    "messages": [{"role": "user", "content": "Count 1 to 5"}],
    "max_tokens": 2000,
    "stream": true
  }'
wire format — SSE chunks
data: {"choices":[{"index":0,"delta":{"role":"assistant"}}]}

data: {"choices":[{"index":0,"delta":{"content":"1"}}]}

data: {"choices":[{"index":0,"delta":{"content":"2"}}]}

...

data: {"choices":[],"usage":{"prompt_tokens":9,"completion_tokens":12}}

data: [DONE]
delta fields
tokens arrive in choices[].delta, not message
data: [DONE]
terminator line ends every stream
usage in final chunk
token counts ride on the last data: line
07 — Tool Calling

Let the model call your functions.

Pass an OpenAI-format tools[] array and the model returns tool_calls with JSON arguments — it decides when to call, you execute, send the result back as a role: "tool" message and it writes the final answer. Works with streaming and on every tool-capable model in the list (deepseek, qwen, minimax, GLM).

1 · Declare tools
request
{
  "model": "deepseek-v4-flash",
  "messages": [{"role": "user", "content": "Weather in Nanded?"}],
  "max_tokens": 2000,
  "tools": [{
    "type": "function",
    "function": {
      "name": "get_weather",
      "description": "Get current weather for a city",
      "parameters": {
        "type": "object",
        "properties": { "city": {"type": "string"} },
        "required": ["city"]
      }
    }
  }]
}
2 · Model responds with a call
response — finish_reason: tool_calls
{
  "choices": [{
    "finish_reason": "tool_calls",
    "message": {
      "role": "assistant",
      "tool_calls": [{
        "id": "call_e06a27e14cbc4ffca5a413d5",
        "type": "function",
        "function": {
          "name": "get_weather",
          "arguments": "{\"city\": \"Nanded\"}"
        }
      }]
    }
  }]
}
3 · complete the loop
# 2 · run the function, send the result back
messages.append(response.choices[0].message)
messages.append({
  "role": "tool",
  "tool_call_id": response.choices[0].message.tool_calls[0].id,
  "content": '{"temp_c": 29, "sky": "clear"}'
})
# 3 · model writes the final answer from your data
JSON Schema parameters
arguments arrive schema-valid — parse and run
finish_reason: tool_calls
your signal to execute the function
round-trip
tool result goes back as role: "tool" with the call id
08 — Structured Output

JSON Schema. Guaranteed.

Add response_format with a JSON Schema — the output is schema-valid by construction via guided decoding. No code fences, no prose, no parsing hacks.

request — POST /v1/chat/completions
{
  "model": "/data/models/GLM-5.3-Flash",
  "messages": [{"role": "user", "content": "Create person record: Ravi, 30, Mumbai"}],
  "max_tokens": 2000,
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "person",
      "strict": true,
      "schema": {
        "type": "object",
        "properties": {
          "name": {"type": "string"},
          "age": {"type": "integer"},
          "city": {"type": "string"}
        },
        "required": ["name", "age", "city"],
        "additionalProperties": false
      }
    }
  }
}
response → choices[0].message.content
guaranteed output — pure JSON
{ "name": "Ravi", "age": 30, "city": "Mumbai" }
strict: true
full schema enforcement — no drift
json_object mode
simple "must be JSON" without schema
max_tokens ≥ 2000
reasoning models think before emitting JSON
09 — Video Generation

Text to video, $0.10/second.

Submit a job, poll the status, play the MP4 — signed URL included in the status response, valid for one hour, playable directly in any browser.

1 · Submit
1
POST /v1/videos
{"model": "/data/Models/MiniMax-H3", "prompt": "...",
 "seconds": "5", "aspect_ratio": "16:9"}
→ {"task_id": "task_...", "status": "queued"}
2 · Poll (~2.5 min for 5s)
2
GET /v1/videos/{task_id}
→ {"status": "completed", "progress": 100,
 "url": "/media/video_gen_....mp4?exp=...&sig=..."}
3 · Play / download
3
https://api.modelrouter.in{url}
→ signed link, plays in browser, no auth needed, 1-hour validity
10 — Text to Speech

Text to speech, GPU-fast.

Qwen3-TTS turns text into natural speech — 683 voices, Hindi + 8 languages, WAV 24kHz output. Generated faster than real-time playback, so a 5-minute narration finishes in about two and a half minutes.

1 · Generate speech
POST /v1/audio/speech
curl https://api.modelrouter.in/v1/audio/speech \
  -H "Authorization: Bearer $MR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3-tts",
    "input": "Your text here, up to 10,000 characters.",
    "voice": "estelle"
  }' \
  -o speech.wav
2 · Voices
estelle
default — natural, warm
682 cloned IDs
every voice_xxx works — full list
24kHz WAV
studio-quality PCM, plays everywhere
Limits
10,000 chars max
longer input returns 413 — split into chunks and concatenate the audio
~0.5× real-time
a 5-minute narration generates in about 2.5 minutes
11 — Speech to Text

Speech to text, 99 languages.

Whisper transcription from an audio file — upload MP3, WAV, M4A or WebM, get back plain text. Hindi, English and 97 more languages supported, with automatic language detection.

1 · Transcribe
POST /v1/audio/transcriptions
curl https://api.modelrouter.in/v1/audio/transcriptions \
  -H "Authorization: Bearer $MR_KEY" \
  -F [email protected] \
  -F model=whisper-small
2 · Response
200 OK
{"text": "Hello, this is what was said in the recording."}
Models
whisper-small
fast — best for clear audio and quick drafts
whisper-medium
large-v3-turbo — higher accuracy on noisy audio
12 — OCR & ASR Models

OCR + ASR. Pick the right model.

One key, every modality. Vision/OCR runs on the flagship vision model; speech-to-text has two Whisper tiers — small for quick drafts, medium for noisy audio.

Vision/OCRdeepseek-v4-flash-vision-exptext + image input — screenshots, scanned docs, handwriting, tables
ASR · fastwhisper-smallbest for clear audio and quick drafts · 99 languages
ASR · accuratewhisper-mediumlarge-v3-turbo — higher accuracy on noisy audio
Transcription parameters
language
optional ISO code hint, e.g. hi or en — auto-detected when omitted
response_format
json (default, returns {"text": ...}) or text for plain output
13 — Rate Limits

Fast, but not unlimited.

Limits are per key, enforced in real time. Generation endpoints cost more so heavy jobs can't starve chat traffic. Hit a limit and the response carries 429 with a Retry-After header.

Chat & vision200 req / minper key, per model group
Generation5× weightTTS and video requests count as 5 requests each
Burst bucket10 / s · burst 30token-bucket at the gateway edge
Global edge1800 req / 3 minper IP, all keys combined
Retry-After header
429 responses tell you exactly how long to wait — honor it and back off exponentially
429 body
{"error": "rate limit exceeded, slow down"}
14 — Error Codes

Every error, decoded.

Errors are JSON, always the same shape: an error object with message, type and code. Handle the status, log the code.

401invalid_api_keykey missing, wrong, or revoked — check the Authorization header
403insufficient_user_quotawallet empty — top up at modelrouter.in
413payload too largeTTS body over ~12 KB (≈10k chars) — split and concatenate
429rate limitslow down — see Retry-After
503model_not_foundno channel for that model in your group — check GET /v1/models
500internal / upstreamtransient upstream failure — retry once, then report
error body example — 503
{
  "error": {
    "message": "No available channel for model gpt-99 under group default",
    "type": "new_api_error",
    "code": "model_not_found"
  },
  "system_fingerprint": "astra-v1"
}
15 — SDKs & Tools

Agents & SDKs. Plug it in everywhere.

The gateway speaks OpenAI and Anthropic wire formats, so every coding agent and SDK works — point them at api.modelrouter.in and use your Model Router key.

Claude Code
Anthropic format — /v1/messages
terminal
export ANTHROPIC_BASE_URL=https://api.modelrouter.in
export ANTHROPIC_AUTH_TOKEN=sk-...

claude --model deepseek-v4-flash
Hermes Agent
custom provider via config
terminal
hermes config set model.provider custom
hermes config set model.base_url https://api.modelrouter.in/v1
hermes config set model.api_key ${ASTRA_API_KEY}

# MR_KEY=sk-...  →  ~/.hermes/.env
hermes model   # pick deepseek-v4-flash
OpenClaw
models.providers in config
~/.openclaw/openclaw.json
{
  models: {
    providers: {
      modelrouter: {
        baseUrl: "https://api.modelrouter.in/v1",
        apiKey: "sk-...",
        api: "openai-completions",
        models: [{
          id: "deepseek-v4-flash",
          name: "DeepSeek V4 Flash",
          input: ["text"],
          contextWindow: 128000
        }]
      }
    }
  }
}
// openclaw models list → modelrouter/deepseek-v4-flash
Python
pip install openai
from openai import OpenAI
client = OpenAI(
  base_url="https://api.modelrouter.in/v1",
  api_key=os.environ["MR_KEY"],
)
resp = client.chat.completions.create(
  model="deepseek-v4-flash",
  messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)
TypeScript
npm i openai
import OpenAI from "openai";
const client = new OpenAI({
  baseURL: "https://api.modelrouter.in/v1",
  apiKey: process.env.MR_KEY,
});
const res = await client.chat.completions.create({
  model: "deepseek-v4-flash",
  messages: [{ role: "user", content: "Hello" }],
});
JavaScript
no SDK — fetch
const res = await fetch("https://api.modelrouter.in/v1/chat/completions", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${process.env.MR_KEY}`,
  },
  body: JSON.stringify({
    model: "deepseek-v4-flash",
    messages: [{ role: "user", content: "Hello" }],
  }),
});
const data = await res.json();
16 — Wallet Metadata

Know your balance. Always.

Every response body carries an astra block with live wallet state — never guess when to recharge.

in every response body
"astra": {
  "gateway": "modelrouter.in",
  "balance_usd": "12.3571",
  "used_usd": "26.5082",
  "plan": "default/prepaid",
  "models_count": "42",
  "providers": "modelrouter.in",
  "requests": "544"
}
17 — Pricing

Pay-as-you-go. No subscriptions.

One wallet, per-use billing. Live balance in every response and at GET /v1/key/info.

Textfrom $0.06/M tokensGLM-5.3-Flash input · DeepSeek $0.165/M
Images$0.0112 – $0.03per image · dall-e-3, flux-image
Video$0.10 / second5s = $0.50 · 10s = $1.00 · HD

Ready to build?

Grab a key, point your SDK at the gateway, ship something.