Create an OpenAI-format chat completion
Changed onRelay an OpenAI-format chat completions payload to one provider and get that provider's response back byte for byte. Respan authenticates the request, applies your limits, and logs it, but doesn't translate the request or recompute usage. Respan removes respan_params and merges a literal extra_body object into the body; unknown and provider-only fields are passed through. Streams are relayed frame by frame, and requests time out after 600 seconds.
{provider} is a provider with an OpenAI-format API, such as openai, azure_openai, xai, groq, mistral, deepseek, togetherai, fireworks, or perplexity. A provider without an OpenAI-format API returns 404. A provider with no fixed public endpoint, such as Azure OpenAI, needs the provider URL saved with its key; without it the request returns 400. Anthropic, Google and OpenRouter have their own endpoints.
Upstream, Respan sends only accept, accept-language, content-type, user-agent, and headers that start with x- plus the provider ID, with _ written as - (for example x-azure-openai-). The response includes X-Respan-Log-Id, X-Respan-Upstream-Request-Id, and the provider's x-ratelimit-* and retry-after headers.
The example uses openai with gpt-6-luna. If you select another provider, use that provider's model ID and a model supported on Respan credits, or configure your provider key in Settings > Providers.
Request
- Base URLhttps://api.respan.ai
- URLhttps://api.respan.ai/api/{provider}/v1/chat/completions
- AuthHTTP bearer
Path parameters
The provider ID, such as openai, azure_openai, xai, groq, mistral, deepseek, togetherai, fireworks, or perplexity.
Request body
Example request
{
"model": "gpt-6-luna",
"messages": [
{
"role": "user",
"content": "Reply with exactly ok."
}
],
"max_completion_tokens": 32,
"reasoning_effort": "none"
}Response
The provider's response, unchanged.
Changes
- breaking
request body became required
- info
api operation id
providerGateway_createProviderChatCompletionremoved and replaced withcreateProviderChatCompletion - info
api tag
Provider Gatewayadded - info
api tag
providerGatewayremoved - info
added the media type
text/event-streamfor the response with the status
- breaking
- info
endpoint added
- info