Provider Gateway

Create an OpenAI-format chat completion

Changed on

Relay 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.

post/api/{provider}/v1/chat/completions

Request

  • Base URL
    https://api.respan.ai
  • URL
    https://api.respan.ai/api/{provider}/v1/chat/completions
  • Auth
    HTTP bearer

Path parameters

providerstring required
Example:openai

The provider ID, such as openai, azure_openai, xai, groq, mistral, deepseek, togetherai, fireworks, or perplexity.

Request body

modelstring required

The provider's own model ID.

messagesobject[] required

Chat messages in OpenAI format.

streamboolean

Stream the provider's response as server-sent events.

respan_paramsobject

Respan parameters such as customer_identifier or metadata. Removed before the request is forwarded.

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.

object required

Changes

    • breaking

      request body became required

    • info

      api operation id providerGateway_createProviderChatCompletion removed and replaced with createProviderChatCompletion

    • info

      api tag Provider Gateway added

    • info

      api tag providerGateway removed

    • info

      added the media type text/event-stream for the response with the status

    • info

      endpoint added