Architecture
How Sypnia AI is built: the gateway's parts, where Rust runs, and how they connect.
- Your app, or a Sypnia product, calls the API with a task.
- The router reads the task’s route: model, fallbacks, instructions, options.
- Limits are checked and the most the call can cost is reserved; after the call, the real cost is charged.
- The call goes to the provider, and the answer streams back.
- The call becomes a span in Telemetry; its record and usage go to Postgres and, in Sypnia Cloud, to your credits.
Read this diagram as text
The gateway is one Rust binary with the API, the router, the limiter and meter, the safety checks, the provider adapters, the OpenTelemetry exporter and the MCP server. It keeps routes, keys, limits, call records and usage in Postgres. Object storage is used only for what a route chose to keep and for the response cache.
| Part | Language | Open source |
|---|---|---|
| Gateway: API, router, limiter and meter, safety, provider adapters, exporter, MCP | Rust (axum, tokio, reqwest; the AWS SDK for Bedrock) | yes, AGPL-3.0 |
@sypnia/ai and the ai command | TypeScript | yes, MIT |
| Credits ledger and billing | the suite’s shared ledger | no |
Console (ai.app.sypnia.com) | TypeScript (React) | no |
Why Rust
Every model call of the suite passes through the gateway, and many are long streams. Rust keeps the time the gateway adds to a call to a few milliseconds, holds thousands of open streams in little memory, and makes the code that counts credits hard to get wrong.
What happens inside the gateway for a call, a streamed call, a browser call and a route change.
The tables of the gateway's Postgres schema and what each holds.
Reference implementation on AWS
Every AWS service Sypnia AI uses in Sypnia Cloud, and how.
What happens when a provider, the database, the ledger or a copy of the gateway fails, and how it grows.
How the open-source repository is organized.