Quick start
Create a key in your account, then use an OpenAI-compatible client for chat, images and speech. Copy the API base URL from Account → API keys; it includes /v1. Requests charge the balance of the account that owns the key. All keys on that account share its balance, with separate key spending caps.
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.RPROUTER_API_KEY,
baseURL: process.env.RPROUTER_BASE_URL // ends with /v1
});
const { data: models } = await client.models.list();
if (!models.length) throw new Error("No routes currently available");
const response = await client.chat.completions.create({
model: models.find(m => m.architecture.output_modalities.includes("text")).id,
messages: [{ role: "user", content: "Tell me a short story." }],
max_tokens: 500, stream: true
});
for await (const chunk of response) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}Authentication
Send Authorization: Bearer rp_…. API keys are shown once, stored as hashes, and can be revoked immediately. Keep keys on your server. The account website uses separate email authentication.
Each key has a lifetime spending cap, and accounts have a daily UTC cap. Pending reservations count against both. Provider keys cannot be connected in this release.
Keys carry permissions (scopes). When you create a key in Account → API keys, choose what it may do; it gets only inference unless you add more. A missing permission returns 403 insufficient_scope. The endpoint list shows the scope each call needs.
| Scope | Allows |
|---|---|
inference | Make chat, image, video, speech, transcription and voice-call requests billed to your RProuter credit |
balance | See your account balance and reserved credit |
profile | See your RProuter account ID and email address |
billing | See when you add credit and how much (not your balance or usage) |
usage | See requests made with this key |
purchases | Charge your RProuter credit for purchases you make in the app |
Chat
POST /v1/chat/completions is OpenAI-compatible, so any OpenAI SDK works with the RProuter base URL. Use a model ID from GET /v1/models whose architecture.output_modalities includes text. Without max_tokens (or max_completion_tokens, not both) a reply is capped at 1,024 tokens or the model’s maximum output, whichever is lower.
| Parameter | Meaning |
|---|---|
model | Model ID (required unless models is sent). :nitro after it sorts by throughput, :floor by price |
models | Up to 8 more model IDs, tried in order when the ones before them cannot answer |
messages | system, user, assistant and tool messages (required). Content is a string or a list of text and image_url parts; images need a model that takes image input |
session_id | Names the conversation, so its requests keep the provider that answered the last one (also the x-session-id header). Without it a conversation is recognized by its opening messages |
stream | Server-Sent Events, as OpenAI sends them |
stream_options.include_usage | Send token usage in a final chunk |
max_tokens, max_completion_tokens | Output cap; also bounds the credit reserved |
temperature, top_p, stop, seed, frequency_penalty, presence_penalty | Sampling, as in OpenAI’s API |
tools, tool_choice | Function calling, up to 50 tools |
response_format | JSON mode or a JSON schema |
reasoning | Reasoning controls: effort, max_tokens, enabled (false turns it off) and exclude (keep the reasoning text out of the reply) |
provider.sort | balanced (default), price, latency or throughput; or {by, partition} where partition: "none" ranks the providers of every model in models together |
provider.order | Provider names or slugs to try first, in order |
provider.only, provider.ignore | Providers to keep to, and providers to leave out |
provider.allow_fallbacks | false: try only the first choice, or only the providers in order (default true) |
provider.max_price | {prompt, completion}: the highest price per million tokens a provider may charge |
provider.preferred_max_latency | Seconds to the first token, as a number (median) or {p50, p75, p90, p99}. Slower providers are tried last |
provider.preferred_min_throughput | Tokens per second, as a number or percentiles. Slower providers are tried last |
provider.data_collection, zdr, quantizations | Restrictions on how a provider handles your data and which quantizations it runs; the request goes only to providers known to meet them |
Each model lists the parameters it accepts in supported_parameters. A request is routed only to a provider that supports every parameter you send, and fails with 400 no_compatible_route when none does, instead of silently dropping it. Unknown fields return 400. The reply follows OpenAI’s shape; usage carries the provider’s token counts, including cached and reasoning tokens, and x-request-id identifies the charge in your usage. See Streaming & failures for routing, retries and error codes.
POST /v1/chat/completions
Authorization: Bearer rp_…
{
"model": "MODEL_ID",
"messages": [
{ "role": "system", "content": "You are a gentle narrator." },
{ "role": "user", "content": "Begin a story in a lighthouse." }
],
"max_tokens": 500,
"temperature": 0.9,
"reasoning": { "effort": "low", "exclude": true },
"provider": { "sort": "throughput" },
"stream": true,
"stream_options": { "include_usage": true }
}Images, video and speech
Use the same key and wallet for every modality. Only models listed by GET /v1/models are available; each lists its providers with their prices and, for images and video, their response_type. Set RPROUTER_BASE_URL to your API base URL ending in /v1.
Images: one response, two shapes
POST /v1/images generates images. Each provider either returns the image at once or hands back a job, and the reply says which in response_type: "sync" fills sync with the image; "async" fills async with a job to poll, the same job POST /v1/videos returns. The other field is null. The same model can be served both ways when it has providers of each kind.
Set async: true to use only providers that answer with a job, or false for only those that answer at once. When the model has no provider of that kind the request fails with 400 no_async_provider or no_sync_provider. callback_url is notified when an asynchronous job finishes and is ignored for synchronous replies.
Supported only by these providers: TensorArt Non-standard parameters are accepted only by some providers. Sending one routes the request only to the providers that support it (hover the marker to see which), so a request with a TensorArt parameter goes to TensorArt and returns a job. Every other parameter you send must be supported too: a value no provider of the model offers returns 400 unsupported_parameter.
| Parameter | Type | Description |
|---|---|---|
modelrequired | string | Model ID from /v1/models. |
promptrequired | string | What to draw, up to 10,000 characters. |
n | integer | Images to generate, 1–10 (default 1). Many providers make one. |
resolution | string | Output tier: 512, 768, 1K, 1.5K, 2K, 4K. |
aspect_ratio | string | Output shape, such as 1:1, 2:3 or 16:9. |
size | string | Pixel size such as 1024x1024, or a tier such as 2K. |
quality | string | auto, low, medium, high, xhigh, max. |
output_format | string | png, jpeg, webp, svg or gif. |
background | string | auto, transparent (png or webp) or opaque. |
output_compression | integer | 0–100, for jpeg and webp. |
frame_count | integer | Frames of an animated gif, 2–64. |
frame_duration_ms | integer | Milliseconds per gif frame, 20–2000. |
input_references | array | Source or reference images: [{type: "image_url", image_url: {url}}]. url is https, a data URL or upload:<id>. |
markup | object | A transparent PNG overlay that guides an edit. |
seed | integer | Best-effort determinism. |
provider | object | Routing: only, ignore, order (provider names or slugs), sort (price by default, latency, throughput or balanced) and allow_fallbacks. When a provider is rate limited or fails before answering, the next one of the same response type is tried, and you are charged only for the one that delivered. options: provider-specific settings keyed by provider slug, such as {tensorart: {loras}}; only the serving provider's entry is used. |
asyncRProuter | boolean | true: only providers that answer with a job to poll; false: only providers that return the image at once. Omit to allow both. |
callback_urlRProuter | string | Public https URL notified when an asynchronous job finishes. Ignored for synchronous responses. |
max_costRProuter | number | Refuse the request if its maximum charge in USD is higher. |
negative_promptSupported only by these providers: TensorArt | string | What to keep out of the image. |
maskSupported only by these providers: TensorArt | object | Inpainting mask as an image part; white areas are repainted. Needs one input_references image. |
edit_modeSupported only by these providers: TensorArt | string | image-to-image (default), reference or inpaint. |
strengthSupported only by these providers: TensorArt | number | How much an edit changes the source, 0–1 (default 0.5). |
Provider-specific options
Settings whose values only one provider understands, such as its own model or LoRA IDs, go in provider.options, keyed by provider slug. Only the entry of the provider that serves the request is used; the others are ignored and never change routing, so pin the provider with provider.only when the options must apply. Options for a provider not documented below are passed to that provider unchanged.
provider.options.tensorart (TensorArt):
| Parameter | Type | Description |
|---|---|---|
checkpoint | string | A public TensorArt checkpoint built on the model's base (such as an Illustrious fine-tune), used instead of the base model. |
loras | array | Up to four [{id, strength}] TensorArt LoRA IDs, strength 0–1. |
detail_refinement | boolean | TensorArt's face and hand detail passes. Not with a mask. |
detail_prompts | object | {face, hand} prompts for the detail passes; each defaults to prompt. |
POST /v1/images
{
"model": "onoma-ai/illustrious-xl-v2",
"prompt": "A quiet library beneath the stars",
"aspect_ratio": "2:3",
"seed": 42,
"negative_prompt": "blurry, low detail",Supported only by these providers: TensorArt
"callback_url": "https://your-app.example/hooks/rprouter",
"provider": {
"only": [
"tensorart"
],
"options": {
"tensorart": {
"checkpoint": "943946051788787917",
"loras": [
{
"id": "910362684594084297",
"strength": 0.8
}
]
}
}
}
}A synchronous reply (200):
{
"response_type": "sync",
"sync": {
"created": 1794700000,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA…",
"media_type": "image/png"
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 1290,
"total_tokens": 1290,
"cost": 0.039
}
},
"async": null
}An asynchronous reply (202):
{
"response_type": "async",
"sync": null,
"async": {
"id": "6f1c2a9e-4b7d-4e21-9a8f-2c5d1e7b3a40",
"polling_url": "https://rprouter.ai/v1/jobs/6f1c2a9e-4b7d-4e21-9a8f-2c5d1e7b3a40",
"status": "pending",
"generation_id": "b0e4f7d2-91c3-4a6e-8d15-7f2a9c3e5b18"
}
}Generate an image
The reply's response_type says which kind of provider served it: sync carries the image in sync; async carries a job to poll in async. Send a stable Idempotency-Key when retrying.
curl "$RPROUTER_BASE_URL/images" \
-H "Authorization: Bearer $RPROUTER_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $REQUEST_ID" \
-d '{"model":"google/gemini-3.1-flash-image","prompt":"A quiet mountain lake","aspect_ratio":"16:9"}'Edit an image, or use non-standard parameters
input_references takes images as https URLs, base64 data URLs, or upload:<id> for a file sent to /uploads. negative_prompt, mask, edit_mode and strength are non-standard: sending one routes the request only to providers that accept them (TensorArt, which answers with a job). TensorArt's own settings, such as LoRA IDs, go in provider.options.tensorart. Masks use the white-to-repaint convention.
curl "$RPROUTER_BASE_URL/uploads" -H "Authorization: Bearer $RPROUTER_API_KEY" -F file=@source.png
curl "$RPROUTER_BASE_URL/uploads" -H "Authorization: Bearer $RPROUTER_API_KEY" -F file=@mask.png
curl "$RPROUTER_BASE_URL/images" \
-H "Authorization: Bearer $RPROUTER_API_KEY" -H "Content-Type: application/json" -H "Idempotency-Key: $REQUEST_ID" \
-d '{"model":"onoma-ai/illustrious-xl-v2","prompt":"Change the sky to sunset",
"input_references":[{"type":"image_url","image_url":{"url":"upload:'$SOURCE_ID'"}}],
"mask":{"type":"image_url","image_url":{"url":"upload:'$MASK_ID'"}},
"edit_mode":"inpaint","strength":0.5,"negative_prompt":"blurry",
"provider":{"options":{"tensorart":{"loras":[{"id":"910362684594084297","strength":0.8}]}}}}'Video
POST /v1/videos always answers with a job (202). Supported durations, resolutions and frame types differ by model; see its capabilities in /v1/models.
| Parameter | Type | Description |
|---|---|---|
modelrequired | string | Model ID from /v1/models. |
prompt | string | What happens in the video. Optional for models that animate frame_images alone. |
duration | integer | Seconds, from the model's supported durations; -1 lets the provider choose where supported. |
resolution | string | 360p, 480p, 720p, 768p, 1080p, 1K, 2K, 4K. |
aspect_ratio | string | 16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3, 21:9, 9:21. |
size | string | WIDTHxHEIGHT, instead of resolution and aspect_ratio. |
frame_images | array | Image-to-video frames: [{type: "image_url", image_url: {url}, frame_type: "first_frame" | "last_frame"}]. |
input_references | array | Reference images (and, for some models, audio_url or video_url parts). |
generate_audio | boolean | Generate a soundtrack where the model supports it. |
seed | integer | Best-effort determinism. |
provider | object | Routing: only, ignore, order, sort (price by default, latency, throughput or balanced) and allow_fallbacks. A provider that does not accept the job passes it to the next one. |
callback_url | string | Public https URL notified when the job finishes. |
max_costRProuter | number | Refuse the request if its maximum charge in USD is higher. |
POST /v1/videos
{
"model": "google/veo-3.1-fast",
"prompt": "Waves rolling onto a beach at golden hour",
"duration": 4,
"resolution": "720p",
"aspect_ratio": "16:9",
"frame_images": [
{
"type": "image_url",
"image_url": {
"url": "upload:<upload id>"
},
"frame_type": "first_frame"
}
],
"callback_url": "https://your-app.example/hooks/rprouter"
}202 Accepted
{
"id": "6f1c2a9e-4b7d-4e21-9a8f-2c5d1e7b3a40",
"polling_url": "https://rprouter.ai/v1/jobs/6f1c2a9e-4b7d-4e21-9a8f-2c5d1e7b3a40",
"status": "pending",
"generation_id": "b0e4f7d2-91c3-4a6e-8d15-7f2a9c3e5b18"
}Generate a video
The reply is always a job. Poll its polling_url (/jobs/:id) until status is completed, then download each output from unsigned_urls with your key. Or pass callback_url and wait for the callback.
curl "$RPROUTER_BASE_URL/videos" \
-H "Authorization: Bearer $RPROUTER_API_KEY" -H "Content-Type: application/json" -H "Idempotency-Key: $REQUEST_ID" \
-d '{"model":"google/veo-3.1-fast","prompt":"Waves at golden hour","duration":4,"resolution":"720p"}'
curl "$RPROUTER_BASE_URL/jobs/$JOB_ID" -H "Authorization: Bearer $RPROUTER_API_KEY"
curl "$RPROUTER_BASE_URL/jobs/$JOB_ID/content?index=0" -H "Authorization: Bearer $RPROUTER_API_KEY" --output video.mp4Jobs: polling and downloads
Asynchronous images and all video are jobs. Polling and downloads live under /v1/jobs: GET /v1/jobs/:id (the polling_url) returns the status — pending, in_progress, completed, failed, cancelled or expired — and, once completed, unsigned_urls (GET /v1/jobs/:id/content?index=N, with your key) and urls (signed links that work without a key, such as in an <img> or <video> tag, until expires_at). usage.cost is the charge in USD. DELETE /v1/jobs/:id cancels a job; one already sent to the provider may still finish and be charged. GET /v1/jobs lists your recent jobs.
GET /v1/jobs/:id
{
"id": "6f1c2a9e-4b7d-4e21-9a8f-2c5d1e7b3a40",
"kind": "video",
"model": "google/veo-3.1-fast",
"polling_url": "https://rprouter.ai/v1/jobs/6f1c2a9e-4b7d-4e21-9a8f-2c5d1e7b3a40",
"status": "completed",
"generation_id": "b0e4f7d2-91c3-4a6e-8d15-7f2a9c3e5b18",
"created_at": 1794700000,
"unsigned_urls": [
"https://rprouter.ai/v1/jobs/6f1c2a9e-4b7d-4e21-9a8f-2c5d1e7b3a40/content?index=0"
],
"urls": [
"https://rprouter.ai/v1/media/6f1c2a9e-4b7d-4e21-9a8f-2c5d1e7b3a40.0.1794786400.9f2c…"
],
"expires_at": 1794786400,
"usage": {
"cost": 0.48
}
}Callbacks
With callback_url (a public https URL), RProuter POSTs an event when the job completes, fails, is cancelled or expires: image.generation.completed, video.generation.failed and so on. Answer with any 2xx; other answers and timeouts (10 s) are retried after 1 minute, 5 minutes, 30 minutes, 2 hours and 6 hours. Create a signing secret in Account → Settings to have every callback signed.
{
"type": "video.generation.completed",
"created_at": "2026-11-14T10:00:12.345Z",
"data": {
"id": "6f1c2a9e-4b7d-4e21-9a8f-2c5d1e7b3a40",
"status": "completed",
"generation_id": "b0e4f7d2-91c3-4a6e-8d15-7f2a9c3e5b18",
"model": "google/veo-3.1-fast",
"unsigned_urls": [
"https://rprouter.ai/v1/jobs/6f1c2a9e-4b7d-4e21-9a8f-2c5d1e7b3a40/content?index=0"
],
"urls": [
"https://rprouter.ai/v1/media/6f1c2a9e-4b7d-4e21-9a8f-2c5d1e7b3a40.0.1794786400.9f2c…"
],
"expires_at": 1794786400,
"usage": {
"cost": 0.48
}
}
}Verify a callback
Callbacks are signed: X-RProuter-Signature is t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>,<raw body>"> with your account's signing secret (Account → Settings). Verify the raw bytes, reject old timestamps, and drop repeats by X-RProuter-Idempotency-Key.
# Your endpoint receives:
POST /hooks/rprouter
Content-Type: application/json
X-RProuter-Idempotency-Key: <job id>-completed
X-RProuter-Signature: t=1794700812,v1=5d41402abc4b2a76b9719d911017c592…
{"type":"video.generation.completed","created_at":"…","data":{"id":"…","status":"completed",…}}Image options and retention
Generated images and videos are not stored by RProuter. Synchronous images arrive in the reply as base64. Job outputs stream from the provider through /v1/jobs/:id/content and /v1/media/… links for 24 hours, or until the provider removes the file; save what you want to keep. Uploads (POST /v1/uploads, PNG, JPEG or WebP up to 20 MB) expire after one hour unless a job uses them; refer to one as upload:<id>. Image inputs given as URLs or data URLs to a job-based provider are stored as uploads for the job.
Every request reserves its maximum charge first and is charged what the provider reports, never more than the reservation. Synchronous and failed generations that produce nothing cost nothing. TensorArt jobs are quoted in TensorArt credits before submission; a TensorArt job that fails without an image is free. Fees apply only when purchasing credit.
Speech
Stream speech
OpenAI's request shape, so OpenAI SDKs work, with speech from Fish Audio or ElevenLabs: model is an RProuter speech model (fish/s2-pro, elevenlabs/eleven-v4, …), not tts-1, and voice is an RProuter voice UUID from /voices, fish:<reference_id> for a public Fish voice, or elevenlabs:<voice_id> for an ElevenLabs library or premade voice (OpenAI voices such as alloy do not exist). A voice works only with its own provider's models. Unknown fields such as instructions are rejected; formats are mp3, wav (Fish only), pcm and opus; stream defaults to true. Expressive tags are forwarded unchanged. Fish bills submitted UTF-8 bytes, ElevenLabs characters; ElevenLabs ignores speed. Add timestamps: true for JSON with base64 audio and character timing. Audio is not retained.
curl "$RPROUTER_BASE_URL/voices?scope=public&search=" -H "Authorization: Bearer $RPROUTER_API_KEY"
curl "$RPROUTER_BASE_URL/audio/speech" \
-H "Authorization: Bearer $RPROUTER_API_KEY" -H "Content-Type: application/json" \
-d "{\"model\":\"fish/s2-pro\",\"voice\":\"$VOICE_ID\",\"input\":\"Hello there.\",\"response_format\":\"mp3\"}" \
--output speech.mp3Create and delete a private voice
RProuter extension. Clones are made on Fish Audio and speak with the Fish models; until the operator enables cloning the request is 503 cloning_unavailable. Use your own voice or obtain the speaker’s permission. Upload WAV, MP3 or FLAC; wait until ready before synthesizing. Deletion is asynchronous and retried upstream. The sample is deleted once the voice is ready.
curl "$RPROUTER_BASE_URL/uploads" -H "Authorization: Bearer $RPROUTER_API_KEY" -F file=@sample.wav
# Use the returned upload id:
curl "$RPROUTER_BASE_URL/voices" -H "Authorization: Bearer $RPROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"name\":\"My voice\",\"uploadId\":\"$UPLOAD_ID\",\"consent\":true,\"consentVersion\":\"2026-09-09\",\"rights\":\"my_voice\"}"
curl "$RPROUTER_BASE_URL/voices/$VOICE_ID" -H "Authorization: Bearer $RPROUTER_API_KEY"
curl -X DELETE "$RPROUTER_BASE_URL/voices/$VOICE_ID" -H "Authorization: Bearer $RPROUTER_API_KEY"Speech uses the pinned price per million UTF-8 bytes (Fish) or characters (ElevenLabs). Provider refusals before any audio cost nothing; cancelled or incomplete speech is settled at its quote when reconciled.
Transcription
POST /v1/audio/transcriptions turns a recording into text with a transcription model such as elevenlabs/scribe-v2. Send multipart form data with file, a 16-bit PCM WAV (8–48 kHz, mono or stereo, up to five minutes and 30 MB), model and, optionally, language (ISO 639-1 or 639-3; detected when omitted). It is charged per second of audio, rounded up to a tenth of a second and held at that amount before the audio is sent. Other formats return 400 unsupported_audio; longer recordings 413 audio_too_long.
curl "$RPROUTER_BASE_URL/audio/transcriptions" \
-H "Authorization: Bearer $RPROUTER_API_KEY" \
-F model=elevenlabs/scribe-v2 \
-F language=en \
-F file=@call.wav
{
"text": "Hello, thanks for calling.",
"language": "en",
"usage": { "seconds": 2.4, "cost_usd": 0.00026 }
}Realtime voice sessions
A realtime session is a live voice call. RProuter listens to the caller’s microphone, transcribes each turn with end-of-turn detection, speaks the reply text your client streams in and handles interruptions. Your code decides what to answer, with any chat model. Speech-to-text uses elevenlabs/scribe-v2-realtime; speech uses elevenlabs/eleven-v4-turbo, fish/s2-pro or fish/s1, with the same voice IDs as /v1/audio/speech.
- Your server creates the session with
POST /v1/realtime/sessionsand its API key. The reply (201) carries a WebSocketurland a single-useclient_secretvalid for 60 seconds. - Hand both to the browser, never the API key. It connects with the secret as a subprotocol (browsers can’t set WebSocket headers) and waits for
session.ready. - The browser sends microphone audio as binary frames (16 kHz mono PCM16, about 100 ms each) and receives the reply audio as binary frames (24 kHz mono PCM16).
- On
transcript.final, answer withresponse.text.appendmessages as your reply is generated, using itsturn_idasresponse_id, thenresponse.text.done.
POST /v1/realtime/sessions
{
"stt": {
"model": "elevenlabs/scribe-v2-realtime",
"language": "en",
"end_of_turn_ms": 700
},
"tts": {
"model": "elevenlabs/eleven-v4-turbo",
"voice": "elevenlabs:<voice_id>"
},
"limits": {
"max_minutes": 60,
"idle_minutes": 5,
"spend_limit_usd": 0.5
},
"metadata": {
"chat": "c_123"
}
}// In the browser, with url and client_secret from your server
const ws = new WebSocket(session.url, [
"rprouter.realtime.v1",
`secret.${session.client_secret.value}`,
]);
ws.binaryType = "arraybuffer";
ws.onmessage = async (e) => {
if (e.data instanceof ArrayBuffer) return play(e.data); // reply audio
const event = JSON.parse(e.data);
if (event.type === "transcript.final") {
for await (const text of yourChatReply(event.text))
ws.send(JSON.stringify({ type: "response.text.append", response_id: event.turn_id, text }));
ws.send(JSON.stringify({ type: "response.text.done", response_id: event.turn_id }));
}
if (event.type === "response.interrupted") stopPlayback();
};Other client messages: response.cancel, playback.mark (how much of a reply the caller heard, about every 500 ms while playing, so an interrupted reply is stored as spoken_text), input.mute, input.commit (push-to-talk) and session.end. The server also sends transcript.partial, input.speech_started, response.audio.start, response.alignment (character timing, ElevenLabs only), response.done, response.failed, usage every 10 seconds, error and session.ended with its reason.
GET /v1/realtime/sessions/:id returns the session’s status, usage and end_reason; PATCH with spend_limit_usd changes its limit; POST …/end ends it. Audio is billed in rolling holds: speech-to-text per second sent, speech per character or byte like /v1/audio/speech. Each hold passes your balance and limits and the session’s spend_limit_usd; when one is refused the session ends once the current hold runs out.
Developer apps
Let your users bring their own RProuter account. Your site sends the user to RProuter; they sign in, choose a spending limit and approve; RProuter sends them back with a one-time code; your server exchanges the code for a key. From then on, requests you make with that key are billed to the user’s credit and listed in their usage under your app’s name. This is the standard OAuth 2.0 authorization-code flow, with PKCE for apps that can’t keep a secret.
- Register the app in Account → Apps with its exact redirect URIs. Keep the client secret on your server. Registering apps requires Premium; if it stays unpaid for 90 days, keys issued through your apps stop working (403
app_suspended) until it is paid again. - Send the user to
/oauth/authorizewithclient_id,redirect_uri,scope, a randomstateand, optionally,limit_usdto suggest a spending limit. - RProuter redirects to your
redirect_uriwithcodeand yourstate, or witherror=access_denied. Checkstatefirst. - Within 10 minutes, POST the code to
/oauth/token. The response’saccess_tokenis an RProuter API key (rp_…); store it encrypted, per user. - Call
/v1with it. The user can disconnect at any time, after which the key returns 401.
// 1. Redirect the user (server-side route)
const state = crypto.randomUUID(); // store in the user's session
const url = new URL("https://rprouter.example/oauth/authorize");
url.search = new URLSearchParams({
client_id: process.env.RPROUTER_CLIENT_ID,
redirect_uri: "https://your-app.example/rprouter/callback",
scope: "inference",
state,
// limit_usd: "20", // optional: suggest a monthly spending limit
}).toString();
return Response.redirect(url, 302);
// 2. Callback: verify state, then exchange the code
const res = await fetch("https://rprouter.example/oauth/token", {
method: "POST",
headers: { "content-type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
grant_type: "authorization_code",
code: callbackUrl.searchParams.get("code"),
redirect_uri: "https://your-app.example/rprouter/callback",
client_id: process.env.RPROUTER_CLIENT_ID,
client_secret: process.env.RPROUTER_CLIENT_SECRET,
}),
});
const { access_token, user_id, scope, spending_limit_usd } = await res.json();
// 3. Make requests on the user's behalf, billed to their credit
const reply = await fetch("https://rprouter.example/v1/chat/completions", {
method: "POST",
headers: {
Authorization: `Bearer ${access_token}`,
"content-type": "application/json",
},
body: JSON.stringify({
model: "MODEL_ID", // any ID from GET /v1/models
messages: [{ role: "user", content: "Tell me a short story." }],
max_tokens: 500,
}),
}).then((r) => r.json());
showReply(reply.choices[0].message.content);Public clients (single-page and mobile apps) omit the secret and use PKCE: send code_challenge=BASE64URL(SHA256(verifier)) and code_challenge_method=S256 to /oauth/authorize, then code_verifier to /oauth/token. The token endpoint accepts cross-origin requests.
GET /v1/me returns the stable RProuter user ID for the key (use it to link accounts on your side), the app, the granted scopes and the key’s monthly spending limit (null when the user set none; it resets each calendar month and the user can change it without reconnecting); the email address is included only with the profile scope. Connecting again replaces the user’s previous key for your app. Revoke a key yourself with POST /oauth/revoke and token=rp_…. Codes are single use; redirect URIs must match a registered URI exactly.
Monthly commitments
Ask a connected user to commit a monthly amount to your app. Every month, that much of the user’s monthly credit is set aside for your key instead of their balance: only requests you make with that key spend it, and it is spent before the rest of their balance. Use it for your own rules, such as unlocking a plan while a commitment of a certain size is active; RProuter only reports the facts.
- Send the user to
/oauth/commitwithclient_id,amount_usd(whole dollars, 1 to 500),return_to(a page on the same site as one of your redirect URIs) and, optionally, astateyou get back unchanged. - They sign in if needed and approve or decline. The amount for the current month is taken from their balance when they approve; if anything is missing, RProuter takes them through it and then carries on.
- RProuter sends them back to
return_towithrprouter_commitment=approvedordeclined, and yourstate. Treat the parameter as a hint and read the commitment with the user’s key.
// 1. Send the user to approve $5 a month
const url = new URL("https://rprouter.example/oauth/commit");
url.search = new URLSearchParams({
client_id: process.env.RPROUTER_CLIENT_ID,
amount_usd: "5",
return_to: "https://your-app.example/plan",
state,
}).toString();
return Response.redirect(url, 302);
// 2. When they return (and whenever you need to know)
GET /v1/app/commitment
Authorization: Bearer rp_… // the user's key for your app
{
"object": "commitment",
"id": "5f0c…",
"key_id": "…",
"user_id": "…",
"status": "active", // "none" | "active" | "past_due" | "cancelled"
"amount_usd": 5,
"available_usd": 3.42, // committed credit your key hasn't spent yet
"current_period_end": "2026-12-22T10:00:00.000Z",
"cancel_reason": null, // "user" | "key_revoked" | "subscription_ended"
"cancelled_at": null,
"created_at": "2026-11-22T10:00:00.000Z",
"updated_at": "2026-11-22T10:00:00.000Z"
}active means the current month is paid; past_due that the user’s monthly payment failed and this month’s amount has not arrived; cancelled that it ended. Users can lower or end a commitment at any time in their account, and unspent committed credit then returns to their balance. Asking again with another amount replaces the commitment: a higher amount takes the difference for the current month from the balance. Any key of your app can read its commitment, whatever its scopes; GET /v1/balance on that key includes the committed credit in available and reports it as committed. Connecting again moves the commitment to the new key; disconnecting ends it.
To hear about changes, set a commitment webhook on the app in Account → Apps. RProuter POSTs commitment.updated with the commitment as above (without available_usd) whenever its status or amount changes, retrying for about nine hours until your endpoint answers 2xx. With a signing secret (Account → Settings) each delivery carries X-RProuter-Signature: t=…,v1=…, the hex HMAC-SHA256 of <t>,<raw body>; X-RProuter-Idempotency-Key is the event’s ID.
POST https://your-app.example/rprouter/commitments
X-RProuter-Idempotency-Key: evt_…
{
"id": "evt_…",
"type": "commitment.updated",
"created_at": "2026-11-22T10:00:00.000Z",
"data": { "object": "commitment", "id": "5f0c…", "status": "cancelled", "amount_usd": 5, … }
}Top-ups from your app
To let users add credit without leaving your flow, link them to /topup?client_id=…&return_to=…. Add &amount=25 (whole dollars, 5 to 1,000) to preselect the amount. They sign in if needed, pay by card or crypto (minimum $5), and once the credit has landed RProuter sends them back to return_to, which must be on the same site as one of your redirect URIs.
With the billing scope, GET /v1/me/funding?days=30 reports the credit the user added in that window (net of refunds) and their latest top-up. Use it for your own rules, such as unlocking features after a recent top-up; RProuter only reports the facts. Check it when the user returns from /topup and when they sign in to your app. Automatic top-ups count too, and history lists each one, for rules like “30 days of a feature per $10”.
Users can turn on auto top-up: when their balance drops below their threshold, or can’t cover a request, RProuter charges their saved card, up to their monthly limit of credit. auto_topup in this response and in /v1/balance shows its state. When the card is declined or the bank wants confirmation, requests fail with 402 auto_topup_failed; send the user to /topup or their RProuter billing page to fix it.
GET /v1/me/funding?days=30
Authorization: Bearer rp_…
{
"object": "funding",
"currency": "USD",
"window_days": 30,
"topped_up_usd": 25,
"topups": 1,
"last_topup_at": "2026-09-28T10:00:00.000Z",
"last_topup_usd": 25,
"history": [{ "at": "2026-09-28T10:00:00.000Z", "usd": 25 }],
"auto_topup": {
"enabled": true,
"status": "on", // "on" | "paused" | "off"
"paused_reason": null, // "declined" | "action_required" | "disputed"
"amount_usd": 25,
"threshold_usd": 5, // tops up below this balance; 0: only when a request doesn't fit
"monthly_limit_usd": 100 // credit per calendar month; null: no limit
}
}API endpoints
| Method | Path | Result | Scope |
|---|---|---|---|
| GET | /v1/models | Available model IDs and capabilities | none |
| POST | /v1/chat/completions | Text completion or SSE stream | inference |
| POST | /v1/images | Generate or edit an image: the result (sync) or a job (async) | inference |
| POST | /v1/images/estimate | Maximum charge and provider, without generating | inference |
| POST | /v1/videos | Generate a video (a job) | inference |
| GET | /v1/jobs | Recent image and video jobs | inference |
| GETDELETE | /v1/jobs/:id | Poll a job / request cancellation | inference |
| GET | /v1/jobs/:id/content | Download a job output (with your key) | inference |
| POST | /v1/uploads | Account-owned image, mask or voice sample | inference |
| GET | /v1/media/:token | Signed link streaming a job output from the provider | none |
| POST | /v1/audio/speech | Audio bytes, streaming by default, or JSON with timing | inference |
| POST | /v1/audio/transcriptions | Transcript of a WAV recording, up to five minutes | inference |
| POST | /v1/realtime/sessions | Start a realtime voice session; returns its WebSocket URL and client secret | inference |
| GETPATCH | /v1/realtime/sessions/:id | Session status and usage / change its spend limit | inference |
| POST | /v1/realtime/sessions/:id/end | End a session | inference |
| GET | /v1/realtime/sessions/:id/connect | The browser’s WebSocket for the call | client secret |
| GETPOST | /v1/voices | List public/private voices or create a private clone | inference |
| GETDELETE | /v1/voices/:id | Inspect / delete an owned voice | inference |
| POST | /v1/voices/search | Discover public Fish voices | inference |
| GETPOSTDELETE | /v1/app/voices | An app’s private provider voices | app client ID and secret |
| POST | /v1/app/charges | Charge the user’s balance for a purchase (RProuter’s own apps only) | purchases |
| GET | /v1/app/commitment | The user’s monthly commitment to the app | any app key |
| GET | /v1/balance | The account balance, and what this key can spend | balance |
| GET | /v1/me | The key’s user ID, app, scopes and limit | any key |
| GET | /v1/me/funding | Credit the user added, net of refunds | billing |
| GET | /v1/usage | Requests made with this key | usage |
| GET | /oauth/authorize | Start connecting a user’s account | none |
| POST | /oauth/token | Exchange a code for the user’s key | app client ID, with secret or PKCE |
| POST | /oauth/revoke | Revoke an app key | the key itself |
| GET | /oauth/commit | Ask a user for a monthly commitment and back | none |
| GET | /topup | Send a user to add credit and back | none |
Scope any key means any active key works, whatever its scopes. Signed links (/v1/media/…) and the realtime WebSocket, opened with the session’s one-time client secret, need no key. Full request and response schemas are in the API reference (OpenAPI JSON).
Streaming and routing
Text uses Server-Sent Events. x-request-id identifies the billable request. Disconnecting cancels upstream work where supported, but it does not guarantee zero supplier usage.
A model is often served by several providers at different prices and speeds (providers in GET /v1/models). Routing is set with the request’s provider object. By default it is balanced: providers that are cheap, fast and answering reliably get most requests, and load is spread so no one provider is pushed into rate limiting. Set provider.sort to price (lowest cost for the request), latency (shortest time to the first token) or throughput (most tokens per second) to rank strictly by one of them. provider.order names providers to try first, provider.only and provider.ignore filter them, and provider.max_price excludes providers above a price per million tokens (400 no_compatible_route when none is left). provider.preferred_max_latency (seconds) and provider.preferred_min_throughput (tokens per second) move providers that miss them to the end instead of excluding them. A provider that has not been measured counts as a typical one, never as the fastest.
When a provider is rate limited, at capacity, down or fails before any output, the request moves to the next one, and you are charged only for the provider that answered, at its price. A provider that just rate limited is tried last until it has had time to recover. provider.allow_fallbacks: false keeps the request to the first choice. To fall back to other models, send models: they are tried in the order given, or ranked together with provider.sort: {"by": "price", "partition": "none"}. The reply’s model and provider say which answered, and the reservation covers the most expensive provider the request may reach.
A conversation stays with the provider that answered it, so the provider’s prompt cache keeps working (cached input is cheaper and starts sooner) and a character’s voice does not change between turns. A conversation is recognized by its first system message and its first other message, for five minutes after each reply; send session_id to name it yourself, which holds it for an hour and also under an explicit provider.sort. With provider.order your order is followed instead, and a provider that is rate limited or failing is never held to.
A provider that does not start answering in time is replaced by the next one: for a stream the wait is for the first token, a few times what that provider usually needs (at least 15 seconds, at most two minutes, longer when reasoning is hidden or set high); for a buffered reply it is for the whole answer. The last provider left is never cut short. If every provider is too slow the answer is 504 provider_timeout.
Images and video are routed the same way with their own provider object (sort, order, only, ignore, allow_fallbacks): the cheapest provider first unless you sort otherwise, a rate-limited or failing provider tried last, and a provider that refuses or is too slow replaced by the next one that answers the same way (at once, or with a job). Speech voices belong to one provider, so there is nothing to choose; a brief rate limit there is waited out and tried once more.
Send an Idempotency-Key to avoid duplicate dispatch. A repeated text request returns 409 and the original request ID; it does not replay stored conversation content. Unsupported settings return 400, inactive keys 401, insufficient credit 402, ownership failures 404, capacity exhaustion 429 with Retry-After, and unavailable routes 503.
Requests run immediately when the provider has capacity. Otherwise they wait in arrival order, up to five seconds, then get 429 supplier_capacity. Running streams are never interrupted, and each account may hold only its share of a provider’s capacity (429 customer_capacity).
On the last provider left, a confirmed unbilled transient refusal is retried once before output. When every provider rate limits, the answer is 429 with the shortest Retry-After they gave. Models are substituted only from the models you send, and private voices never. Missing provider usage remains reserved for reconciliation.
Billing and limits
Before dispatch, RProuter reserves a conservative upper bound. Text estimates use a UTF-8 byte bound plus message framing and the requested output cap. Large requests may reserve more than their final charge. Final settlement uses provider-reported tokens, including cached and billed reasoning tokens.
Missing usage stays pending; unused reservations are released. Cancellations and partial results are reconciled against actual supplier usage.
Purchased credit never expires. A top-up is any whole-dollar amount from $5, paid by card or crypto, and costs its credit plus a service fee (5.8% + $0.32 of the credit by card; the Add credits dialog shows the fee and the total before you pay). Requests are charged at the usage prices /v1/models lists for each provider; a routing fee of up to 1% of a request’s cost may be added, and usage.cost in every answer is the exact charge. Premium is $10 a month and adds $9 of credit every paid month. With auto top-up on, the saved card is charged when the balance drops below the balance you chose, up to the monthly limit, and a request the balance can’t cover runs on that top-up. The account’s daily limit ($500 by default, or none) and each key’s optional monthly limit cap spending. Refunds revoke corresponding credit; refunded credit already used becomes a balance adjustment that must be cleared before further spending. Taxes do not create usage credit.
Premium priority
Standard requests run immediately when capacity is free. When both queues are waiting, up to three Premium admissions precede the next Standard admission. Running streams are never interrupted. A request waits up to five seconds on Standard or ten seconds on Premium, then receives a 429 response if capacity is still unavailable. Per-customer concurrency limits apply to both plans.
Premium priority requires a paid, unexpired membership. Canceling renewal preserves priority through the paid period. A full membership refund removes the refunded period’s priority. Status updates alone cannot grant a new unpaid period.
Priority only affects RProuter’s admission queue. It cannot change a supplier’s internal scheduling, rate limits, or token-generation speed.
Performance
First-answer latency starts with the incoming request and ends at the first visible answer content. Reasoning-only chunks do not end this timer. Generation speed uses output tokens and the measured generation interval; completion time covers the full request.
Summaries group provider route, region, workload, and settings. Medians require 30 comparable samples; p95 requires 100. Summaries refresh every five minutes and display sample count, window, method, and freshness. Supplier claims must be labeled separately.
External benchmark figures are separate from RProuter route observations. Customer conversations are not benchmark material without consent.
Benchmark sources
The September 15, 2026 snapshot matches 22 catalog models to EQ-Bench Creative Writing v3 and 11 to EQ-Bench 4. Writing measures story generation; EQ measures social and emotional intelligence in multi-turn persona conversations. Neither is a complete roleplay evaluation. The EQ4 export was generated July 26, 2026; a retrieval date is not a new test date.
Six exact model versions have speed and first-token figures from linked Artificial Analysis model summaries. These are dated external observations at the stated provider and reasoning setting, not live RProuter performance. Prompt lengths and sample windows were not specified in the cited summaries. Different setups limit direct latency comparisons.
We map exact versions and preserve provisional labels. Confidence intervals and sample counts appear when published. Missing values stay unavailable; they do not become zero.
Source records include URLs, tested model IDs, settings, and retrieval dates. These snapshots are refreshed separately from the five-minute summaries of RProuter traffic. No external benchmark is presented as our own test.