Skip to content

Architecture

How Sypnia AI is built: the gateway's parts, where Rust runs, and how they connect.

Applies to EngineCloud
View as Markdown
Figure. Sypnia AI: your app and Sypnia's products call the gateway; routes choose the model, limits and the meter guard the credits, and every call becomes a span.
  1. Your app, or a Sypnia product, calls the API with a task.
  2. The router reads the task’s route: model, fallbacks, instructions, options.
  3. Limits are checked and the most the call can cost is reserved; after the call, the real cost is charged.
  4. The call goes to the provider, and the answer streams back.
  5. 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.

PartLanguageOpen source
Gateway: API, router, limiter and meter, safety, provider adapters, exporter, MCPRust (axum, tokio, reqwest; the AWS SDK for Bedrock)yes, AGPL-3.0
@sypnia/ai and the ai commandTypeScriptyes, MIT
Credits ledger and billingthe suite’s shared ledgerno
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.

  • Request paths

    What happens inside the gateway for a call, a streamed call, a browser call and a route change.

  • Data model

    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.

  • Failures and scaling

    What happens when a provider, the database, the ledger or a copy of the gateway fails, and how it grows.

  • Codebase

    How the open-source repository is organized.

    Search pages, sections and terms