Skip to content
OpenSmartRoute
Documentation
Hosted platformREST API reference

OpenAI-compatible

OpenAI-compatible chat completions and model listing.

Hosted platformAPI version 2.1.0

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

NameInTypeDefaultDescription
x-osr-tenantheaderstring | null
x-goog-api-keyheaderstring | null

Request bodySpeechIn

FieldTypeDefaultDescription
input(required)string
instructionsstring | null
modelstring"auto"
osrRoutingOptionsPlatform extension carried in the chat body under osr (ignored by other providers).
cacheboolean | null
constraintsobject
conversationbooleanfalse
conversation_idstring | null
fallbacksbooleantrue
memoryboolean | null
objectiveobject<number>
planboolean | null
plan_modestring | null
promptPromptRef | null
providerobject | null
tenantstring | null
response_formatstring | null
speednumber | null
userstring | null
voicestring | null

Responses

200Successful Response
422Validation ErrorHTTPValidationError
401Missing, invalid or revoked API key
Requestbash
curl -s -X POST "$OSR_URL/v1/audio/speech" \
  -H "Authorization: Bearer $OSR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "input": "string" }'
Bodyjson
{
  "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

NameInTypeDefaultDescription
x-osr-tenantheaderstring | null
x-goog-api-keyheaderstring | null

Responses

200Successful Response
422Validation ErrorHTTPValidationError
401Missing, invalid or revoked API key
Requestbash
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

NameInTypeDefaultDescription
x-osr-tenantheaderstring | null
x-osr-cacheheaderstring | null
x-osr-cache-ttlheaderstring | null
x-goog-api-keyheaderstring | null

Request bodyChatCompletionIn

FieldTypeDefaultDescription
logprobsboolean | null
max_tokensinteger | null
messages(required)ChatMessage[]
metadataobject
modelstring"auto"
modelsstring[]
ninteger | null
osrRoutingOptionsPlatform extension carried in the chat body under osr (ignored by other providers).
cacheboolean | null
constraintsobject
conversationbooleanfalse
conversation_idstring | null
fallbacksbooleantrue
memoryboolean | null
objectiveobject<number>
planboolean | null
plan_modestring | null
promptPromptRef | null
providerobject | null
tenantstring | null
parallel_tool_callsboolean | null
providerobject | null
response_formatobject | null
seedinteger | null
stopstring | string[] | null
streambooleanfalse
stream_optionsobject | null
temperaturenumber | null
tool_choiceany
toolsobject[] | null
top_logprobsinteger | null
userstring | null

Responses

200Successful Response
422Validation ErrorHTTPValidationError
401Missing, invalid or revoked API key
Requestbash
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" }'
Bodyjson
{
  "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

NameInTypeDefaultDescription
x-osr-tenantheaderstring | null
x-goog-api-keyheaderstring | null

Request bodyEmbeddingsIn

FieldTypeDefaultDescription
dimensionsinteger | null
encoding_formatstring | null
input(required)string | string[]
modelstring"auto"
osrRoutingOptionsPlatform extension carried in the chat body under osr (ignored by other providers).
cacheboolean | null
constraintsobject
conversationbooleanfalse
conversation_idstring | null
fallbacksbooleantrue
memoryboolean | null
objectiveobject<number>
planboolean | null
plan_modestring | null
promptPromptRef | null
providerobject | null
tenantstring | null
userstring | null

Responses

200Successful Response
422Validation ErrorHTTPValidationError
401Missing, invalid or revoked API key
Requestbash
curl -s -X POST "$OSR_URL/v1/embeddings" \
  -H "Authorization: Bearer $OSR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "input": "string" }'
Bodyjson
{
  "input": "string"
}

post/v1/feedback

Alias of /api/v1/feedback

Requires an API key

Parameters

NameInTypeDefaultDescription
x-goog-api-keyheaderstring | null

Request bodyFeedbackIn

FieldTypeDefaultDescription
complexitynumber | null
cost_usdnumber | null
domainsstring[]
latency_msnumber | null
preferred_overstring | null
qualitynumber | null
request_id(required)string
rolestring | null
success(required)boolean
target_id(required)string

Responses

200Successful Response
422Validation ErrorHTTPValidationError
401Missing, invalid or revoked API key
Requestbash
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 }'
Bodyjson
{
  "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

NameInTypeDefaultDescription
x-osr-tenantheaderstring | null
x-goog-api-keyheaderstring | null

Request bodyImagesIn

FieldTypeDefaultDescription
modelstring"auto"
ninteger | null
osrRoutingOptionsPlatform extension carried in the chat body under osr (ignored by other providers).
cacheboolean | null
constraintsobject
conversationbooleanfalse
conversation_idstring | null
fallbacksbooleantrue
memoryboolean | null
objectiveobject<number>
planboolean | null
plan_modestring | null
promptPromptRef | null
providerobject | null
tenantstring | null
prompt(required)string
qualitystring | null
response_formatstring | null
sizestring | null
stylestring | null
userstring | null

Responses

200Successful Response
422Validation ErrorHTTPValidationError
401Missing, invalid or revoked API key
Requestbash
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." }'
Bodyjson
{
  "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

NameInTypeDefaultDescription
x-osr-tenantheaderstring | null
x-goog-api-keyheaderstring | null

Responses

200Successful Response
422Validation ErrorHTTPValidationError
401Missing, invalid or revoked API key
Requestbash
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

NameInTypeDefaultDescription
x-goog-api-keyheaderstring | null

Responses

200Successful Response
422Validation ErrorHTTPValidationError
401Missing, invalid or revoked API key
Requestbash
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

NameInTypeDefaultDescription
x-goog-api-keyheaderstring | null

Responses

200Successful Response
422Validation ErrorHTTPValidationError
401Missing, invalid or revoked API key
Requestbash
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

NameInTypeDefaultDescription
x-goog-api-keyheaderstring | null

Request bodyModerationsIn

FieldTypeDefaultDescription
flag_piibooleanfalse
input(required)string | any[]
modelstring | null

Responses

200Successful Response
422Validation ErrorHTTPValidationError
401Missing, invalid or revoked API key
Requestbash
curl -s -X POST "$OSR_URL/v1/moderations" \
  -H "Authorization: Bearer $OSR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "input": "string" }'
Bodyjson
{
  "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

NameInTypeDefaultDescription
x-osr-tenantheaderstring | null
x-goog-api-keyheaderstring | null

Request bodyRerankIn

FieldTypeDefaultDescription
documents(required)string | object[]
modelstring"auto"
osrRoutingOptionsPlatform extension carried in the chat body under osr (ignored by other providers).
cacheboolean | null
constraintsobject
conversationbooleanfalse
conversation_idstring | null
fallbacksbooleantrue
memoryboolean | null
objectiveobject<number>
planboolean | null
plan_modestring | null
promptPromptRef | null
providerobject | null
tenantstring | null
query(required)string
return_documentsbooleanfalse
top_ninteger | null
userstring | null

Responses

200Successful Response
422Validation ErrorHTTPValidationError
401Missing, invalid or revoked API key
Requestbash
curl -s -X POST "$OSR_URL/v1/rerank" \
  -H "Authorization: Bearer $OSR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "documents": [], "query": "string" }'
Bodyjson
{
  "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

NameInTypeDefaultDescription
x-osr-tenantheaderstring | null
x-goog-api-keyheaderstring | null

Responses

200Successful Response
422Validation ErrorHTTPValidationError
401Missing, invalid or revoked API key
Requestbash
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

NameInTypeDefaultDescription
x-osr-tenantheaderstring | null
x-goog-api-keyheaderstring | null

Request bodyRouteIn

FieldTypeDefaultDescription
constraintsobject
contextobject
executebooleanfalse
historyobject[]
kindsstring[] | null
objectiveobject<number>
planbooleanfalse
plan_modestring | null
profileobject
promptPromptRef | null
text(required)string
top_kinteger3

Responses

200Successful Response
422Validation ErrorHTTPValidationError
401Missing, invalid or revoked API key
Requestbash
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 }'
Bodyjson
{
  "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

NameInTypeDefaultDescription
x-goog-api-keyheaderstring | null

Responses

200Successful Response
422Validation ErrorHTTPValidationError
401Missing, invalid or revoked API key
Requestbash
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

NameInTypeDefaultDescription
model(required)pathstring
action(required)pathstring
x-osr-tenantheaderstring | null
x-goog-api-keyheaderstring | null

Responses

200Successful Response
422Validation ErrorHTTPValidationError
401Missing, invalid or revoked API key
Requestbash
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.