Перейти к содержимому

Create chat completion

POST
/chat/completions
curl https://api.waibee.com/v1/chat/completions \
-H "Authorization: Bearer $WAIBEE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4.6",
"messages": [{ "role": "user", "content": "Hello!" }]
}'

OpenAI-compatible chat completion. Send messages, receive a model response. Set stream: true for a Server-Sent Events stream terminated by data: [DONE].

Media typeapplication/json
object
model
required

<provider>/<model> from GET /v1/models. waibee/auto lets the router pick.

string
messages
required
Array<object>
>= 1 items
object
role
required
string
Allowed values: system user assistant
content
required
string
stream

Stream the response as Server-Sent Events.

boolean
max_tokens

Maximum tokens to generate. max_completion_tokens is also accepted.

integer
temperature
number
<= 2
top_p
number
tools

Function/tool definitions (max 256).

Array<object>

Function/tool definition for function calling.

object
type
string
Allowed value: function
function
object
name
string
description
string
parameters

JSON Schema of the tool arguments.

object
key
additional properties
any
tool_choice

Tool selection: auto | none | required, or an object {type: function, function: {name}}.

string
web_search_options

Ask the router to run a web search for this request. An empty object is enough. Each executed search is billed on top of tokens, and the sources come back as message.annotations[].url_citation.

object
key
additional properties
any
response_format

Structured output format.

object
type
string
Allowed values: text json_object json_schema
json_schema

Schema used when type is json_schema.

object
key
additional properties
any
reasoning_effort

Reasoning depth. max is NOT supported here, use /v1/messages with output_config.effort.

string
Allowed values: minimal low medium high xhigh
plugins

Per-request plugins.

object
dlp

Data-loss-prevention scan, mask or block. Optional: a DLP policy set for your API key applies as a floor of strictness even when this object is absent, and this object can only make the check stricter. entity_types is unioned with the policy’s categories, so the scan may be wider than the list you send.

object
mode

Applies to the rules you declare yourself. Where the key’s policy declares the same rule, the stricter of the two modes wins; the policy’s own categories keep the mode the administrator set.

string
Allowed values: alert mask block
entity_types

Unioned with the categories of the key’s policy, never narrowing them.

Array<string>
report_scope

Which messages’ findings come back to you. Narrowing it does not narrow the scan: every message is still scanned, and the block decision counts every finding.

string
default: all
Allowed values: all last_message latest_user_message
stop_words

Values that are a finding on their own, whatever the categories say. Unioned with the key’s policy.

Array<object>
object
value
required
string
match
string
default: exact
Allowed values: exact fuzzy
allowlist

Exceptions, matched on the whole value only. They reach your own rules only: an exception never lifts a finding raised by a rule of the key’s policy. Within your own config a stop word beats an exception on the same value.

Array<object>
object
value
required
string
match

Exact only. A substring exception would exempt every lookalike containing it.

string
default: exact
Allowed values: exact
regexes

Named patterns, run by RE2. Unioned with the key’s policy.

Array<object>
object
name
required
string
pattern
required
string
injected_context_names

Marks a message as inserted by the platform rather than typed by a person, by the value of its name field, and takes it out of the scan. Ignored while a policy applies to your key: on this path the same caller supplies both the marker and the content, so it would be a way to opt out of the check.

Array<string>
acknowledged

Reserved, and currently changes nothing: alert reports the findings and forwards the request, so there is no hold to confirm.

boolean

Model response.

Media typeapplication/json
object
id
string
object
string
Allowed value: chat.completion
created
integer
model
string
choices
Array<object>
object
index
integer
finish_reason
string
Allowed values: stop length tool_calls content_filter
message
object
role
required
string
Allowed values: system user assistant
content
required
string
usage
object
prompt_tokens
integer
completion_tokens
integer
total_tokens
integer
prompt_tokens_details
object
cached_tokens
integer
cache_write_tokens
integer
Example
{
"id": "gen-...",
"object": "chat.completion",
"created": 1784025392,
"model": "anthropic/claude-sonnet-4.6",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": "Paris"
}
}
],
"usage": {
"prompt_tokens": 22,
"completion_tokens": 6,
"total_tokens": 28
}
}

Invalid request. Codes: invalid_model, validation_error, feature_not_supported.

Media typeapplication/json

OpenAI-format error envelope.

