Skip to navigation

Create an OpenRouter chat completion

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.

Authentication

AuthorizationBearer

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.

Headers

x-openrouter-api-keystringRequired
Your OpenRouter API key. Authorization carries the Respan API key on this operation.

Request

This endpoint expects an object.
modelstringRequired

OpenRouter model slug, for example anthropic/claude-sonnet-4-5. An openrouter/ prefix is also accepted and is stripped before the call goes upstream.

messageslist of maps from strings to anyRequired
streambooleanOptionalDefaults to false
providermap from strings to anyOptional
OpenRouter provider routing block, forwarded unchanged.
reasoningmap from strings to anyOptional
OpenRouter reasoning block, forwarded unchanged.
respan_paramsmap from strings to anyOptional

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.

Response

OpenRouter response or event stream.

Errors

400
Bad Request Error
402
Payment Required Error
403
Forbidden Error
404
Not Found Error
429
Too Many Requests Error