OpenAI-compatible
OpenAI-compatible chat completions and model listing.
Point an OpenAI SDK at the platform base URL and use `model: "auto"`; the router chooses the model per request.
post /v1 /audio /speech
Speech
OpenAI-compatible text to speech: model: auto picks among the targets tagged speech (or
metadata.speech); a target id pins one. Returns the audio bytes (response_format mp3 by
default; opus, aac, flac, wav, pcm) with the decision in X-OSR-Target / X-Request-Id.
Requires an API key
Parameters
| Name | In | Type | Default | Description |
|---|---|---|---|---|
| x-osr-tenant | header | string | null | ||
| x-goog-api-key | header | string | null |
Request bodySpeechIn
| Field | Type | Default | Description |
|---|---|---|---|
| input(required) | string | ||
| instructions | string | null | ||
| model | string | "auto" | |
| osr | RoutingOptions | Platform extension carried in the chat body under osr (ignored by other providers). | |
| cache | boolean | null | ||
| constraints | object | ||
| conversation | boolean | false | |
| conversation_id | string | null | ||
| fallbacks | boolean | true | |
| memory | boolean | null | ||
| objective | object<number> | ||
| plan | boolean | null | ||
| plan_mode | string | null | ||
| prompt | PromptRef | null | ||
| provider | object | null | ||
| tenant | string | null | ||
| response_format | string | null | ||
| speed | number | null | ||
| user | string | null | ||
| voice | string | null |
Responses
| 200 | Successful Response |
| 422 | Validation ErrorHTTPValidationError |
| 401 | Missing, invalid or revoked API key |
curl -s -X POST "$OSR_URL/v1/audio/speech" \
-H "Authorization: Bearer $OSR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "input": "string" }'{
"input": "string"
}post /v1 /audio /transcriptions
Transcriptions
OpenAI-compatible speech to text (multipart file + model): model: auto picks among the
targets tagged transcription (or metadata.transcription); a target id pins one. The audio
never enters the routed text - only the file name and prompt do. response_format json
(default), verbose_json (language, duration, segments), text, srt or vtt.
Requires an API key
Parameters
| Name | In | Type | Default | Description |
|---|---|---|---|---|
| x-osr-tenant | header | string | null | ||
| x-goog-api-key | header | string | null |
Responses
| 200 | Successful Response |
| 422 | Validation ErrorHTTPValidationError |
| 401 | Missing, invalid or revoked API key |
curl -s -X POST "$OSR_URL/v1/audio/transcriptions" \
-H "Authorization: Bearer $OSR_API_KEY"post /v1 /chat /completions
Chat
Requires an API key
Parameters
| Name | In | Type | Default | Description |
|---|---|---|---|---|
| x-osr-tenant | header | string | null | ||
| x-osr-cache | header | string | null | ||
| x-osr-cache-ttl | header | string | null | ||
| x-goog-api-key | header | string | null |
Request bodyChatCompletionIn
| Field | Type | Default | Description |
|---|---|---|---|
| logprobs | boolean | null | ||
| max_tokens | integer | null | ||
| messages(required) | ChatMessage[] | ||
| metadata | object | ||
| model | string | "auto" | |
| models | string[] | ||
| n | integer | null | ||
| osr | RoutingOptions | Platform extension carried in the chat body under osr (ignored by other providers). | |
| cache | boolean | null | ||
| constraints | object | ||
| conversation | boolean | false | |
| conversation_id | string | null | ||
| fallbacks | boolean | true | |
| memory | boolean | null | ||
| objective | object<number> | ||
| plan | boolean | null | ||
| plan_mode | string | null | ||
| prompt | PromptRef | null | ||
| provider | object | null | ||
| tenant | string | null | ||
| parallel_tool_calls | boolean | null | ||
| provider | object | null | ||
| response_format | object | null | ||
| seed | integer | null | ||
| stop | string | string[] | null | ||
| stream | boolean | false | |
| stream_options | object | null | ||
| temperature | number | null | ||
| tool_choice | any | ||
| tools | object[] | null | ||
| top_logprobs | integer | null | ||
| user | string | null |
Responses
| 200 | Successful Response |
| 422 | Validation ErrorHTTPValidationError |
| 401 | Missing, invalid or revoked API key |
curl -s -X POST "$OSR_URL/v1/chat/completions" \
-H "Authorization: Bearer $OSR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "messages": [ { "role": "user", "content": "Write a haiku about routing." } ], "model": "auto" }'{
"messages": [
{
"role": "user",
"content": "Write a haiku about routing."
}
],
"model": "auto"
}post /v1 /embeddings
Embeddings
OpenAI-compatible embeddings: model: auto picks among the targets tagged embeddings
(or metadata.embeddings); a target id pins one. Metered like a chat completion.
Requires an API key
Parameters
| Name | In | Type | Default | Description |
|---|---|---|---|---|
| x-osr-tenant | header | string | null | ||
| x-goog-api-key | header | string | null |
Request bodyEmbeddingsIn
| Field | Type | Default | Description |
|---|---|---|---|
| dimensions | integer | null | ||
| encoding_format | string | null | ||
| input(required) | string | string[] | ||
| model | string | "auto" | |
| osr | RoutingOptions | Platform extension carried in the chat body under osr (ignored by other providers). | |
| cache | boolean | null | ||
| constraints | object | ||
| conversation | boolean | false | |
| conversation_id | string | null | ||
| fallbacks | boolean | true | |
| memory | boolean | null | ||
| objective | object<number> | ||
| plan | boolean | null | ||
| plan_mode | string | null | ||
| prompt | PromptRef | null | ||
| provider | object | null | ||
| tenant | string | null | ||
| user | string | null |
Responses
| 200 | Successful Response |
| 422 | Validation ErrorHTTPValidationError |
| 401 | Missing, invalid or revoked API key |
curl -s -X POST "$OSR_URL/v1/embeddings" \
-H "Authorization: Bearer $OSR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "input": "string" }'{
"input": "string"
}post /v1 /feedback
Alias of /api/v1/feedback
Requires an API key
Parameters
| Name | In | Type | Default | Description |
|---|---|---|---|---|
| x-goog-api-key | header | string | null |
Request bodyFeedbackIn
| Field | Type | Default | Description |
|---|---|---|---|
| complexity | number | null | ||
| cost_usd | number | null | ||
| domains | string[] | ||
| latency_ms | number | null | ||
| preferred_over | string | null | ||
| quality | number | null | ||
| request_id(required) | string | ||
| role | string | null | ||
| success(required) | boolean | ||
| target_id(required) | string |
Responses
| 200 | Successful Response |
| 422 | Validation ErrorHTTPValidationError |
| 401 | Missing, invalid or revoked API key |
curl -s -X POST "$OSR_URL/v1/feedback" \
-H "Authorization: Bearer $OSR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "request_id": "7f3c0e2a9b1d4f6e8a0c2b4d6e8f0a1b", "success": true, "quality": 0.9 }'{
"request_id": "7f3c0e2a9b1d4f6e8a0c2b4d6e8f0a1b",
"success": true,
"quality": 0.9
}post /v1 /images /generations
Images
OpenAI-compatible image generation: model: auto picks among the executable image tools
(actions: [image]); a target id pins one. data[] carries url or b64_json as the
provider returned it (response_format is honoured when the provider gives that shape).
Requires an API key
Parameters
| Name | In | Type | Default | Description |
|---|---|---|---|---|
| x-osr-tenant | header | string | null | ||
| x-goog-api-key | header | string | null |
Request bodyImagesIn
| Field | Type | Default | Description |
|---|---|---|---|
| model | string | "auto" | |
| n | integer | null | ||
| osr | RoutingOptions | Platform extension carried in the chat body under osr (ignored by other providers). | |
| cache | boolean | null | ||
| constraints | object | ||
| conversation | boolean | false | |
| conversation_id | string | null | ||
| fallbacks | boolean | true | |
| memory | boolean | null | ||
| objective | object<number> | ||
| plan | boolean | null | ||
| plan_mode | string | null | ||
| prompt | PromptRef | null | ||
| provider | object | null | ||
| tenant | string | null | ||
| prompt(required) | string | ||
| quality | string | null | ||
| response_format | string | null | ||
| size | string | null | ||
| style | string | null | ||
| user | string | null |
Responses
| 200 | Successful Response |
| 422 | Validation ErrorHTTPValidationError |
| 401 | Missing, invalid or revoked API key |
curl -s -X POST "$OSR_URL/v1/images/generations" \
-H "Authorization: Bearer $OSR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "prompt": "Prove that sqrt(2) is irrational." }'{
"prompt": "Prove that sqrt(2) is irrational."
}post /v1 /messages
Messages
Anthropic **Messages API** over the chat path (opensmartroute.anthropic): system, content
blocks (text / image / tool_use / tool_result), tools with input_schema,
tool_choice, stop_sequences, streaming events; metered as a chat completion. Errors use the
{"type": "error", "error": {...}} envelope Anthropic clients expect.
Requires an API key
Parameters
| Name | In | Type | Default | Description |
|---|---|---|---|---|
| x-osr-tenant | header | string | null | ||
| x-goog-api-key | header | string | null |
Responses
| 200 | Successful Response |
| 422 | Validation ErrorHTTPValidationError |
| 401 | Missing, invalid or revoked API key |
curl -s -X POST "$OSR_URL/v1/messages" \
-H "Authorization: Bearer $OSR_API_KEY"post /v1 /messages /count_tokens
Messages Count Tokens
{"input_tokens": n} for a Messages request from the router's token estimate; no provider call,
nothing metered.
Requires an API key
Parameters
| Name | In | Type | Default | Description |
|---|---|---|---|---|
| x-goog-api-key | header | string | null |
Responses
| 200 | Successful Response |
| 422 | Validation ErrorHTTPValidationError |
| 401 | Missing, invalid or revoked API key |
curl -s -X POST "$OSR_URL/v1/messages/count_tokens" \
-H "Authorization: Bearer $OSR_API_KEY"get /v1 /models
Models
What this workspace may name as model: auto and the osr/auto:* presets, every executable
hand-written target, the workspace's installed listings, and every catalogue model on offer in
OpenRouter's shape (pricing in USD per token as strings - the price **this workspace** pays -
context_length, architecture, top_provider and an osr.endpoints list naming the providers;
pin one with vendor/model@provider).
Requires an API key
Parameters
| Name | In | Type | Default | Description |
|---|---|---|---|---|
| x-goog-api-key | header | string | null |
Responses
| 200 | Successful Response |
| 422 | Validation ErrorHTTPValidationError |
| 401 | Missing, invalid or revoked API key |
curl -s "$OSR_URL/v1/models" \
-H "Authorization: Bearer $OSR_API_KEY"post /v1 /moderations
Moderations
OpenAI-shaped moderation over the router's own guards (opensmartroute.security.moderate): prompt
injection, router steering, confounder gadgets, PII, oversize and control characters. No provider call,
nothing metered; the route scope suffices.
Requires an API key
Parameters
| Name | In | Type | Default | Description |
|---|---|---|---|---|
| x-goog-api-key | header | string | null |
Request bodyModerationsIn
| Field | Type | Default | Description |
|---|---|---|---|
| flag_pii | boolean | false | |
| input(required) | string | any[] | ||
| model | string | null |
Responses
| 200 | Successful Response |
| 422 | Validation ErrorHTTPValidationError |
| 401 | Missing, invalid or revoked API key |
curl -s -X POST "$OSR_URL/v1/moderations" \
-H "Authorization: Bearer $OSR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "input": "string" }'{
"input": "string"
}post /v1 /rerank
Rerank
Cohere / Jina-compatible rerank: query and documents are embedded by one embeddings-capable
target (model: auto chooses it, a target id pins it) and the documents come back ordered by
relevance_score with their original index; top_n trims, return_documents echoes the text.
One metered embeddings call.
Requires an API key
Parameters
| Name | In | Type | Default | Description |
|---|---|---|---|---|
| x-osr-tenant | header | string | null | ||
| x-goog-api-key | header | string | null |
Request bodyRerankIn
| Field | Type | Default | Description |
|---|---|---|---|
| documents(required) | string | object[] | ||
| model | string | "auto" | |
| osr | RoutingOptions | Platform extension carried in the chat body under osr (ignored by other providers). | |
| cache | boolean | null | ||
| constraints | object | ||
| conversation | boolean | false | |
| conversation_id | string | null | ||
| fallbacks | boolean | true | |
| memory | boolean | null | ||
| objective | object<number> | ||
| plan | boolean | null | ||
| plan_mode | string | null | ||
| prompt | PromptRef | null | ||
| provider | object | null | ||
| tenant | string | null | ||
| query(required) | string | ||
| return_documents | boolean | false | |
| top_n | integer | null | ||
| user | string | null |
Responses
| 200 | Successful Response |
| 422 | Validation ErrorHTTPValidationError |
| 401 | Missing, invalid or revoked API key |
curl -s -X POST "$OSR_URL/v1/rerank" \
-H "Authorization: Bearer $OSR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "documents": [], "query": "string" }'{
"documents": [],
"query": "string"
}post /v1 /responses
Responses
OpenAI **Responses API** over the chat path (opensmartroute.responses): input string or
items, instructions, flat tools, function_call_output turns, streaming events; metered
as a chat completion. previous_response_id continues a response of this workspace remembered for
OSR_PLATFORM_RESPONSES_STORE_TTL_S seconds (store: false opts out); built-in tools are
refused with 400 rather than dropped.
Requires an API key
Parameters
| Name | In | Type | Default | Description |
|---|---|---|---|---|
| x-osr-tenant | header | string | null | ||
| x-goog-api-key | header | string | null |
Responses
| 200 | Successful Response |
| 422 | Validation ErrorHTTPValidationError |
| 401 | Missing, invalid or revoked API key |
curl -s -X POST "$OSR_URL/v1/responses" \
-H "Authorization: Bearer $OSR_API_KEY"post /v1 /route
Alias of /api/v1/route
Requires an API key
Parameters
| Name | In | Type | Default | Description |
|---|---|---|---|---|
| x-osr-tenant | header | string | null | ||
| x-goog-api-key | header | string | null |
Request bodyRouteIn
| Field | Type | Default | Description |
|---|---|---|---|
| constraints | object | ||
| context | object | ||
| execute | boolean | false | |
| history | object[] | ||
| kinds | string[] | null | ||
| objective | object<number> | ||
| plan | boolean | false | |
| plan_mode | string | null | ||
| profile | object | ||
| prompt | PromptRef | null | ||
| text(required) | string | ||
| top_k | integer | 3 |
Responses
| 200 | Successful Response |
| 422 | Validation ErrorHTTPValidationError |
| 401 | Missing, invalid or revoked API key |
curl -s -X POST "$OSR_URL/v1/route" \
-H "Authorization: Bearer $OSR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "objective": { "quality": 1, "cost": 0.3 }, "top_k": 3 }'{
"objective": {
"quality": 1,
"cost": 0.3
},
"top_k": 3
}get /v1beta /models
Gemini Models
The Gemini-shaped model list: every name the workspace may route to, auto first.
Requires an API key
Parameters
| Name | In | Type | Default | Description |
|---|---|---|---|---|
| x-goog-api-key | header | string | null |
Responses
| 200 | Successful Response |
| 422 | Validation ErrorHTTPValidationError |
| 401 | Missing, invalid or revoked API key |
curl -s "$OSR_URL/v1beta/models" \
-H "Authorization: Bearer $OSR_API_KEY"post /v1beta /models /{model}:{action}
Gemini Action
Google Gemini API: generateContent (one GenerateContentResponse), streamGenerateContent
(?alt=sse frames) and countTokens, over the routed chat path with the same key, policy, budgets,
redaction and trace as a chat completion. model is auto or any target the workspace may use;
the models/ prefix the SDKs add is accepted.
Requires an API key
Parameters
| Name | In | Type | Default | Description |
|---|---|---|---|---|
| model(required) | path | string | ||
| action(required) | path | string | ||
| x-osr-tenant | header | string | null | ||
| x-goog-api-key | header | string | null |
Responses
| 200 | Successful Response |
| 422 | Validation ErrorHTTPValidationError |
| 401 | Missing, invalid or revoked API key |
curl -s -X POST "$OSR_URL/v1beta/models/<model>:<action>" \
-H "Authorization: Bearer $OSR_API_KEY"Something wrong or out of date on this page? Tell us - the page is named for you, so a one-line note is enough.