Gateway
Gateway configuration
How a request is shaped on the way through Cran: routing headers, the compiled routing policy, caching, reliability knobs, guardrails, and budgets.
Request headers
x-cran-configworkflow-slugx-cran-routecostx-cran-context-tokensnumberx-cran-metadatajsonx-cran-no-storebooleanRouting policy
A published architecture compiles into a routing policy the gateway executes per call:
- Primary - the default model (highest measured quality from the audit).
- Fallback chain - tried in order when the primary errors.
- Cost route - an optional cheaper model selected via
x-cran-route: cost. - Conditions - per-class rules (e.g. long-context inputs route to a wide-context model).
Architecture parameters
cache_ttl_secnumber0 disables caching.request_timeout_msnumber120000.max_input_tokensnumberReliability
Retries use jittered exponential backoff and honor the provider’s Retry-After header (capped at 20s) on 429/5xx. A per-model circuit breaker pulls a repeatedly-failing model out of rotation briefly, and the fallback chain covers the rest. These apply to every modality.
Guardrails
Input and output guardrails run around each call: a maximum input-token check, optional JSON-object enforcement (when response_format is json_object), and PII checks on persisted traffic. A blocked request returns 400 with a guardrail_denied type.
Budgets & rate limits
Per-project budgets (daily / monthly spend caps) and rate limits (requests-per-minute, tokens-per-minute) are enforced before the provider call, fail-closed on a limits-service error. Over-budget returns 402; over-rate returns 429 with a Retry-After header.
# example: a rate-limited response
HTTP/1.1 429 Too Many Requests
retry-after: 60
{ "error": { "type": "rate_limit_exceeded", "message": "…" } }