Chat Completions
Send a conversation, get the next message. OpenAI's Chat Completions API: the OpenAI and OpenRouter SDKs call it unchanged. Set stream: true for server-sent events, which end with a usage chunk and data: [DONE].
curl -X POST https://api.llm.buzz/api/v1/chat/completions \
-H "Authorization: Bearer $LLM_BUZZ_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek/deepseek-v4.1-flash",
"messages": [
{
"role": "user",
"content": "Say hello in one word."
}
]
}'import os
from openai import OpenAI
client = OpenAI(base_url="https://api.llm.buzz/api/v1", api_key=os.environ["LLM_BUZZ_KEY"])
reply = client.chat.completions.create(
model="deepseek/deepseek-v4.1-flash",
messages=[{"role": "user", "content": "Say hello in one word."}],
)
print(reply.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.llm.buzz/api/v1", apiKey: process.env.LLM_BUZZ_KEY });
const reply = await client.chat.completions.create({
model: "deepseek/deepseek-v4.1-flash",
messages: [{ role: "user", content: "Say hello in one word." }],
});
console.log(reply.choices[0].message.content);{
"id": "chatcmpl-...",
"object": "chat.completion",
"model": "deepseek/deepseek-v4.1-flash",
"provider": "Prime Intellect",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello!"
},
"finish_reason": "stop",
"native_finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 3,
"total_tokens": 15,
"cost": 0.0000072
},
"system_fingerprint": null
}{
"error": {
"code": 400,
"message": "...",
"metadata": {
"error_type": "invalid_request",
"gateway_code": "invalid_request",
"param": "messages"
}
}
}{
"error": {
"code": 401,
"message": "A valid gateway Bearer key is required. Send the virtual key as 'Authorization: Bearer <key>'.",
"metadata": {
"error_type": "authentication",
"gateway_code": "invalid_key"
}
}
}{
"error": {
"code": 402,
"message": "...",
"metadata": {
"error_type": "payment_required",
"gateway_code": "insufficient_credits"
}
}
}{
"error": {
"code": 404,
"message": "The requested model does not exist or is not granted to this key. GET /api/v1/models lists the model aliases available to this key.",
"metadata": {
"error_type": "not_found",
"gateway_code": "model_not_found",
"param": "model"
}
}
}{
"error": {
"code": 409,
"message": "...",
"metadata": {
"error_type": "invalid_request",
"gateway_code": "idempotency_replay_unavailable",
"param": "Idempotency-Key"
}
}
}{
"error": {
"code": 429,
"message": "...",
"metadata": {
"error_type": "rate_limit_exceeded",
"gateway_code": "unavailable_route"
}
}
}Authorization
An inference key, as Authorization: Bearer KEY.
Parameters
Idempotency-KeystringheaderA retry with the same key and the same body never runs the request twice: it returns the first answer, or 409
idempotency_replay_unavailablewhen that answer is not stored where the retry arrived. Send the same key again only when the first call got no answer, or after an answer carryingx-gateway-admission-refused: true; after any other error answer send a new key. A retry without the key, or with a new one, runs and bills the request again. Reusing a key with a different body answers 409idempotency_conflict.x-session-idstringheaderNames the conversation, as
session_iddoes, so its turns stay on the provider that holds its cache.
Body application/json
modelstringrequiredA model's name from
GET /api/v1/models, such asdeepseek/deepseek-v4.1-flash. A suffix changes one request::floortries the cheapest provider first and:nitrothe fastest. On Chat Completions and Responses:onlineasks for a web search, which llm.buzz does not run today: the request is served without one andx-sgr-ignored-parametersnamesweb_search->dropped(search_unavailable), or for an organization whose requests llm.buzz keeps in the EU it answers 400web_search_unavailable_in_region. On Messages:onlinedoes nothing and is named asmodel:online.messagesobject[]requiredThe conversation, as OpenAI's message objects:
system,user,assistantandtoolroles. A user message may carryimage_urlparts for models that read images, and atextpart may carryprompt_cache_breakpoint, OpenAI's explicit cache mark.streambooleandefault falseStream the answer as server-sent events.
max_tokensintegerThe most tokens the answer may use. Also bounds what the request holds of your balance while it runs.
temperaturenumberSampling temperature. A model that takes none drops it and names it in
x-sgr-ignored-parameters.toolsobject[]Functions the model can call, in OpenAI's shape.
{"type": "openrouter:tool_search"}declares a tool search, and a tool withdefer_loading: truebesidefunctionwaits for it.tool_choicestring or objectauto,none,required, or an object naming one function.response_formatobject{"type": "json_schema", ...}asks for an answer in a JSON schema;{"type": "json_object"}for any JSON object.reasoningobjectReasoning controls, translated for each provider.
Show 4 child fields
effortstringHow hard the model thinks. An effort the model does not take becomes the nearest one it does, named in
x-sgr-ignored-parameters.max_tokensintegerA reasoning budget in tokens.
enabledbooleanTurn reasoning on or off.
excludebooleanKeep the reasoning text out of the answer while the model still reasons.
include_reasoningbooleanOpenRouter's older switch:
trueisreasoning: {},falseisreasoning: {exclude: true}.providerobjectSteers one request across the model's providers. With the OpenAI SDK, send it in
extra_body. Every field acceptsnull. A name matches a provider's display name, its tag or the tag's first part, ignoring case:llm.buzzorllm-buzznames llm.buzz's own provider, andllm-buzz/euonly its capacity in the EU.Show 7 child fields
orderstring[]Try these providers first, in this order, then the others. At most 64 names.
onlystring[]Use only these providers.
ignorestring[]Never use these providers.
allow_fallbacksbooleanfalsestops moving to other providers.sortstringThe order to try providers in. Ignored when
orderis set.pricethroughputlatencysmartzdrbooleantruekeeps the request on providers that declare 0 days of retention.data_collectionstringdenykeeps the request on providers that declare no training and 0 days of retention.allowdeny
session_idstringA name for the conversation, 1 to 256 characters, so its turns stay on the provider that holds its cache.
cache_controlobjectAnthropic's prompt-cache marker,
{"type": "ephemeral"}with an optionalttlof"5m"or"1h". llm.buzz passes it on and never adds one. Claude models cache only where a request marks it.prompt_cache_optionsobjectOpenAI's explicit caching, for GPT-5.6 and later models:
modeimplicit(OpenAI's default) orexplicit(OpenAI writes the cache only at aprompt_cache_breakpoint), andttl30m.prompt_cache_retentionstringOpenAI's cache retention.
24hwithprovider.zdr,provider.data_collection: "deny"or your organization's no-retention policy is a 400invalid_request.in_memory24hweb_search_optionsobjectAsks for a web search, as the
:onlinesuffix does. llm.buzz runs none today: the request is served without a search, nothing is billed for one, andx-sgr-ignored-parametersnames it asweb_search->dropped(search_unavailable). An organization whose requests llm.buzz keeps in the EU gets 400web_search_unavailable_in_regioninstead.
Response 200
The answer. provider names the provider that answered, and usage.cost is the request's cost in US dollars when every part of it is known.
idstringThe completion's ID.
modelstringThe model that answered.
providerstringThe display name of the provider that answered, after any failover:
llm.buzzfor llm.buzz's own provider.choicesobject[]The answer.
message.reasoningcarries readable reasoning when the model returns it, andmessage.imagesthe images a model that makes images returns.usageobjectToken counts; cache reads in
prompt_tokens_details.cached_tokensand writes in itscache_write_tokens(cache_write_1h_tokensfor the one-hour part, when the provider reports it); andcostin US dollars. Omitted when the provider reported no counts.x-sgr-ignored-parametersstring[]Fields llm.buzz dropped instead of failing the request, such as
temperature->dropped(unsupported_by_provider).
Errors
400A field is missing or malformed (
invalid_request, withmetadata.param), or the model cannot do what the request asks (unsupported_capability).401No key, or the key is unknown, expired, revoked or disabled.
402Your balance is spent and the model is not free, or the request could cost more than your balance.
404No model has this name, or your key may not call it.
409The
Idempotency-Keywas used before.idempotency_replay_unavailable: the first request was accepted, and its answer is not stored where this retry arrived, so it was not run again; retry with the same key after a short backoff first, when the first call got no answer, and send a new key to run the request again (it is billed again) or after an error answer.idempotency_conflict: the key came with a different body; use a new key for each distinct request. Neither runs the request again.429Providers are throttling, or the model is at capacity (
unavailable_route): retry afterRetry-Afterseconds. Or a free offer's allowance is used (free_allowance_exceeded): your organization's tokens, or your key's requests per minute. Choose a paid model, or for the per-minute limit retry afterRetry-Afterseconds.