from openai import OpenAI
client = OpenAI(base_url="https://gateway.weflayr.com/v1", api_key="<WEFLAYR_API_KEY>")
completion = client.chat.completions.create(
model="claude-opus-5-5",
messages=[{"role": "user", "content": "Hello"}],
max_completion_tokens=256,
extra_headers={"x-weflayr-metadata": '{"feature_name": "support-chat"}'},
extra_body={"weflayr": {"customer_name": "acme", "call_name": "answer_question"}},
)
const OpenAI = require('openai');
const client = new OpenAI({ baseURL: 'https://gateway.weflayr.com/v1', apiKey: '<WEFLAYR_API_KEY>' });
const completion = await client.chat.completions.create(
{
model: 'claude-opus-5-5',
messages: [{ role: 'user', content: 'Hello' }],
max_completion_tokens: 256,
weflayr: { customer_name: 'acme', call_name: 'answer_question' },
},
{ headers: { 'x-weflayr-metadata': JSON.stringify({ feature_name: 'support-chat' }) } },
);
curl https://gateway.weflayr.com/v1/chat/completions \
-H "Authorization: Bearer $WEFLAYR_API_KEY" \
-H "Content-Type: application/json" \
-H 'x-weflayr-metadata: {"feature_name": "support-chat"}' \
-d '{
"model": "claude-opus-5-5",
"messages": [{"role": "user", "content": "Hello"}],
"max_completion_tokens": 256,
"weflayr": {"customer_name": "acme", "call_name": "answer_question"}
}'
{
"id": "chatcmpl-8f3c2a1e9b7d4c6a",
"object": "chat.completion",
"created": 1792051200,
"model": "claude-opus-5-5",
"choices": [
{
"index": 0,
"message": {"role": "assistant", "content": "Hello! How can I help you today?"},
"finish_reason": "stop"
}
],
"usage": {"prompt_tokens": 8, "completion_tokens": 12, "total_tokens": 20}
}
Gateway
Chat completions
Call any model of any provider with the OpenAI Chat Completions format.
POST
/
v1
/
chat
/
completions
from openai import OpenAI
client = OpenAI(base_url="https://gateway.weflayr.com/v1", api_key="<WEFLAYR_API_KEY>")
completion = client.chat.completions.create(
model="claude-opus-5-5",
messages=[{"role": "user", "content": "Hello"}],
max_completion_tokens=256,
extra_headers={"x-weflayr-metadata": '{"feature_name": "support-chat"}'},
extra_body={"weflayr": {"customer_name": "acme", "call_name": "answer_question"}},
)
const OpenAI = require('openai');
const client = new OpenAI({ baseURL: 'https://gateway.weflayr.com/v1', apiKey: '<WEFLAYR_API_KEY>' });
const completion = await client.chat.completions.create(
{
model: 'claude-opus-5-5',
messages: [{ role: 'user', content: 'Hello' }],
max_completion_tokens: 256,
weflayr: { customer_name: 'acme', call_name: 'answer_question' },
},
{ headers: { 'x-weflayr-metadata': JSON.stringify({ feature_name: 'support-chat' }) } },
);
curl https://gateway.weflayr.com/v1/chat/completions \
-H "Authorization: Bearer $WEFLAYR_API_KEY" \
-H "Content-Type: application/json" \
-H 'x-weflayr-metadata: {"feature_name": "support-chat"}' \
-d '{
"model": "claude-opus-5-5",
"messages": [{"role": "user", "content": "Hello"}],
"max_completion_tokens": 256,
"weflayr": {"customer_name": "acme", "call_name": "answer_question"}
}'
{
"id": "chatcmpl-8f3c2a1e9b7d4c6a",
"object": "chat.completion",
"created": 1792051200,
"model": "claude-opus-5-5",
"choices": [
{
"index": 0,
"message": {"role": "assistant", "content": "Hello! How can I help you today?"},
"finish_reason": "stop"
}
],
"usage": {"prompt_tokens": 8, "completion_tokens": 12, "total_tokens": 20}
}
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. Point any OpenAI client at
https://gateway.weflayr.com/v1 with a Gateway API key.
OpenAI fields
The gateway readsmodel, messages, max_completion_tokens (or the deprecated max_tokens), temperature, top_p, top_k, stop, stream, stream_options, tools (function tools), tool_choice, parallel_tool_calls, response_format, reasoning_effort, service_tier (flex or priority keep only the providers that offer it), presence_penalty, frequency_penalty, seed, n, logprobs, top_logprobs, user and web_search_options.
OpenAI, Azure and xAI models are called through their Responses API, which has no
stop, seed, presence_penalty, frequency_penalty, top_k, logit_bias, audio, modalities, metadata, store, or n above 1: sending one of these to those models returns a 400.Weflayr fields
The gateway reads these fields on top of the OpenAI ones and never sends them to the provider. With the OpenAI SDK, pass them inextra_body (Python) or as extra keys of the request object (Node.js).
string
required
A model name, as listed in the model picker of a benchmark (e.g.
claude-opus-5-5, gpt-5.6), or a routing strategy id: strategy/<id> for its latest version, strategy/<id>:<version> to pin one.string
Serve the model from this provider only:
alibaba, anthropic, azure, bedrock, google, mistral, openai, spacexai or vertex. Omit to let Weflayr pick one. Not allowed with a routing strategy.string
Serve the model from this region only:
GLOBAL, US, EU, or a provider’s own region (e.g. eu-west-1 on Bedrock). Not allowed with a routing strategy."on_with_warnings" | "on" | "off"
default:"\"on_with_warnings\""
What to do with a parameter the model does not take (e.g.
temperature on a reasoning model): on_with_warnings removes it and lists the change in weflayr_warnings, on removes it silently, off sends the request unchanged.list[string]
Parameters to remove when the model does not take them, even with
self_heal: "off": any of service_tier, temperature, tool_choice, reasoning, cache_breakpoints, parallel_tool_calls.object
Raw provider fields merged into the request sent to the provider, keyed by
common (every provider), an API family (e.g. anthropic_messages, gemini_generate_content) or a provider (e.g. openai).object
What the call is for, shown on your dashboards.
Show properties
Show properties
string
string
The name of this LLM call inside its feature, e.g.
summarize_ticket. A benchmark is set up per call name.{string: string}
Your own dimensions to filter on, e.g.
{"environment": "production"}.boolean
default:"true"
Keep the prompt and the answer. Set
false to keep only tokens, cost and latency. Benchmarks need the content.JSON object
The feature the call belongs to, as
{"feature_name": "support-chat"}. It also takes feature_run_uuid (32 hex characters, to group the calls of one feature run), customer_name, call_name and tags; the body’s weflayr values win over the header’s. The SDKs set this header for you.Response
An OpenAI Chat Completion object. Whenself_heal changed the request, the response also carries weflayr_warnings, a list of the changes.
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.
Errors
See Errors.from openai import OpenAI
client = OpenAI(base_url="https://gateway.weflayr.com/v1", api_key="<WEFLAYR_API_KEY>")
completion = client.chat.completions.create(
model="claude-opus-5-5",
messages=[{"role": "user", "content": "Hello"}],
max_completion_tokens=256,
extra_headers={"x-weflayr-metadata": '{"feature_name": "support-chat"}'},
extra_body={"weflayr": {"customer_name": "acme", "call_name": "answer_question"}},
)
const OpenAI = require('openai');
const client = new OpenAI({ baseURL: 'https://gateway.weflayr.com/v1', apiKey: '<WEFLAYR_API_KEY>' });
const completion = await client.chat.completions.create(
{
model: 'claude-opus-5-5',
messages: [{ role: 'user', content: 'Hello' }],
max_completion_tokens: 256,
weflayr: { customer_name: 'acme', call_name: 'answer_question' },
},
{ headers: { 'x-weflayr-metadata': JSON.stringify({ feature_name: 'support-chat' }) } },
);
curl https://gateway.weflayr.com/v1/chat/completions \
-H "Authorization: Bearer $WEFLAYR_API_KEY" \
-H "Content-Type: application/json" \
-H 'x-weflayr-metadata: {"feature_name": "support-chat"}' \
-d '{
"model": "claude-opus-5-5",
"messages": [{"role": "user", "content": "Hello"}],
"max_completion_tokens": 256,
"weflayr": {"customer_name": "acme", "call_name": "answer_question"}
}'
{
"id": "chatcmpl-8f3c2a1e9b7d4c6a",
"object": "chat.completion",
"created": 1792051200,
"model": "claude-opus-5-5",
"choices": [
{
"index": 0,
"message": {"role": "assistant", "content": "Hello! How can I help you today?"},
"finish_reason": "stop"
}
],
"usage": {"prompt_tokens": 8, "completion_tokens": 12, "total_tokens": 20}
}