Gateway
Name a config once and send requests through it: which model answers, what to fall back to, how often to retry, whether to answer from cache, and how fast a key may go. Run the examples under Gateway › Playground in the console, then have your agent create the one you want.
Send requests through one
Name it in the x-klinn-gateway header, make it a key's default on its page in the console, or make it your account's default gateway in the advanced gateway settings. API keys › Guardrails in the console switches the common checks on for all keys or one key, without naming a gateway at all. A model of default, or none, means the gateway's default model.
The order. A request runs under the gateway its x-klinn-gateway header names; else its key's gateway; else the account's default gateway; else none. A key with a gateway of its own is locked to it, and so is a key under an account default gateway with guardrails: a header naming another gateway is a 403 gateway_locked, and naming its own is fine. The account's default covers every own model key without a gateway of its own, so one fallback to another model or one set of guardrails covers them all. It is a chat gateway; set it with PATCH /api/v1/account { "defaultGateway": "<name>" } or the MCP tool update_account. A change reaches the router within about a minute.
curl https://api.opencheap.si/v1/chat/completions \
-H "Authorization: Bearer $OPENCHEAP_API_KEY" \
-H "x-klinn-gateway: support-bot" \
-H "Content-Type: application/json" \
-d '{ "model": "default", "messages": [{ "role": "user", "content": "Hello" }] }'It works the same on chat, messages and decisions calls. Each gateway belongs to one account; another account's names do not resolve.
Make one by asking an agent connected over MCP (each example in the console's Playground hands you the prompt, with its whole config), or from code with the Management API (/api/v1/gateways, and PATCH /api/v1/keys/{id} for a key's default). The MCP tools are create_gateway and update_key. Once it exists, its page in the advanced gateway settings (linked from API keys › Guardrails) edits its rules and keys and shows its numbers.
Two kinds
A chat gateway (kind: "chat", the default) routes the requests your code sends: they name their model, or default, and the rules below do the rest. A decision gateway (kind: "decision") is your own classifier: its default model is a decision model and it saves the questions, so a call to POST https://api.opencheap.si/v1/systemone sends only { "state": "…" } and gets the answers back; the same routing rules apply, guardrails do not (it is the check). The config, the three-line call and the console's per-question answer counts are on Decisions.
What a gateway sets
Routing. Single: the request's model, or the one model you pin. Fallback: models tried in order; when one answers with a status code you list (by default 429, 500, 502, 503 and 504), the next one answers. Load balance: each request goes to one model, by weight. A streamed answer falls back only before its first token. Within each model we still choose and fall over between providers as usual.
Speed. The default sort of the requests under it: cheapest, balanced, fastest, or a floor on tokens per second and a ceiling on seconds to the first token. It comes before the speed set on the keys that run through it, and a request's own provider.sort comes before it. See Speed.
Input:output ratio. io_ratio ranks this gateway's chat requests at the answer you expect (15, or "15:1": input tokens per output token) instead of at max_tokens. It replaces the ratio on the key. A request's own x-klinn-io-ratio header comes first. See Speed.
Retries and timeouts. Up to 5 retries a model, after 1, 2 and 4 seconds, or when the model's Retry-After says. A timeout bounds how long an answer may take to start.
Overrides. Per model: max_tokens, temperature, top_p and seed replace what the request sent.
Response cache. The exact same request gets the kept answer, for free, for the time you set (up to 24 hours). Answers are kept in memory, per account, and a restart empties them. Send x-klinn-cache: refresh for a new answer.
Limits. Requests a minute per key, and the models allowed through it (ids, or patterns with *).
Guardrails. On a chat gateway: block prompt injection, mask or block personal data, and keep to the topics you allow, checked on Decider v1.2 before the model is called. Free for now; a blocked request is a 446 and never billed. See Guardrails.
What comes back
Answers carry x-klinn-gateway, x-klinn-target (the model that answered) and, with a cache, x-klinn-cache (hit, miss or refresh), and with guardrails x-klinn-guardrail and x-klinn-guardrail-checks. Ranked at an input:output ratio, an answer also carries x-klinn-io-ratio-applied and x-klinn-io-ratio-from (request, gateway or key). Each answer is billed at its model's price. A try that failed before an answer is not billed, and a cache hit is free. Usage › Requests shows each request's gateway, the model that answered, its fallbacks and retries, and cache hits.
gateway_not_found; another gateway than the one the key is locked to, a 403 gateway_locked. A model the gateway does not allow is a 403 model_not_allowed, never answered by another model. Past its rate limit, a 429 with Retry-After.