object
error
required
object
code
string
message
string
extra

Additional error data; fields depend on the error code.

object
key
additional properties
any
Example
{
"error": {
"code": "invalid_model",
"message": "Model 'foo' is not available",
"extra": {}
}
}

Missing or invalid API key.

Media typeapplication/json
object
error
string
Example
{
"error": "unauthorized"
}

Not enough credits for the request (insufficient_funds).

Media typeapplication/json

OpenAI-format error envelope.

object
error
required
object
code
string
message
string
extra

Additional error data; fields depend on the error code.

object
key
additional properties
any
Example
{
"error": {
"code": "insufficient_funds",
"message": "Insufficient credits",
"extra": {}
}
}

Request blocked by an access policy (policy_violation) or by DLP (dlp_violation). A DLP block is about the content of the request, not about the key’s permissions: branch on error.code, not on the status alone.

Media typeapplication/json

OpenAI-format error envelope.

object
error
required
object
code
string
message
string
extra

Additional error data; fields depend on the error code.

object
key
additional properties
any
Examples

Model not allowed for this group

{
"error": {
"code": "policy_violation",
"message": "Request blocked by policy",
"extra": {}
}
}

Model not in the catalog (model_not_found).

Media typeapplication/json

OpenAI-format error envelope.

object
error
required
object
code
string
message
string
extra

Additional error data; fields depend on the error code.

object
key
additional properties
any
Example
{
"error": {
"code": "model_not_found",
"message": "Model 'nonexistent/model' is not available. Check the model name and try again.",
"extra": {}
}
}

Upstream took too long, including a stream that went silent (provider_timeout).

Media typeapplication/json

OpenAI-format error envelope.

object
error
required
object
code
string
message
string
extra

Additional error data; fields depend on the error code.

object
key
additional properties
any
Example
{
"error": {
"code": "provider_timeout",
"message": "Provider timed out",
"extra": {}
}
}

Request body, a file or the aggregate text exceeds the limit: payload_too_large, file_too_large, text_content_too_large.

Media typeapplication/json

OpenAI-format error envelope.

object
error
required
object
code
string
message
string
extra

Additional error data; fields depend on the error code.

object
key
additional properties
any
Example
{
"error": {
"code": "payload_too_large",
"message": "Request body too large",
"extra": {}
}
}

Request failed validation (validation_error): model not in <provider>/<model> form, or a missing field.

Media typeapplication/json

OpenAI-format error envelope.

object
error
required
object
code
string
message
string
extra

Additional error data; fields depend on the error code.

object
key
additional properties
any
Example
{
"error": {
"code": "validation_error",
"message": "Invalid request",
"extra": {
"errors": [
{
"type": "value_error",
"loc": [
"body",
"model"
],
"msg": "model must be in format <provider>/<model>"
}
]
}
}
}

Rate limit exceeded (provider_rate_limited).

Media typeapplication/json

OpenAI-format error envelope.

object
error
required
object
code
string
message
string
extra

Additional error data; fields depend on the error code.

object
key
additional properties
any
Example
{
"error": {
"code": "provider_rate_limited",
"message": "Rate limit exceeded",
"extra": {}
}
}

Upstream model unavailable (provider_unavailable).

Media typeapplication/json

OpenAI-format error envelope.

object
error
required
object
code
string
message
string
extra

Additional error data; fields depend on the error code.

object
key
additional properties
any
Example
{
"error": {
"code": "provider_unavailable",
"message": "Provider unavailable",
"extra": {}
}
}

Temporarily unavailable. service_unavailable and circuit_breaker_open mean load or overload protection; dlp_policy_unavailable means the DLP policy for the key could not be resolved, and the request was refused rather than run unscanned. service_unavailable and dlp_policy_unavailable carry Retry-After; circuit_breaker_open does not, because the router does not know when the backend it fenced off will be back. dlp_unavailable also lands here and carries no header either: it says the router is not enforcing DLP, so a retry returns the same answer.

Media typeapplication/json

OpenAI-format error envelope.

object
error
required
object
code
string
message
string
extra

Additional error data; fields depend on the error code.

object
key
additional properties
any
Examples

Router under load

{
"error": {
"code": "service_unavailable",
"message": "Service temporarily unavailable due to high load",
"extra": {}
}
}
Retry-After
integer

Seconds to wait before retrying.