
One Rust binary, every request.
The Kaeso gateway sits between your apps and your providers. It checks every key and limit, translates every format and logs every request.
Follow one request.
Eight steps between your app's request and its reply, and what the app gets when one of them refuses it.
Key
The API key decides the project and the member or service account it acts for. Keys are stored only as hashes and answered from memory for 30 seconds.
What the app can get
- 401UnauthorizedUnauthorizedThe key is missing, unknown, disabled, archived or expired.
- 403ForbiddenForbiddenThe key has no inference access, or its member lacks the right
api.request. - 429Rate limitedRate limitedToo many requests with unknown keys came from the same address.
The gateway reads the key from
x-api-key, or else fromAuthorization: Bearer:Decode
KPP decodes the body from the app's format into Kaeso's canonical format. Anything Kaeso never sends to a provider is refused here.
What the app can get
- 413Too largeToo largeThe body is larger than 32 MiB, the default limit.
- 400Bad requestBad requestKaeso can't read the request, or it asks for something Kaeso never sends, such as more than one choice.
- 503UnavailableUnavailableRequests being translated already use the memory set aside for them, and this one waited 10 seconds. In the Anthropic format the status is 529.
Both limits are settings; these are their defaults:
Model
The name resolves in the project's catalogue, where an alias's route chooses the model and its fallbacks, and the request is checked against the model's capabilities before anything is sent.
What the app can get
- 404Not foundNot foundThe model isn't in the project's catalogue, or the key may not use it. Both answer alike, so a key can't learn which other models exist.
- 400Bad requestBad requestSeveral providers serve the id, or the model lacks something the request needs, such as tools or images.
The same 404 in each format, so every SDK raises its usual error:
Limits
Every rate and budget of the key, the member and the project is checked at once in Valkey. Over a limit, the app gets 429, and the message names the limit.
What the app can get
- 429Rate limitedRate limitedA rate or a hard budget is reached. For a rate,
Retry-Aftersays when to try again; for a budget, the message says when it resets. - 403ForbiddenForbiddenA spend budget applies, and the request uses something Kaeso can't price, such as a provider-run tool or a model without a price.
- 200OKOKA soft budget is passed. The request goes on, and the budget only alerts.
- 503UnavailableUnavailableValkey can't be reached and the request falls under a hard budget, or the project's limits can't be loaded. The OpenAI formats answer 500.
A rate limit's
Retry-Aftergives the wait in whole seconds, rounded up:- 429Rate limitedRate limitedA rate or a hard budget is reached. For a rate,
Provider key
The project's key for the provider is chosen and decrypted, and kept only in memory for at most 30 seconds.
What the app can get
- 400Bad requestBad requestThe project has no provider key for the model's provider.
- 500Server errorServer errorKaeso can't decrypt the provider key.
Generate a new master key, write it in front of the old one in
master-keys, recreate the gateway, thenrewrapmoves every stored secret to it:Encode and send
KPP encodes the request for the provider's format, and what that format can't express is refused. In a project with the response cache on, a repeated identical request is answered from Valkey instead.
What the app can get
- 400Bad requestBad requestThe provider's format can't express what the request asks for.
- 502Bad gatewayBad gatewayThe provider can't be reached, or it refused the project's provider key.
- 504Gateway timeoutGateway timeoutThe provider didn't answer in time.
A provider that refuses the project's key gets your app a 502 that asks for an admin, never the provider's 401:
Reply
The reply is decoded and encoded in the app's format, event by event for a stream, with the
kaeso-modelandkaeso-providerheaders.What the app can get
- 200OKOKThe reply in the app's own format, with the model and provider that served it.
- 529OverloadedOverloadedThe provider is overloaded: 529 in the Anthropic format, 503 in the OpenAI formats.
Every answer names the request, and once the model is known, who served it:
Log
Usage, the cost at the prices in force when the request was made, and the request log are recorded, with the content when both the organization and the project log it, and its images, audio and files only when both keep media.
What the app can get
- 200OKOKLogging never holds a request up: the reply goes out first, and log entries wait in memory.
- 499Client closedClient closedThe app closed the connection. Kaeso stops the provider request at once and charges what was used.
Log rows wait in memory and go to ClickHouse in batches:
Inside the gateway.
Keys that stay in the gateway, state in stores you already run, and a service you operate like any other.
01
Keys stay in the gateway
Provider keys never reach your apps, and every action in the console is checked against one right.
A Kaeso key, stored only as a hash, with an optional expiry and access to models, the Platform API or the project's tools.
Provider keys, envelope-encrypted with AES‑256‑GCM under a master key ring you hold. Rotate the master key with kaeso master-key rewrap.
- Sign-in
- Password with an authenticator app and recovery codes, sign-in links, and single sign‑on through each organization's OIDC provider
- Rights
- Fine-grained rights with built-in roles and up to 50 custom roles per organization
- Audit logs
- For the instance, every organization and every project
02
State in stores you know
Gateway instances keep nothing of their own, so you add more behind your load balancer. They share one PostgreSQL and one Valkey, and ClickHouse for request logs, which you can also turn off.
- PostgreSQL
- Keys, catalogue, limits, usage and audit logs
- ClickHouse
- Request logs and their content
- Valkey
- Rate and budget counters, shared caches
03
Run it like any service
Configure it with environment variables or a TOML file, read every secret from a file, and watch it with the tools you already run.
- Metrics
- Prometheus on port
9100, which Caddy doesn't route; keep it private - Health
/healthzwhile the process runs, and/readyzwith the state of PostgreSQL, Valkey and ClickHouse- Logs
- Structured JSON, and request logs kept 90 days, content 30 days, by default
- Streams
- Keepalives after 15 seconds of silence; the provider call is cancelled when the app goes away
One repository, one version.
The gateway, the console, KPP and Kaeso UI ship together, MIT licensed.
- Gateway (opens in a new tab)
The kaeso binary: the Model API, the Platform API, migrations and admin commands.
ghcr.io/logicplanes/kaeso-gateway - Console (opens in a new tab)
The web console, built with React 19 and only Kaeso UI.
ghcr.io/logicplanes/kaeso-console - KPP (opens in a new tab)
The Kaeso Provider Protocol and its codecs, on crates.io.
kaeso-kpp, kaeso-codecs - Kaeso UI (opens in a new tab)
The component library every Kaeso screen and this site are built from.
@logicplanes/kaeso-ui

In front of every app.
One Compose file with Caddy, the gateway, the console, PostgreSQL, ClickHouse and Valkey, on your own servers.