Create an OpenRouter chat completion
https://api.respan.ai/api/openrouter/v1/chat/completionsForward OpenRouter requests and return its response, status code, or event stream unchanged. OpenRouter fields such as provider and reasoning are preserved. Supply your Respan key in Authorization and your OpenRouter key in x-openrouter-api-key; this endpoint requires your own OpenRouter key and does not use Respan gateway credits.
Servers
https://api.respan.ai: Respan API Server
Authentication
RespanApiKey
Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer <RESPAN_API_KEY>. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan_params.credential_override in the request body, not in this authentication field.
HTTP scheme: bearer; format: Respan API key.
Authorization: Bearer $RESPAN_API_KEYHeaders
x-openrouter-api-key string RequiredRequest body
A request body is required.
application/json
$ object Required body
model string Required in parentmessages array<object> Required in parent
1messages[] object Array itemstream boolean Optionalfalseprovider object OptionalAdditional properties are allowed
reasoning object OptionalAdditional properties are allowed
respan_params object OptionalAdditional properties are allowed
OpenAPI request schema
{
"type": "object",
"required": [
"model",
"messages"
],
"properties": {
"model": {
"type": "string",
"description": "OpenRouter model slug, for example openai/gpt-6-luna. An openrouter/ prefix is also accepted and is stripped before the call goes upstream."
},
"messages": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"additionalProperties": true
}
},
"stream": {
"type": "boolean",
"default": false
},
"provider": {
"type": "object",
"additionalProperties": true,
"description": "OpenRouter provider routing block, forwarded unchanged."
},
"reasoning": {
"type": "object",
"additionalProperties": true,
"description": "OpenRouter reasoning block, forwarded unchanged."
},
"respan_params": {
"type": "object",
"additionalProperties": true,
"description": "Respan gateway metadata. Stripped before the payload reaches OpenRouter. Must be a JSON object: a string, list, number or boolean is ignored and none of its params apply."
}
},
"additionalProperties": true
}Example
{
"model": "openai/gpt-6-luna",
"messages": [
{
"role": "user",
"content": "Reply with exactly ok."
}
],
"max_tokens": 32
}Responses
200
OpenRouter response or event stream.
application/json
$ object BodyOpenAPI response schema
{
"type": "object",
"additionalProperties": true
}text/event-stream
$ string BodyOpenAPI response schema
{
"type": "string",
"description": "OpenRouter server-sent event stream, including the data: [DONE] sentinel."
}400
x-openrouter-api-key is missing, or OpenRouter rejected the request. OpenRouter’s own errors come back with its body.
application/json
$ object BodyOpenAPI response schema
{
"type": "object",
"additionalProperties": true
}Example
{
"detail": "Missing OpenRouter credentials. Send your OpenRouter API key in the 'x-openrouter-api-key' header. The 'Authorization' header carries your Respan key on this endpoint."
}402
Relayed from OpenRouter: insufficient credits.
application/json
$ object BodyOpenAPI response schema
{
"type": "object",
"additionalProperties": true
}403
The API key is missing, invalid or expired.
application/json
$ object Body
detail string Required in parentOpenAPI response schema
{
"type": "object",
"required": [
"detail"
],
"properties": {
"detail": {
"type": "string"
}
}
}Example
{
"detail": "Your API key is invalid or expired, please check your API key in the platform settings."
}404
Relayed from OpenRouter: unknown model or route.
application/json
$ object BodyOpenAPI response schema
{
"type": "object",
"additionalProperties": true
}429
Rate limit exceeded, from Respan or relayed from OpenRouter.
application/json
$ object BodyOpenAPI response schema
{
"type": "object",
"additionalProperties": true
}OpenAPI source
The operation and referenced components below retain the complete OpenAPI definitions, including constraints and examples.
OpenAPI operation
{
"summary": "Create an OpenRouter chat completion",
"operationId": "openrouter_native_chat_completions",
"tags": [
"OpenRouter Gateway"
],
"description": "Forward OpenRouter requests and return its response, status code, or event stream unchanged. OpenRouter fields such as `provider` and `reasoning` are preserved. Supply your Respan key in `Authorization` and your OpenRouter key in `x-openrouter-api-key`; this endpoint requires your own OpenRouter key and does not use Respan gateway credits.",
"parameters": [
{
"name": "x-openrouter-api-key",
"in": "header",
"required": true,
"schema": {
"type": "string"
},
"description": "Your OpenRouter API key. Authorization carries the Respan API key on this operation."
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"model",
"messages"
],
"properties": {
"model": {
"type": "string",
"description": "OpenRouter model slug, for example openai/gpt-6-luna. An openrouter/ prefix is also accepted and is stripped before the call goes upstream."
},
"messages": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"additionalProperties": true
}
},
"stream": {
"type": "boolean",
"default": false
},
"provider": {
"type": "object",
"additionalProperties": true,
"description": "OpenRouter provider routing block, forwarded unchanged."
},
"reasoning": {
"type": "object",
"additionalProperties": true,
"description": "OpenRouter reasoning block, forwarded unchanged."
},
"respan_params": {
"type": "object",
"additionalProperties": true,
"description": "Respan gateway metadata. Stripped before the payload reaches OpenRouter. Must be a JSON object: a string, list, number or boolean is ignored and none of its params apply."
}
},
"additionalProperties": true
},
"example": {
"model": "openai/gpt-6-luna",
"messages": [
{
"role": "user",
"content": "Reply with exactly ok."
}
],
"max_tokens": 32
}
}
}
},
"responses": {
"200": {
"description": "OpenRouter response or event stream.",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": true
}
},
"text/event-stream": {
"schema": {
"type": "string",
"description": "OpenRouter server-sent event stream, including the data: [DONE] sentinel."
}
}
}
},
"400": {
"description": "`x-openrouter-api-key` is missing, or OpenRouter rejected the request. OpenRouter's own errors come back with its body.",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": true
},
"example": {
"detail": "Missing OpenRouter credentials. Send your OpenRouter API key in the 'x-openrouter-api-key' header. The 'Authorization' header carries your Respan key on this endpoint."
}
}
}
},
"402": {
"description": "Relayed from OpenRouter: insufficient credits.",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
},
"403": {
"$ref": "#/components/responses/InvalidApiKey"
},
"404": {
"description": "Relayed from OpenRouter: unknown model or route.",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
},
"429": {
"description": "Rate limit exceeded, from Respan or relayed from OpenRouter.",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
}
},
"security": [
{
"RespanApiKey": []
}
]
}OpenAPI path metadata
{}Referenced OpenAPI components
{
"responses": {
"InvalidApiKey": {
"description": "The API key is missing, invalid or expired.",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"detail"
],
"properties": {
"detail": {
"type": "string"
}
}
},
"example": {
"detail": "Your API key is invalid or expired, please check your API key in the platform settings."
}
}
}
}
},
"securitySchemes": {
"RespanApiKey": {
"type": "http",
"scheme": "bearer",
"bearerFormat": "Respan API key",
"description": "Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer <RESPAN_API_KEY>. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan_params.credential_override in the request body, not in this authentication field.",
"x-fern-bearer": {
"name": "respanApiKey",
"env": "RESPAN_API_KEY"
}
}
}
}