Skip to content

Request paths

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

Applies to EngineCloud
View as Markdown
On this page
  1. A call
  2. A streamed call
  3. A browser call
  4. A route change

A call

  1. Who. The key or token is checked. Keys are cached for 60 seconds, so a revoked key stops working within a minute.
  2. Which route. The task’s route, at its current version, is read from a cache refreshed whenever routes change.
  3. Limits. Per-minute counters live in the gateway’s memory and are refilled in small leases from Postgres, so a limit holds across every running copy of the gateway without a database trip on each call. Caps in credits are checked against the day’s and month’s totals.
  4. Reserve. The most the call can cost is estimated and reserved: in Sypnia Cloud, as a hold on the organization’s credits.
  5. Safety. Redaction and moderation run if the route has them.
  6. Provider. The adapter turns the request into the provider’s own shape, calls it, and turns the answer back into the OpenAI shape. Fallbacks are tried as the route says.
  7. Charge. The real tokens are priced; the charge replaces the hold.
  8. Record. The call record and usage rows are written in batches every second; the span is exported in batches to Telemetry.

A streamed call

The same, except that the answer is passed to your app chunk by chunk as it arrives, while the gateway counts tokens on the way. The charge happens when the stream ends, or when your app closes it: an answer cut short is charged for what was written.

A browser call

The browser first exchanges the person’s Sypnia Data session for a browser token: the gateway checks the session’s signature with Data’s published keys, checks the page’s origin against the project’s list, and signs a token valid 10 minutes that names the project, the person and the tasks. Each call then runs as above, with the person’s limits.

A route change

PUT /routes, by a person with the owner or admin role, is validated before it is saved: the models exist and fit their inputs, tools are named, every browser route has a per-person limit, and a change of embedding model is flagged. It becomes a new version, and every copy of the gateway drops its cached routes.

  1. A call
  2. A streamed call
  3. A browser call
  4. A route change

    Search pages, sections and terms