Skip to main content
POST
The body is an OpenAI Chat Completions request, whatever the provider: the gateway translates it for Anthropic, Google, Bedrock, Mistral and the others, and answers in OpenAI’s format. An OpenAI or Azure model receives it on its own Chat Completions API, as you sent it, or on its Responses API when the request needs a feature only that API serves (see self-heal). Point any OpenAI client at https://gateway.weflayr.com/v1 with an API key with the Gateway scope.

Request body

string
required
A model name (e.g. claude-opus-5-5, gpt-6-luna), as GET /v1/models lists them, or a routing strategy or A/B test slug: strategy/<slug> for its latest version (strategy/<slug>:latest is the same), strategy/<slug>:<version> to pin one. Any other text after the : returns a 400 invalid_routing_strategy_version. Do not prefix the name with the provider (openai/gpt-6-luna is not found): set provider instead. A list of model names is tried in order (see fallback); a routing strategy cannot be in a list.
object[]
required
The conversation, as the OpenAI Chat Completions API writes it. A content part can mark a cache breakpoint with Anthropic’s cache_control or OpenAI’s prompt_cache_breakpoint, whatever the model: the gateway writes it the way the provider reads it.
integer
The most tokens the answer can have, reasoning tokens included. The deprecated max_tokens is read too; send one or the other.
number
The sampling temperature.
number
Nucleus sampling: the model samples among the tokens making up this share of the probability. Removed by self-heal on models that refuse it, such as Claude Opus 4.7 and later.
integer
The model samples among this many most likely tokens. Removed by self-heal on OpenAI, Azure and xAI, which have no such field.
string
Text, or a list of texts, that ends the answer when the model writes it. Removed by self-heal on xAI.
number
Lowers the odds of tokens already in the answer. Removed by self-heal on xAI, Anthropic and Bedrock, like frequency_penalty.
number
Lowers the odds of tokens by how often they already appear in the answer.
integer
Makes sampling repeatable where the provider supports it. Removed by self-heal on xAI, Anthropic and Bedrock.
integer
default:"1"
The number of answers to write. Above 1, removed by self-heal on xAI, Anthropic and Bedrock.
boolean
true returns the log probability of each answer token. Removed by self-heal on Anthropic, Bedrock and xAI.
integer
The number of most likely tokens to return at each position, with their log probabilities. Needs logprobs: true.
object[]
The function tools the model may call (type: "function", with its name, description, parameters and strict).
string
auto, required or none, or a function to call ({"type": "function", "function": {"name": "..."}}).
boolean
Whether the model may call several tools in one turn.
object
Lets the model search the web (search_context_size, user_location), on the providers that run a web search.
object
{"type": "text"}, {"type": "json_object"}, or {"type": "json_schema", "json_schema": {"name": "...", "schema": {...}, "strict": true}} for a structured output.
string
none, minimal, low, medium, high, xhigh or max. A level the model does not take is replaced with the closest one it does if self-heal is on. Send it or reasoning, not both. Through a routing strategy, it wins over the effort the strategy sets.
object
How much the model thinks before it answers, with more control than reasoning_effort.
string
auto, default, flex, priority or ultrafast. flex, priority and ultrafast keep only the providers and regions that offer that tier (Azure, for example, offers flex in GLOBAL only).
string
An id of your end user, passed to the provider.
boolean
default:"false"
true streams the answer as server-sent events (see Response).
object
include_obfuscation: false leaves out the padding OpenAI adds to each streamed chunk.
string
A key grouping requests that share a prompt prefix, to improve prompt cache hits. Used by OpenAI, Azure, xAI, Meta, Mistral and the Bedrock models called through their Responses API (e.g. some of OpenAI’s or Kimi K3). Claude, Gemini and the other Bedrock models refuse it. Without one, the gateway sends these providers a key of its own per organization and model.
string
in_memory or 24h: how long OpenAI keeps the cached prompt prefix. Sent to OpenAI, Azure and Bedrock’s Responses API models; with self-heal on, removed for Claude, Gemini, the other Bedrock models and xAI, which have no such field. To set a lifetime on any model taking cache breakpoints, use the breakpoint’s ttl: self-heal moves it to the closest lifetime the provider offers.
object
{"mode": "explicit"} turns off GPT-5.6+‘s implicit cache, so only your breakpoints are cached. Sent and removed like prompt_cache_retention.
string
A stable id of your end user, hashed, which the provider uses to detect abuse.
integer
The most built-in tool calls the model can make in one answer.
string
auto drops the earliest messages when the prompt is longer than the model’s context, disabled (the default) refuses it.

Cache breakpoints

Mark cache breakpoints with OpenAI’s prompt_cache_breakpoint (with an optional ttl): it works on every provider, for every model that takes cache breakpoints, such as Claude, GPT-5.6 and later, Kimi, Qwen, GLM and Nova. Anthropic’s cache_control is accepted too. With self-heal on, the gateway removes the breakpoints on a model where they write no cache, and replaces a ttl the provider does not offer with the closest one it does: 5m or 1h on Claude, 30m or 12h on OpenAI and Azure. A request body of 4 MiB or more is answered with a 503 large_requests_overloaded and a Retry-After header when other large bodies take all the memory the gateway reserves for them and none frees up within 5 seconds. Smaller requests are never refused for this reason. A request sent without a Content-Length header (chunked) counts for the bytes the gateway has read of it so far, once they reach 4 MiB. Such a body, and any chunked one, must be received within 10 seconds plus 1 second per MiB (of its Content-Length, or of the bytes received so far when chunked), or the request is answered with a 408 request_body_too_slow.

Response

An OpenAI Chat Completion object. When the gateway changed the request or a routing strategy setting, or moved the request to another deployment, the response also has weflayr_warnings, the list of changes. The gateway adds these fields to the answer, in the same format as OpenRouter.
number | null
What Weflayr bills the call, in USD: the cost of its tokens, or the Weflayr fee when the call was made with your own provider key. null when the gateway could not price the call.
boolean
Whether the call was made with your own provider key.
object | null
The token cost at the provider’s prices, in USD. The Responses API names the fields input and output instead of prompt and completions. null when usage.cost is.
object
The provider, model and region that answered the call, e.g. {"provider": "anthropic", "model": "claude-opus-5-5", "region": "GLOBAL"}.
With "stream": true, the gateway answers with OpenAI’s server-sent events, ending with data: [DONE]. Warnings then come first, in a chunk with no choice. The last chunk, which has no choice, holds the usage and weflayr_deployment.

Errors

See Errors.