Skip to main content

Endpoint

The body is an OpenAI Chat Completions request. The gateway reads model and stream, resolves the model through the virtual key, and sends the request to the provider that serves it. Point any OpenAI SDK at the gateway: set the base URL to https://gateway.langwatch.ai/v1 and the API key to the virtual key. The key also works in an x-api-key header.

Request

Response

OpenAI-compatible providers (OpenAI, Azure OpenAI, custom OpenAI-compatible endpoints) answer in their own bytes. On the translated lanes (Anthropic, Bedrock, Gemini, Vertex) the gateway builds the provider request and rebuilds the answer in this shape. When the gateway dropped a parameter, the answer carries the list in extra_fields.params_dropped.

Parameters the gateway changes or refuses

Request headers the gateway reads

Response headers

Non-streaming calls that run long receive a single space character before the JSON body at each keep-alive interval. JSON parsers skip it.

Streaming

Set "stream": true. The response is text/event-stream, one data: frame per chunk, ending with data: [DONE]:
Two extra frames can appear:
  • event: error with a JSON object when the stream fails after it opened. See Errors.
  • event: warning with {"warning":"provider_did_not_report_usage_on_stream"} when the stream ended with no usage from the provider.
Response headers are written before the first frame. Dropped parameters also land in extra_fields.params_dropped on the final usage-bearing chunk.

Errors

The gateway answers with the envelope on Errors. Codes this endpoint raises before the provider is called: A provider’s own error is forwarded with the provider’s status and body, under X-LangWatch-Provider. Also check: Streaming, Model aliases, Budgets.
Last modified on September 6, 2026