Gateway configuration reference
Every gateway has a config JSON object that controls authentication, caching, timeouts, security, routing, and provider settings. Update it with PATCH /admin/v1/gateways/{id}.
💡 Note: This page covers the configuration of a gateway. The platform-wide settings that a platform administrator manages (for example the reranker, the sign-up limits, and the integration secrets) are not gateway configuration; every key is listed with its type and default in the Global settings API.
The config is merged at the top level on each PATCH — only the fields you include are changed. Nested objects (rate_limit) are replaced in full when provided.
🔑 Reading the config back — credential fields are role-scoped.
GET /admin/v1/gateways/{id}and the tenant gateways listing are open to any member of the tenant, so the third-party credential fields below —web_search.api_key,semantic_cache.embedding_api_key,webhooks.secret,siem.token/siem.passwordandtracing.headers— are write-only: no caller receives them, a<leaf>_setboolean is shown instead, and a save that omits one keeps it. A reader holdingGATEWAYS_MANAGEstill receives the non-secretsiemkeys; a reader without it gets the wholesiemblock withheld as before. See the read-scoping note in the gateways API reference.
Full default config
{
"auth_required": true,
"budget_usd": null,
"budget_period": "monthly",
"tenant_spend_cap_usd": null,
"cache_ttl": 0,
"retry_count": 2,
"timeout_ms": 60000,
"log_payloads": true,
"rate_limit": null,
"ip_allowlist": [],
"guardrails": [],
"circuit_breaker": null,
"webhooks": null,
"siem": null,
"azure_endpoint": null,
"azure_deployment": null,
"azure_api_version": "2024-02-01",
"azure_resource": null,
"bedrock_region": "us-east-1",
"vertex_project": null,
"vertex_region": "us-central1",
"cf_account_id": null,
"hf_endpoint": null,
"provider_base_urls": {},
"provider_allowlist_enforced": false,
"provider_allowlist": [],
"tracing": null,
"web_search": null,
"semantic_cache": null,
"agentic_fetch": null,
"url_fetch": null,
"av_scan": null,
"prompt_caching": { "enabled": true, "ttl": "1h" },
"context_compaction": {
"enabled": true,
"threshold_tokens": 200000,
"keep_last_turns": 10
}
}
Core fields
| Field | Type | Default | Description |
|---|---|---|---|
auth_required |
boolean | true |
Require a valid x-aig-token, Authorization: Bearer, or x-api-key header on all inference requests. Set to false only for development. |
budget_usd |
number | null | null |
Gateway-level spend cap in USD for the current budget period. Blocks all requests once exhausted. null = no cap. |
budget_period |
string | "monthly" |
Period over which gateway spend is accumulated. One of: "daily" (resets each day at midnight UTC), "monthly" (resets on the first of each calendar month, 00:00 UTC), "total" (lifetime, never resets). Any other value is rejected 400 by the admin API (create, and a PATCH that touches the budget). |
test_headers_allowed |
boolean | absent | Reserved for Myra's test tooling; never set on a customer gateway. Platform-admin-only: on a config write by any other actor (a tenant admin, or a custom role holding GATEWAYS_MANAGE) the submitted value is ignored and the stored value kept — on PATCH and on a POST to an existing slug alike, so no one below a platform admin can arm or disarm a gateway — and the 2xx response then carries "ignored_fields": ["test_headers_allowed"] when the dropped value differed from the stored one (omitting the field, or re-sending the stored value, is a plain no-op). A platform admin's value is applied as sent; a platform admin's non-boolean value that differs from the stored one is rejected 400 ("test_headers_allowed must be a boolean"). |
tenant_spend_cap_usd |
number | null | null |
The tenant's self-imposed monthly spend cap in USD, folded (read-only) onto every gateway of the tenant from tenant.spend_cap_usd. Applies across all gateways belonging to the tenant, in addition to the always-on wallet gate (a turn is admitted only while the wallet holds money and is not frozen). null = no cap (unlimited within the wallet); 0 = a deliberate freeze-all. The window is a fixed monthly ceiling — there is no tenant-level period field. Set it via PATCH /tenants/{id} → spend_cap_usd, not in the gateway config JSON. (The former enforced tenant_budget_usd / tenant_budget_period fold was retired with the wallet money-model rework.) |
budget_alert_pct |
number | null | 0.8 |
Soft-alert threshold as a fraction of the budget cap: when current-period spend crosses this fraction of any configured budget (token / tenant / gateway) without being over it, a proactive budget_threshold signal fires once — a budget_threshold webhook (if webhooks is configured) plus an ops notification (log + operator alert e-mail + alert webhook + Mattermost). This is advisory only and never blocks the request; the hard stop still happens at 100%. Must be a number in the open interval (0, 1); 0 disables the soft alert; null, absent, or any out-of-range/non-number value falls back to 0.8 (fail-safe read). The crossing is recorded in the database and each of the two signals is sent once across all gateway nodes per (scope, entity, period, cap); a new period or a changed budget re-arms it. A signal that cannot be sent at once (its background task cannot start or is dropped, the node restarts, a database fault) is sent by a background sweep about a minute later, marked late; if the database is unavailable when the threshold is crossed, nothing is sent and the node tries again on a request at least 60 seconds later — see Soft-threshold alerts. Note: the SPA's "Spend cap warnings" badge is fixed at 80% and is independent of this knob (it changes only the webhook/notification timing, not the badge). |
pii_masking_enforced |
boolean | false |
Tenant-level. When true, PII masking is mandatory for every user of the tenant: the chat privacy toggle is locked, the client hint_pii_preference opt-out is ignored, routing is forced through a PII-masking gateway (or the request is rejected fail-closed), manual unmask is denied, and every third-party tool egress (web search, fetch_url, MCP arguments) is scrubbed or blocked. A wholly-local (Myra/EU) model leg — the resolved primary and every failover fallback first-party — is never masked on the model input (masking a first-party leg protects nothing and corrupts the user's own data); its tool egress is still guarded, and agent-invoke output (delivered externally) always masks. If any provider in the egress set is external, the leg is masked fail-closed. Set on the tenant, not per-gateway; a platform admin writes it through PATCH /admin/v1/tenants/{id} (see the tenants API). See PII Protector → tenant-enforced masking. |
cache_ttl |
integer | 0 |
Response cache TTL in seconds, a whole number from 0 to 9007199254740991 (2^53 - 1, the largest whole number a 64-bit double holds exactly; every whole-number limit below that reads "no product cap" uses the same ceiling). 0 disables the cache. Anything else is refused on write with 400; null or absent = 0; a legacy stored malformed value is read as 0 (logged). The key covers tenant, gateway, provider, model, the canonical body and the scoping headers; see Response caching. |
retry_count |
integer | 2 |
Maximum number of retry attempts against the primary provider on a retryable status (500, 502, 503, 504, or 429 — the last honouring the Retry-After / Retry-After-Ms header) before the fallback chain is walked. A whole number from 0 to 5; anything else is refused on write with 400; null or absent = 2; a legacy stored malformed value is read as 2 (logged). |
timeout_ms |
integer | 60000 |
Per-upstream-request timeout in milliseconds, a whole number from 1 to 3600000; anything else is refused on write with 400, and a legacy stored malformed value is read as 60000 (logged). Applies to each attempt individually, not the total request time. Bounds the request send (a matching rule's timeout_ms replaces it) and, for a provider call made non-streamed, the wait for the answer — see Gateways → Timeouts for the exact precedence with routing-rule timeouts and built-in budgets. The TCP connection and the TLS handshake are each bounded separately by 5 s (or by timeout_ms when that is smaller), and DNS resolution by the resolver's own timeout, so an unreachable address cannot consume the whole timeout; when a provider host resolves to several addresses the gateway tries the next one (IPv4 first) within that connection bound (each address gets at most half of it, and DNS resolution, up to about 2 s, happens outside it). The admin UI pre-fills 120000 when a gateway is created; the 60000 default applies when the key is absent or null. For the built-in Myra fleet the TCP connect and the TLS handshake are each bounded by a fixed 5 s, neither shortened nor widened by timeout_ms, and a timeout under a deadline shorter than 20 s is not counted against the shared Myra circuit breaker (see Circuit breaker). |
log_payloads |
boolean | true |
Store request and response bodies in the log table, and the turn replay record. Also gates trace-step content: tracing.include_bodies stores bodies only while this is on. Disable for sensitive workloads where prompt/response content must not be persisted. Must be a JSON boolean (null/absent = true); any other value is rejected with 400, and a legacy stored non-boolean is read as false. While it is false, an agent schedule on this gateway that requires approval before delivery is refused when it is created, enabled, has approval turned on, gets a new destination, or is run now (approval_undeliverable_payload_logging) and existing ones are flagged (approval_blocked) — an approved result is re-read from the stored payload. |
max_parallel_tools |
integer | — | Maximum number of tool calls the gateway runs in parallel within one assistant turn. Overrides the built-in limit of 4 (lower or higher): a whole JSON number from 1 to 9007199254740991 (2^53 - 1, the largest whole number a 64-bit double holds exactly; a precision bound, not a product cap); null or absent = the default 4. Anything else (a string such as "5" or "inf", 0, a negative or fractional number, a boolean, an object) is refused on write with 400; a legacy stored malformed value is read as 4 (logged), never as unlimited. The same limit bounds how many byte-identical repeats of one tool call a single streamed completion may contain before the gateway stops it, so a higher value widens that bound. |
Rate limiting
| Field | Type | Default | Description |
|---|---|---|---|
rate_limit |
object | null | null (disabled) |
Gateway-level sliding-window rate limit applied to all callers. Default: null (disabled). Example: {"requests": 100, "window_sec": 60}. Per-token limits are checked independently — a request can be blocked by either limit. Accepted shape (validated on POST /gateways and PATCH /gateways/{id}): a JSON object whose only keys are requests and window_sec, or null to clear. Rejected with 400: a string, number, boolean or array; an unknown key (a typo such as reqs used to be stored and silently mean 100 per 60 s); a requests / window_sec that is not a whole number ≥ 1 (a string "100", 0, a negative or fractional value, nan/inf) or above the ceilings (requests ≤ 1,000,000,000; window_sec ≤ 31,536,000 — one year). A key sent as null is treated as omitted and is not stored. At request time, a stored value the gateway cannot use — not an object (a string, number, boolean or array), or a present requests / window_sec that is not a whole number in range — makes the gateway refuse every request with 500 configuration_error and log the reason once per worker (until the value is corrected) — never "no limit" and never a crash per request. A row written before this validation existed is otherwise served as-is: extra keys are ignored at read, a null key takes the default. |
rate_limit.requests |
integer | 100 |
Maximum requests allowed in the window. Used when rate_limit is set but this field is omitted or null. |
rate_limit.window_sec |
integer | 60 |
Window duration in seconds. Used when rate_limit is set but this field is omitted or null. |
⭐ Example:
IP allowlist
| Field | Type | Default | Description |
|---|---|---|---|
ip_allowlist |
array of strings | [] |
CIDR blocks permitted to call this gateway. An empty array allows all source IPs. Requests from IPs outside the list return 403 forbidden — checked right after authentication, before rate limits and budgets, without waiting for or parsing the request body. A stored value that is not an array (a single string, a number, a non-empty object) refuses every request that passes authentication on the inference API (/v1, /copilot/v1, /direct/v1) with 500 configuration_error (never read as "allow all"); an entry that is not a valid CIDR string never matches. See IP allowlist. |
⭐ Example:
Guardrails
| Field | Type | Default | Description |
|---|---|---|---|
guardrails |
array | [] |
Ordered list of guardrail configs. Evaluated in array order within each tier. First block verdict short-circuits the pipeline. |
💡 Note: The legacy key
detectorsis still accepted as a fallback, but only whenguardrailsis absent (the key is missing) or the booleanfalse. A present-but-nullor otherwise non-arrayguardrailsvalue takes precedence and resolves to zero detectors (it does not fall back todetectors). New configurations should useguardrails.
Each guardrail object has a common set of fields plus type-specific fields:
| Field | Type | Description |
|---|---|---|
type |
string | Guardrail type: regex, keyword, jailbreak, json_schema, contains_code, gibberish, language, custom_pii, presidio, prompt_guard, pii_protector. |
name |
string | Human-readable name used in block messages and logs. |
action |
string | One of block, scrub, or flag. |
target |
string | One of request, response, or both. |
See the Guardrail Pipeline page for full per-type field documentation.
💡 Note:
guardrail_baselineandguardrails_fail_closedare organisation-level settings (see Tenant guardrail baseline and fail-closed switch), not gateway fields. The gateway read views includeconfig.guardrail_baselineas a read-only copy so that clients see the full effective detector list. When a gatewayPOST/PATCHsends either key back inconfig, the key is removed before the write. It is never stored on the gateway and never causes an error. The guardrail-config import rejects both keys as unknown.
Role policies
The role_policies block makes the guardrails and the model allowance of a gateway stricter for individual user roles. A role policy can only tighten the gateway configuration: it adds detectors to the base guardrails list and narrows the set of models. A role policy never removes a base detector and never allows a model that the gateway base does not allow. The role comes from the signed-in account on the server, never from client input. The Edit Gateway dialog has no editor for this block; set it with PATCH /admin/v1/gateways/<ID>.
| Field | Type | Default | Description |
|---|---|---|---|
role_policies |
object | null | absent | An object keyed by a system role (admin, tenant_admin, ki_manager, member, viewer, demouser, finance) or default. The default entry applies to every role without its own entry, including requests without a user. A role uses its own entry if one exists, else the default entry, else the gateway base. Custom roles never match. The block is replaced in full on each PATCH. |
role_policies.<ROLE>.guardrails |
array | — | Extra detector objects in the same shape as guardrails. A detector applies to the request when its target is request or both, and to the response when its target is response or both. |
role_policies.<ROLE>.models |
array of strings | — | The bare model IDs the role may use. The list is intersected with the models the gateway allows. An empty list denies every model. A request for a model outside the list is refused with 403 role_model_not_allowed. |
Accepted shape (validated on POST /gateways, PATCH /gateways/{id}, and the guardrail-configuration import): an object keyed by role name, each value an object or null. Rejected with 400: a role_policies value that is not an object (role_policies must be an object), a JSON array (role_policies must be an object keyed by role name (not an array)), an entry that is not an object (role_policies['<ROLE>'] must be an object), and a key that is neither a system role nor default (unknown role_policies key(s): <KEYS> (must be a system role or 'default')). A typo in a role name would otherwise never match and silently lose the intended restriction.
⭐ Example:
"role_policies": {
"viewer": { "models": ["qwen3.8-27b"] },
"default": { "guardrails": [ { "type": "jailbreak", "name": "Jailbreak", "action": "block", "target": "request" } ] }
}
Complexity routing
The laya_routing field controls complexity routing for Auto turns. When it is active, a classifier hosted by Myra rates each prompt of a turn that uses the Auto model choice. A prompt rated hard is sent, for that turn only, to the highest-quality eligible Anthropic model of the gateway. Easy and medium prompts are never changed. An explicit model choice of the user is never overridden. The model that answered is reported in the X-AIG-Model response header.
| Field | Type | Default | Description |
|---|---|---|---|
laya_routing |
string | null | absent (off) |
One of off, shadow, or live. shadow rates each prompt and logs the result without changing the model. live changes the model of hard prompts. null clears the field. Platform-admin-only: on a config write by any other actor, the submitted value is ignored, the stored value is kept, and the 2xx response carries "ignored_fields": ["laya_routing"] when the dropped value differed from the stored one. A platform admin's value outside the three strings is rejected 400 (laya_routing must be one of: off, shadow, live). |
Provider-specific fields
Azure OpenAI
| Field | Type | Default | Description |
|---|---|---|---|
azure_endpoint |
string | null | null |
Azure OpenAI endpoint used by the openai provider path: when set, OpenAI-provider requests are sent to this value with the request's provider path and ?api-version=… appended verbatim, authenticated with api-key (see Azure for the expected form). The dedicated azure provider uses azure_resource / azure_deployment instead. Routed through the same SSRF guard as provider_base_urls: it is resolved once and the dial IP is pinned; a value resolving to a private/internal address is rejected at dispatch. Validated at save time (POST/PATCH): null or absent = no custom endpoint; otherwise a non-empty http(s):// URL without userinfo / whitespace / control characters, else 400. A malformed stored value fails the request with configuration_error (never a fall-back to the default endpoint). Only this gateway's own key is sent to it; changes are audited (gateway.endpoint_config_changed). |
azure_resource |
string | null | null |
Azure resource name. An alternative to azure_endpoint: the gateway builds the URL https://<resource>.openai.azure.com/… from the resource name and azure_deployment. Accepted: a bare vendor label (1–63 chars, alphanumeric plus -/_, starting alphanumeric). Rejected: any value with a dot, slash, colon, @, or whitespace — these would break out of the host authority and are refused — at save (400) and, for a value stored earlier, at request time (configuration error). null = absent. For the azure provider the resource is required: absent, null or empty is refused with a configuration error and nothing is sent upstream (there is no default resource). |
azure_deployment |
string | null | null |
Azure deployment name. Replaces the model name in the request URL path. Accepted: a single path segment (may contain dots/-/_). Rejected: any value with a slash, ?, #, \, :, @, or whitespace (path/query injection) — at save (400) and, for a value stored earlier, at request time (configuration error). null = absent (the request's model is used). |
azure_api_version |
string | null | path-dependent | Azure OpenAI API version appended as the ?api-version= query param. Defaults to "2024-02-01" on the OpenAI-provider path (a gateway with azure_endpoint set) and to "2024-10-21" on the dedicated azure provider path. null means the default; any other value must be a version token (letters, digits, ., -; at most 32 characters) — a malformed value fails the request with configuration_error instead of being appended to the URL. |
AWS Bedrock
| Field | Type | Default | Description |
|---|---|---|---|
bedrock_region |
string | "us-east-1" |
AWS region for Bedrock API calls. Used in SigV4 request signing. |
Google Vertex AI
| Field | Type | Default | Description |
|---|---|---|---|
vertex_project |
string | null | null |
Google Cloud project ID. Required for Vertex AI; if unset, falls back to a deployment-wide default project set by your operator. If neither is set the request fails closed with a configuration_error (no empty-project URL is dialed). |
vertex_region |
string | "us-central1" |
Google Cloud region for Vertex AI API calls. Falls back to a deployment-wide default region when unset. |
Data residency (EU model hosting)
For deployments where model data must stay in the EU (a hard requirement in
regulated / public-sector tenders), a gateway can be put into EU-region
routing mode. When enabled the gateway fails closed: any request whose
provider is not on the EU-owned provider list is rejected with HTTP 403
(data_residency_blocked) — it is never sent to that provider.
| Field | Type | Default | Description |
|---|---|---|---|
eu_region_routing |
boolean | false |
When true, only EU-owned providers may serve this gateway. A non-boolean value is rejected with 400 naming the field (absent or null is accepted); an unchanged legacy echo is accepted. A legacy stored value folds three ways at load: recognized-ON (true, 1, "true", "yes", "on") enforces, recognized-OFF (false, 0, "false", "no", "off") is off, an unrecognized one is off plus a WARN (value escaped in the log) -- unless the tenant floor forces it on. The guardrail-config export writes the effective boolean. |
What counts as EU residency — one ownership-based list (fail closed):
- Myra-hosted models (
myra/vllm) — run on the on-prem Myra EU estate. - Mistral AI (
mistral, France) — the gateway calls only Mistral's EU-hosted endpoint (api.mistral.ai, EU by default); it never enables Mistral's opt-in US endpoint. (Requires a Mistral API key configured for the gateway.) - IONOS AI Model Hub (
ionos, Germany) — the adapter's only built-in host is IONOS's Berlin endpoint (openai.inference.de-txl.ionos.com). (Requires an IONOS API token configured for the gateway.)
EU residency means an EU-owned and EU-hosted provider, not an EU region of a US-owned
cloud. AWS Bedrock, Google Vertex and Azure OpenAI are US-owned clouds: they are refused
under enforcement in every region — eu-central-1, europe-west3, westeurope and every
other EU region included, whatever the model id. Their region settings (bedrock_region,
vertex_region) only choose which endpoint the adapter dials; they never make the route EU
residency. Everything else is refused too — the native anthropic / openai / gemini
adapters, any US SaaS provider, OpenRouter, custom providers. A per-provider
provider_base_urls override is also rejected under enforcement, even for an EU-owned
provider (the gateway cannot vouch for an arbitrary host).
The model picker's hosting label (hosted_in: Myra / EU / US) is derived from the same
list, so a model shows EU exactly when its provider is EU-owned; Bedrock, Vertex and Azure
models show US in any region.
The guarantee holds on every model dispatch path, not just the primary
request. The check sits at the single upstream dispatch chokepoint, so the same
fail-closed refusal applies to the primary attempt and every failover
attempt, each tool-loop leg and the agentic-fetch inner call — all of
which funnel through that one chokepoint. The conversation summarize call and
the provider Files API upload (POST /chat/files without text extraction),
which dial outside that chokepoint, apply the same check themselves and answer
the same 403 data_residency_blocked before anything is sent. It
also covers the web-search query egress (a non-EU search provider such as
Brave is blocked; only an EU provider such as Linkup may receive the
model-generated query, and provider-native search is forced through the EU
two-leg), so an armed gateway can turn web search off but never silently fall back
to a US search backend. Embeddings and image generation are served solely
by the on-prem Myra EU fleet (MYRA_BASE_URL) and never reach a commercial US
provider. Net effect on an armed gateway: no user request — on any path — reaches
a US region; a US route is refused before any network call rather than
egressing.
A deployment-wide default is available as an operator-only setting, applied on the sovereign/EU stack. It is not applied on a shared stack, because it would flip every gateway to enforced and 403 existing US-routed gateways.
EU-hosted model names
Three vendor-independent EU model routes are available:
| Route | Provider | EU models |
|---|---|---|
| Myra-Eigenbetrieb | myra / vllm |
On-prem EU inference fleet (chat, embeddings, image generation). |
| Mistral AI | mistral |
mistral-large-latest, mistral-small-latest, codestral-latest, … — EU host api.mistral.ai. |
| IONOS AI Model Hub | ionos |
openai/gpt-oss-120b, meta-llama/Llama-3.3-70B-Instruct, mistralai/Mistral-Small-24B-Instruct, Qwen/Qwen3.8-27B, Qwen/Qwen3.5-9B, Qwen/Qwen3.5-397B-A17B — Berlin host openai.inference.de-txl.ionos.com. |
Anthropic Claude, OpenAI GPT and Google Gemini models have no EU-residency route: on Bedrock, Azure and Vertex they run on a US-owned cloud, in an EU region too.
Region resolution — the precedence chain
The effective region for a region-bearing provider (Bedrock / Vertex) is resolved from an ordered candidate list; the first candidate that is a valid region token wins:
- the gateway's own region (
bedrock_region/vertex_regionin the gateway config); - the tenant's region (
bedrock_region/vertex_regionon the tenant — set in the tenant settings, see below), inherited by every gateway under that tenant that does not set its own; - the deployment-wide default region set by your operator — now a fallback tier, not the primary source;
- the provider's hard-coded US default (
us-east-1/us-central1) — logged with a WARN so a gateway with no region configured anywhere is visible.
The fall-through is explicit, not OR-coalescing: a non-empty but invalid earlier candidate (a whitespace / uppercase / malformed paste) is treated as "not set" and falls through to the next tier — it can never short-circuit past a valid tenant or env region to the US default.
Per-tenant region SELECT. A tenant sets its Bedrock/Vertex region in the tenant
settings (a dropdown of EU regions, sourced from GET /admin/v1/cloud-regions). The
value is validated server-side as an EU-member region (region.is_eu, fail
closed) — a non-EU or malformed value is rejected with HTTP 400. Clearing it (empty
selection / null) reverts to the deployment or hard-coded default. This is a tenant-column
change, folded into every gateway's cached config, so it propagates within the
gateway-config cache TTL (≤ 30 s) — unlike a per-gateway admin write, which is
invalidated immediately. Allow for the TTL when verifying a tenant region change.
Region value vs the EU guarantee — two distinct controls. The precedence above decides which endpoint Bedrock / Vertex dial; it never decides residency. A per-gateway region overrides the tenant region — including to a non-EU value — and that value is used as-is (the region token is still sanitized against header/URL injection, but not EU-checked). The EU guarantee is the separate
eu_region_routingenforcement floor (per gateway or the tenant floor), and under it Bedrock and Vertex are refused in every region (403data_residency_blocked) — they are US-owned clouds. A tenant EU region is a data-location preference for those adapters, not EU residency.
Transfer safeguard (GDPR Art. 44–46)
GDPR Art. 44–46 allows a transfer of personal data to a third country when appropriate safeguards are in place;
it does not require EU-only hosting. transfer_safeguards_required makes PII masking that safeguard for a
gateway: a provider that is not EU-hosted is used only while the gateway masks personal data in requests.
The GDPR governance template (version 3) switches it on; it
recommends EU routing but does not switch eu_region_routing on.
| Field | Type | Default | Description |
|---|---|---|---|
transfer_safeguards_required |
boolean | absent (off) | When true and the gateway has no enabled request-phase general-PII scrubber (pii_protector, or presidio with scrub — the default — or block, on the request; the same scrubbers a PII mandate accepts), every provider that is not EU-owned is refused with HTTP 403 transfer_safeguard_required before any upstream call. With such a scrubber on, every provider may serve. EU-owned providers (the same set EU model hosting accepts: Myra, Mistral, IONOS, never through a provider_base_urls override; AWS Bedrock, Google Vertex and Azure are not EU-owned in any region) always serve. A non-boolean value is rejected with 400 naming the field (absent or null is accepted). A stored value folds at load: recognized-ON (true, 1, "true", "yes", "on") is on, recognized-OFF (false, 0, "false", "no", "off") is off, an unrecognized value is ON plus a WARN (value escaped in the log) -- garbage never switches the safeguard off. |
Where it applies: the same single dispatch chokepoint as EU residency (primary, fallback, tool-loop leg,
summarization, agentic fetch), the save-time model pins and /compact, the model picker (a refused provider is not
offered), the Files-API upload, and the fleet's served host (a reply the Myra fleet served outside the EU is refused
like under EU routing). eu_region_routing: true still wins: it refuses every non-EU provider, masked or not, with
data_residency_blocked. A custom_pii list or a regex / keyword scrub rule is not a scrubber for this purpose (an
admin keyword list is not a general-PII guarantee); a scrubber that only runs on the response does not mask what is
sent. The check is also made per request: when the configured scrubber could not run and the request went on
unscanned (a fail_open detector during an analyzer outage), when presidio found no field it could scan in the body,
or when masking was skipped because that leg (the request, an agentic-fetch reader leg, a summarize call) used a local
model, a
provider outside the EU is refused for that request with the same code, and so is a reply the Myra fleet served
outside the EU. The flag is part
of the guardrail-config export/import and of the four-eyes gated keys; an import that drops it is reported as
weakening residency.
Provider allowlist (no silent fallback)
Independent of data residency, a gateway can pin an explicit set of approved
providers so it can never silently route — primary or fallback — to a provider
the operator did not approve. Enforced at the same single
dispatch chokepoint as residency: a request whose resolved provider is not on the list
is rejected with HTTP 403 (provider_not_allowed) before any upstream call.
| Field | Type | Default | Description |
|---|---|---|---|
provider_allowlist_enforced |
boolean | false |
When true, only providers named in provider_allowlist may serve this gateway. A model id requested without a provider prefix that several configured providers offer is routed to an allowed one when the usual pick is refused only by the allowlist or EU residency (see Catalogue placement). A non-boolean value is rejected with 400 naming the field (absent or null is accepted); an unchanged legacy echo is accepted. A legacy stored value folds three ways at load: recognized-ON (true, 1, "true", "yes", "on") enforces, recognized-OFF (false, 0, "false", "no", "off") is off, an unrecognized one is off plus a WARN (value escaped in the log) -- unless the tenant floor forces it on. The guardrail-config export writes the effective boolean. |
provider_allowlist |
array of strings | [] |
Approved provider names (e.g. ["myra", "mistral"]). Matched case-insensitively after trimming; vllm folds to myra. Under an armed tenant default this per-gateway list may only narrow the tenant-approved baseline (it is intersected with it) — a gateway can never add a provider outside the tenant list. |
Fail-closed semantics. When enforcement is on, a missing, empty ([]), or
malformed (non-array) allowlist denies every provider — a forgotten or mistyped
list can never silently fall back to allow-all. Non-string array elements (numbers,
null, nested objects) are ignored and can never widen the set; a near-miss or
substring of an approved name never matches. When enforcement is off the list is not
consulted (zero behaviour change for existing gateways).
Scope. The allowlist governs routed chat/inference dispatch. Fixed EU-infrastructure services that call the Myra on-prem fleet directly — embeddings (RAG), image generation/editing, transcription, and vision image-analysis — always use that sovereign fleet and are not routable providers, so they are not gated by this list.
A deployment-wide backstop is available as an operator-only setting, applied on the sovereign stack: with it applied, every gateway must
carry a valid allowlist or its inference fails closed. It is not applied on a shared
stack, because it would 403 every gateway that has not configured an allowlist. An
unrecognised value is treated as disabled and logged at startup.
Per-tenant sub-processor objection (Art. 28 Abs. 6 deactivation)
Orthogonal to residency and the allowlist, a per-tenant sub-processor objection narrows the
effective provider set for one tenant without touching any gateway config or any other tenant.
When Myra Ops records an objection (see the
objection API),
the provider(s) mapped to that sub-processor are deactivated for that tenant: they are dropped
from the tenant's model-offer set and refused at the single dispatch chokepoint (primary, fallback,
failover, and the observed LiteLLM-overflow leg) with 403 provider_objected — the same posture as
the allowlist deny, but scoped by tenant_id and driven by the objection store rather than a config
flag. The deactivated set is derived at config load (a {provider: true} set on the resolved
gateway config, never stored in gateway.config, so a tenant admin cannot PATCH away their own
objection), and it fails closed: a hard read error on the objection store fails the whole config
load rather than serving the objected provider. It is enforcement-flag-free — presence of an
objection is itself the enforcement, so it works on an ordinary non-sovereign gateway too.
Tenant-level residency default (default ON for a sovereign tenant)
For a sovereign tenant on a shared stack (where the deployment-wide backstops
above are not an option — they would flip every tenant), the three residency controls
above (eu_region_routing, provider_allowlist_enforced, provider_allowlist) can be
set as a tenant-level default. Every gateway under that tenant then inherits the
default — including a newly created gateway with an empty config, which is the
behaviour a public-sector "commercial models exclusively via EU regions" obligation
requires: enforcement must be default ON, never fail-open on a forgotten per-gateway
flag.
- Where it lives: tenant columns
tenant.eu_region_routing,tenant.provider_allowlist_enforced,tenant.provider_allowlist.eu_region_routingis settable in the product: Organisation → Organisation settings → Routing → Organisation-wide EU routing (the organisation's own tenant admin or a platform admin; an opt-in, off by default; with config approval on, a tenant admin's change is held for a second administrator), and onPATCH /admin/v1/tenants/{id}aseu_region_routing. It is tri-state:1armed,0explicitly not armed,null(the empty option) = no organisation default at all, each gateway governs itself.provider_allowlist_enforcedandprovider_allowlistremain operator/DB-managed only (a migration or adb.shUPDATE) — there is no admin-UI / PATCH field for those two. - Precedence — a FLOOR (per enforcement control): when a tenant enables a residency
control (
eu_region_routing/provider_allowlist_enforced), that is a floor — a gateway can only raise the control, never lower it. A gateway that setseu_region_routingtofalse/0/"off"under a EU-only tenant is still enforced (it cannot opt a sovereign tenant out of EU-only routing — that would be fail-open on the "commercial models exclusively via EU regions" exclusion criterion). The floor covers the two enforcement booleans and theprovider_allowlistlist contents: when the tenant armsprovider_allowlist_enforcedwith a baseline list, a gateway that supplies its ownprovider_allowlistmay only narrow it — its entries are intersected with the tenant-approved list, so a gateway can never approve a provider the tenant did not (a gateway list of["openai"]under a tenant baseline of["myra","mistral"]resolves to[]— deny all — becauseopenaiis not tenant-approved). A gateway with no own list inherits the baseline. For a fully-sovereign posture arm botheu_region_routingandprovider_allowlist_enforced(as the bid tenant does) — the residency guard is then the hard EU floor regardless of any gateway's allowlist. A gateway's own enforcement-flag value governs only when the tenant default is a recognized tenant default is a recognized OFF (0/false) — the ordinary per-gateway opt-in for non-sovereign tenants. An unrecognized/garbage tenant value (e.g.2) is a mis-provisioned compliance flag and fails closed to ENFORCED (with a warning), never a silent US-leak. For a residency control an absent ornullper-gateway value resolves to the tenant default (the safe ON under a floor). The deployment-wide operator backstop still forces enforcement on where set. - Fail-closed: a tenant that enforces the allowlist but whose
tenant.provider_allowlistis missing/malformed denies every provider on its inheriting gateways (same fail-closed rule as the per-gateway list). - Accepted shape — enforced by the database:
tenant.provider_allowlistmust be SQLNULLor a valid JSON array (e.g.["myra","mistral"]). A DBCHECKconstraint rejects any other write — invalid JSON (a bare-token[myra,mistral]from a mis-quoted provisioning statement), a JSON object, a scalar, or a literalnull— withCONSTRAINT chk_tenant_provider_allowlist_json failed, so a malformed value can no longer be stored at all. Should a pre-constraint/foreign row still carry a non-array value, the gateway treats it as absent (fail-closed: deny-all while enforced) and logs it at ERROR level naming the tenant slug — never silently. - Admin view caveat: the admin gateway GET/PATCH shows the raw per-gateway config, so an inheriting gateway shows these keys absent while enforcement is active at runtime. Read the tenant default to know the effective policy.
- Cache: the per-gateway config is cached briefly (≤ 30 s). A per-gateway change through the admin API invalidates the cache entry immediately; flipping a tenant default (a tenant-column change) still takes effect on a deploy (workers restart) or within the cache TTL, since it is not a per-gateway write.
- Adding a further EU-owned provider: when another EU-owned route (e.g. IONOS) is
provisioned, add it to the tenant
provider_allowlist— otherwise it is residency-OK yet allowlist-blocked. Bedrock, Vertex and Azure cannot be added this way: residency refuses them in every region.
Cloudflare Workers AI
| Field | Type | Default | Description |
|---|---|---|---|
cf_account_id |
string | null | null |
Cloudflare account ID. Required for the Cloudflare Workers AI provider; the gateway builds the request URL from it. Unset, null or empty → the Cloudflare request fails with a configuration error. Rejected: a value with a slash, ?, #, :, @, or whitespace (path injection); the request then fails with a configuration error. |
HuggingFace
| Field | Type | Default | Description |
|---|---|---|---|
hf_endpoint |
string | null | null |
URL of a HuggingFace dedicated inference endpoint. When set, requests go to this endpoint instead of the serverless API (a stored empty string also means the serverless API, but a save must send null to clear it — "" is rejected with 400). Routed through the same SSRF guard as provider_base_urls: resolved once with the dial IP pinned; a value resolving to a private/internal address is rejected at dispatch. Validated at save time (POST/PATCH): null or absent = no custom endpoint; otherwise a non-empty http(s):// URL without userinfo / whitespace / control characters, else 400. A malformed stored value fails the request with configuration_error (never a fall-back to the default endpoint). Only this gateway's own key is sent to it; changes are audited (gateway.endpoint_config_changed). |
Provider base URL overrides
| Field | Type | Default | Description |
|---|---|---|---|
provider_base_urls |
object | {} |
Map of provider_name → base URL. Overrides the hardcoded default endpoint of the gateway for any provider. Useful for internal proxies, self-hosted endpoints, and staging environments. A base only — the provider's endpoint path is appended, and a query string / fragment on the value is discarded. Validated at save time: the field must be an object mapping supported provider slugs to non-empty http:// or https:// URLs with no userinfo (user@host) and no whitespace / control characters; a value that fails this shape — or a key that is not a provider the gateway can route to (an unknown slug, or a legacy alias such as vllm, which is rejected in favour of its canonical id myra) — is rejected with 400 on POST/PATCH — it can no longer be saved and silently no-op at runtime. Setting the field to null (or omitting every entry) clears the override. The full SSRF guard remains at request time: the override host is resolved once and the dial IP pinned, so an entry whose value is not a non-empty URL string (including false or null) or which resolves to a private/internal address is rejected at dispatch with configuration_error — it never silently falls back to the default endpoint. Use the Test Connection endpoint to check reachability before saving. Credentials: an override receives only the API key stored on this gateway for that provider — never a Myra platform credential: a myra override gets requests with no Authorization header (the fleet token goes only to Myra's own fleet endpoint — an override equal to the fleet's origin is the fleet itself), and an anthropic override makes Myra-provided (Platform Key) models unavailable on the gateway. Every change is audited (gateway.endpoint_config_changed, origin-only). |
⭐ Example:
Circuit breaker
| Field | Type | Default | Description |
|---|---|---|---|
circuit_breaker |
object | null | null |
Set to enable the per-provider circuit breaker. null disables it entirely. |
circuit_breaker.enabled |
boolean | false |
Must be true to activate the breaker. |
circuit_breaker.failure_threshold |
integer | 5 |
Number of failures within window_sec before the breaker opens. |
circuit_breaker.window_sec |
integer | 60 |
Window in seconds over which failures are counted. The counter's lifetime is window_sec from the first failure and is not extended by later failures, so the window is tumbling, not sliding. Whole number 1–86400; 0, negative, fractional or non-numeric values are rejected with 400. |
circuit_breaker.cooldown_ms |
integer | 30000 |
Milliseconds to wait in the Open state before allowing a probe request. |
circuit_breaker.failure_status_codes |
array | [500,502,503,504] |
HTTP status codes that count as failures. Connection and timeout errors always count. Must be an array of whole numbers ([] = never trip on status); a malformed value is rejected with 400 on write and fails closed to the default at runtime. |
See Circuit Breaker for state machine details and examples.
Webhooks
Webhooks deliver structured event payloads to an external HTTP endpoint for integration with alerting, ITSM, and automation systems.
| Field | Type | Default | Description |
|---|---|---|---|
webhooks |
object | null | null |
Set to enable outgoing webhooks. null (or absent) disables them. Any other value that is not an object (a string, a number, a boolean, an array) sends nothing, and the gateway logs a webhooks is not an object warning (for the blocked and circuit_open events only when the value is an array; a string, number or boolean is ignored there without a warning). Every warning about an invalid webhooks value names the gateway (gateway=<id>) and, where the event carries one, the tenant (tenant=<id>; circuit_open carries none). |
webhooks.url |
string | — | The endpoint that receives a POST for each event. It must be https:// on a public DNS name (no IP address, no localhost), port 443 or 1024–65535, no user name — checked on save and again on every send, where the host must resolve only to public addresses; redirects are not followed. The full rules and error codes: Webhook destination policy. Absent, null or "" means no webhook is sent. Any other non-string value (a number, an array, an object, a boolean) is invalid: it is refused on save (400 invalid_webhooks, formerly webhook_config_invalid), and a stored one sends nothing and logs a webhooks.url is not a string warning. A stored URL that breaks the destination rules sends nothing and logs webhook: destination refused … with the gateway and tenant. |
webhooks.secret |
string | — | Optional shared secret. When set, each delivery carries an X-AIG-Signature: sha256=<hex> header — the HMAC-SHA256 (RFC 2104) of the exact request body, keyed with this secret. Recompute it over the raw body in your receiver to verify origin and integrity. Absent or null means deliveries are unsigned. Any other non-string value is invalid: no event is sent (never unsigned in its place) and the gateway logs a webhooks.secret is not a string warning. |
webhooks.events |
array | all events | Event types to deliver. Supported values: blocked, budget_exceeded, budget_threshold, circuit_open. The circuit_open payload's provider names the breaker that opened: the provider (for example openai), or for Myra myra/<model> (your gateway's own breaker for one model) or myra (the whole fleet). The Myra model breaker shared by all tenants never sends a tenant's webhook. When this key is absent (or null), every supported event is delivered. Providing an array restricts delivery to the listed events (an empty array delivers none); any other value (a string, a number, a boolean, an object) is invalid: no event is sent and the gateway logs a webhooks.events is not an array warning; note that an existing filter that does not list budget_threshold will not receive the new soft-alert event until you add it. In the web app (the gateway's Edit popup, Notifications section, Webhook) the checkbox All events, including future ones sits above the event checkboxes. Ticked, it saves the webhook with no events key, so it receives every event type, including ones added later; a new webhook starts with it ticked. Unticked, it shows one checkbox per event and saves exactly the checked events as this array (unchecking all of them saves [], which delivers none; the popup then says the webhook receives nothing); an event type added later is not included until you tick it. When you open a webhook, All events, including future ones is ticked if it has no events key (or null), and unticked with its event boxes checked if it has a list; an invalid value shows it unticked with no event checked. Opening the popup or saving other sections never changes the stored filter: it is written only when you save after changing the webhook (URL, secret, All events, including future ones or an event box). An entry that is not one of the four event names is not shown as a checkbox and is dropped when the webhook is saved with All events, including future ones unticked. A webhook saved in the app before budget_threshold had a checkbox stored the three other events: open its settings and tick All events, including future ones (or budget_threshold) to receive it. |
⭐ Example:
"webhooks": {
"url": "https://hooks.slack.com/services/...",
"secret": "mysecret",
"events": ["blocked", "budget_exceeded", "budget_threshold"]
}
Webhook payload
While the tenant is suspended no webhook event is delivered (and none when its state cannot be read); see Messages while suspended.
Every delivery is a POST with a JSON body of the shape:
ts is the Unix epoch (seconds) at send time (for a late budget_threshold webhook sent by the background sweep, the time it was sent). Every webhook is POSTed once — one attempt, a 5-second timeout on each step (connect, send, read), no retry: an endpoint that is down, slow or answers non-2xx does not receive it again. Numbers in the payload (for example spent_usd) are written with their full double precision, never rounded to 14 significant digits, and the x-aig-signature covers exactly those bytes. A payload that cannot be written exactly (a non-finite or otherwise unrepresentable number) is not sent at all: the event is skipped and the failure is logged. The data object depends on the event:
| Event | data fields |
|---|---|
budget_exceeded |
scope ("token" | "tenant" | "gateway" — which cap was hit), budget_usd (the cap: the per-token cap, the tenant's self-imposed spend_cap_usd, the per-gateway budget_usd), spent_usd (current-period spend), period (the period key, e.g. "2026-07", "2026-07-15", or "total"; the tenant spend cap is always monthly). A member's personal budget and a team (department) budget send no webhook: when spend reaches 80% of the cap, and again when the cap is used up, the gateway records the crossing once per cap and period (a raised cap starts a new record) for an e-mail notification; the refused requests themselves carry 429 user_budget_exceeded / 429 team_budget_exceeded. Fired per request when a request is blocked because spend reached the cap. (The former self-serve cap soft-degrade — the degraded / stage fields — was retired with the wallet money-model rework: tenant enforcement is now the wallet balance plus the optional spend_cap_usd, a hard stop with no model swap, so these payloads no longer carry degraded / stage.) |
budget_threshold |
Same fields as budget_exceeded, plus threshold_pct (the configured budget_alert_pct, e.g. 0.8). Sent once across all gateway nodes (per (scope, entity, period, cap), see budget_alert_pct) when spend crosses the soft threshold without being over the cap; the request is not blocked. If it cannot be sent at once (the gateway's background task cannot start or is dropped, the node restarts or is redeployed, a database fault), a background sweep sends it about a minute after the crossing — also when the next request is already over the cap or no further request comes — with late: true and recorded_at (unix seconds, when the crossing was recorded) added to data; spent_usd is then the spend at the crossing and ts the time it was sent. A late webhook goes to the gateway's current webhooks configuration (not sent if the webhook was removed or no longer subscribes to budget_threshold). One attempt only: an endpoint failure is not retried. If the gateway's database is unavailable at the crossing it is not sent until a later request at or above the threshold (at least 60 seconds later) can record it. See Soft-threshold alerts. |
SIEM (gateway-level override)
A gateway-level siem key overrides the tenant-level SIEM (Security Information and Event Management) config for that specific gateway. All fields are identical to the tenant-level config.
| Field | Type | Default | Description |
|---|---|---|---|
siem |
object | null | null |
SIEM backend config for this gateway. Overrides the tenant default. Set null to remove the override and fall back to the tenant config. |
siem.type |
string | — | Backend: splunk_hec, elasticsearch, vector, syslog. |
siem.events |
array | ["blocked"] |
Event filter. Values: blocked, guardrail, scrubbed, all. |
See SIEM Integration for the full field reference and per-backend examples.
Tracing
| Field | Type | Default | Description |
|---|---|---|---|
tracing |
object | null | null |
Set to enable request tracing. null disables tracing entirely. |
tracing.enabled |
boolean | false |
Activate internal pipeline tracing (Traces API + Playground traces). |
tracing.include_bodies |
boolean | false |
Store raw content in trace-step content fields (request messages, answers, tool arguments, queries, URLs, previews, filenames; see Tracing for the list). Stored only when this is on AND log_payloads is on AND the request did not send x-aig-collect-log-payload: false AND the turn is not private. When off, those fields are omitted and only metadata (counts, sizes, status) is stored. Enable only for debugging. |
tracing.otlp_endpoint |
string | — | Base URL of an OpenTelemetry collector (e.g. https://otel-collector.example.com:4318). Must be a public https:// name; internal destinations are refused on save and at send time. Setting this enables OTLP span export. |
tracing.service_name |
string | "ai-gateway" |
service.name resource attribute on all emitted OTLP spans. |
tracing.headers |
object | {} |
Extra HTTP headers to include in the OTLP request (e.g. auth tokens for managed collectors). At most 32 headers and 8192 bytes of JSON in total, stored encrypted; names must be HTTP header tokens, values strings of at most 4096 bytes without control characters; the names the gateway controls (Host, Content-Length, Transfer-Encoding, Connection, Content-Type, User-Agent) are refused on save with invalid_tracing_headers (formerly tracing_headers_invalid). |
tracing.sample_rate |
number | 1.0 |
Fraction of requests to export via OTLP (0.0 = never, 1.0 = always). |
💡 Note: Trace retention is not a per-gateway field. Stored traces are purged automatically by a deployment-wide background job; the window is a deployment setting configured by your operator (default 48 hours). See Request Tracing — Trace retention.
💡 Note: Conversation (chat content) retention is separate. It is disabled by default and enabled per deployment by your operator (default off), then per tenant via
conversation_retention_days. See Conversation retention and deletion.💡 Note: Request-log retention (deletion of
request_logprompt/response rows) is separate again. The deployment-wide switch is on by default in production and beta and off in dev and integration (an operator setsAIG_REQUEST_LOG_RETENTION_ENABLED=falseor0to turn it off); deletion still happens only for a tenant whoserequest_log_retention_daysis set (30 or more). Therequest_log_legscost ledger is never deleted. Where the optional ClickHouse analytics copy is enabled, this deletion does not reach it (nothing in it is deleted or anonymised): its text expires after 14 days and its other personal fields after 730 days — see ClickHouse analytics sink. See Data retention — Request-log retention.💡 Note: Replay-record capture is separate again and on by default for every tenant (
replay_capture_enabled, default 1; a platform operator sets 0 to opt a tenant out on request — there is no self-service switch). The gateway persists a raw (unmasked) per-turn replay record — the exact requests it sent to the model for every model call of the turn, the client messages, the intra-turn tool calls/results, the available tool names, the model, the routing and sampling params, the answer, and references with SHA-256 to attachments and created files — for offline model evaluation and fault diagnosis, not for training. Nothing is cut: what exceeds the record or store limits (platform settingsreplay_tenant_byte_budget_mib,replay_platform_byte_budget_mib) is kept as SHA-256 and size; side requests (titles, follow-up suggestions, sub-agent calls) have their own ring (replay_side_ring_cap, default 50). It is bounded byreplay_capture_ttl_hours(default 720, i.e. 30 days, reaped hourly) andreplay_capture_cap(default 200 per tenant+gateway), deleted on Art. 17 user erasure (by both the turn owner and the run-as driver) and on tenant purge. It is not captured on incognito turns, on turns blocked by a guardrail or a limit, on a gateway withlog_payloads: false, for requests withx-aig-collect-log(-payload): false, for requests that are not a chat turn (nomessages, token counting), or for a tenant whose request logging is disabled. See Data retention — Turn replay records.
See Request Tracing for the full pipeline step reference and OTLP integration guide.
Image generation
| Field | Type | Default | Description |
|---|---|---|---|
image_generation |
object | null | — (absent) | Controls whether the EU image-generation tool (generate_image) is offered on this gateway. Absent by default — an admin- or API-created gateway has no key, and the tool is withheld until { "enabled": true } is set; self-serve signup is the one path that seeds it on. Set { "enabled": false } to withhold the tool (the admin UI's toggle persists null, which withholds it too). The tool is offered only when this is on and the request carries the x-aig-image-gen header (see the inference API reference). |
image_generation.enabled |
boolean | false |
Offer the generate_image tool to the model. Only the boolean true enables it. It also enables the remove_background tool, which additionally needs the platform setting background_removal_available (see Image generation). |
image_generation.model |
string | — | Optional override of the EU-hosted image model the tool calls (see Image generation); absent → the deployment's default image model. Accepted: a non-empty string of at most 128 characters from A–Z a–z 0–9 . _ : / -. Any other value (longer, empty, other characters, or not a string) is ignored at run time — the default image model is used and an operator warning is logged — so a stored typo can never break image generation or its request logging. |
Video generation
| Field | Type | Default | Description |
|---|---|---|---|
video_generation |
object | null | — (absent) | Controls whether the create_video tool (self-hosted EU video backend) is offered on this gateway. Absent by default; self-serve signup does not seed it. The tool is offered only when this is on, the platform setting video_generation_available is on, and the request carries the x-aig-video-gen header (see the inference API reference). See Video generation. |
video_generation.enabled |
boolean | false |
Offer the create_video tool to the model. Only the boolean true enables it; any other value (false, a string, a number, a missing key, or null) leaves it off. |
Web search
| Field | Type | Default | Description |
|---|---|---|---|
web_search |
object | null | null |
Set to enable web-search augmentation. null disables the feature. |
web_search.enabled |
boolean | false |
Activate web search on this gateway. Only the JSON boolean true activates it; absent, null and false leave it off. Any other value (string, number, object, array) is refused on write with 400 invalid_web_search, and a legacy stored one is read as off (logged). |
web_search.api_key |
string | — | API key for the configured web_search.provider (Brave Search or linkup.so). Required for all providers except Google Gemini. |
web_search.max_results |
integer | 5 |
Maximum number of search results to retrieve per query: a whole number from 1 to 9007199254740991; null or absent = 5; anything else is refused on write with 400, and a legacy stored malformed value is read as 5 (logged). The Brave provider asks for at most 20 results per query. |
web_search.mode |
string | "opt-in" |
"opt-in" — only triggered when the client sends the x-aig-web-search request header with 1, true, yes or on (any other value leaves search off; see Web Search). "always" — attempted on every request. Exactly these two strings (case-sensitive); null or absent = "opt-in"; anything else is refused on write with 400 invalid_web_search, and a legacy stored unrecognised value is read as "opt-in" (logged). |
web_search.max_searches_per_turn |
integer | 8 |
Per-turn cap on distinct web searches on the model-driven tool-loop path (near-duplicates are de-duplicated). It also caps the web_search calls taken from ONE model reply on every two-leg turn (extras are dropped and logged once; never more than 999). API-managed; read fail-safe (invalid/zero/non-finite → default). See Web Search settings. |
web_search.provider |
string | "brave" |
Search backend: "brave" or "linkup" (EU-sovereign). When the gateway sets no provider of its own, the tenant web_search_provider default fills it (and, under an armed EU residency floor, a non-EU per-gateway provider is clamped up to an EU tenant default). See Web Search — Supported providers and tenant web_search_provider. |
💡 Note: Web-search per-query cost is a DB catalog row, not a deployment setting. Migration
0226seeds amodel_pricerow forprovider='linkup', model='web_search'withinput_per_1k = 10.0— the per-1,000-queries rate (10.0=$0.01per query), so a web-search leg reportspricing_source=dband is visible and editable on the Model prices page (Platform › Models & providers) like every other model. In the UI that row is flagged per query (its Input field is USD per 1,000 queries, not per token) so an edit is not a 1000× mis-price. Only linkup is metered (Brave is the historical unmetered default and has no cost row). A built-in default rate (0.01) is now only the last-resort fallback used when the catalog row is absent (a fresh DB before the migration, or an operator DELETE). Propagation: the resolved price is memoised per worker for up to 1 hour (uniform across all model prices; the cache is node-local and not invalidated on edit), so a live UI edit takes effect within 1 hour or on the next worker restart; the migration restarts workers, so the seed is immediate. Overshoot bound: the budget cap is checked before a request starts, but search cost is recorded during the turn, so a single turn can overshoot its cap by at most 100 linkup queries (25 tool-loop rounds × 4 parallel calls, ≈$1.00 at the default rate) before the next request is blocked. This is bounded and accepted, not a bug — see Web Search for the full provider notes.
See Web Search for provider support details and usage examples.
Semantic cache
The semantic cache serves a stored response when a new request is close in meaning to an earlier one, even when the request text is not identical. The semantic cache is separate from the exact-match cache that cache_ttl controls and requires an external embedding service.
| Field | Type | Default | Description |
|---|---|---|---|
semantic_cache |
object | null | null |
Set to enable the semantic cache. null disables it. |
semantic_cache.enabled |
boolean | false |
Activate the semantic cache for this gateway. |
semantic_cache.embedding_url |
string | — | URL of the embedding service that produces the request vectors. Required; the semantic cache does nothing when this is unset. |
semantic_cache.embedding_api_key |
string | — | Optional bearer token for the embedding service. |
semantic_cache.embedding_model |
string | "text-embedding-3-small" |
Model the embedding service uses to produce request vectors. |
semantic_cache.max_candidates |
integer | 100 |
Maximum number of stored vectors compared against an incoming request. A whole number from 1 to 9007199254740991; null or absent = 100; anything else is refused on write with 400, and a legacy stored malformed value is read as 100 (logged). |
semantic_cache.threshold |
number | 0.95 |
Minimum cosine similarity for a cached entry to be served. A finite number from 0 to 1; null or absent = 0.95; anything else is refused on write with 400, and a legacy stored malformed value is read as 0.95 (logged). |
semantic_cache.ttl |
integer | 86400 |
Lifetime of a semantic cache entry in seconds: a whole number from 1 to 9007199254740991; null or absent = 86400; anything else is refused on write with 400, and a legacy stored malformed value is read as 86400 (logged). |
Outbound PII egress guard
The egress guard scans a request's outbound tool traffic (web search, URL fetch, MCP tool arguments) for personal data and secrets before it leaves the gateway. It is on by default; any internal error in the guard fails closed (blocks). See Guardrails — threat model.
| Field | Type | Default | Description |
|---|---|---|---|
egress_guard |
object | null | on | Configures the outbound PII egress guard. Omit to keep the default-on behaviour; set enabled: false to disable it. |
egress_guard.enabled |
boolean | true |
false disables the guard for this gateway. |
egress_guard.mode |
string | "block" |
"block" refuses a request whose outbound tool traffic carries flagged data; "flag" logs the near-miss and allows it (for an open-web-browsing gateway). |
egress_guard.pii_sets |
array | high-signal set | The identifier/secret pattern sets to scan for. The default set omits loose numeric identifiers (SSN, phone, IP) that false-positive on ordinary URL IDs — opt those in explicitly. |
Agentic fetch
Agentic fetch lets the model fetch a URL and read its content during a conversation.
| Field | Type | Default | Description |
|---|---|---|---|
agentic_fetch |
object | null | null |
Set to enable agentic fetch. null disables it. |
agentic_fetch.enabled |
boolean | false |
Activate agentic fetch for this gateway. |
agentic_fetch.model |
string | — | Optional model for the fetch sub-request — any provider's model (its reply is read with that provider's own reader). When unset, the gateway uses the Myra fleet's canonical local chat model (qwen3.8-27b). A value naming a retired Myra-fleet id with a registered successor is upgraded to the successor at dispatch (logged; no response header — the inner leg does not serve the turn). See Retired model ids. Self-serve workspaces: the override must be in the plan's model list, and a Myra-hosted override needs the EU-Gov add-on — a PATCH setting a non-permitted value is refused (400 plan_model_not_allowed / eu_gov_model_not_allowed), and a stored non-permitted value runs on the default instead. The default itself is platform infrastructure and exempt from the EU-Gov rule. |
URL-fetch per-turn budgets
The fetch_url/agentic_fetch tools are bounded per turn. Both budgets are API-managed (no UI control in the Edit modal, which preserves a stored section untouched) and read fail-safe: an invalid, zero, negative, or non-finite value falls back to the default — a config typo can never uncap the tool or brick it.
| Field | Type | Default | Description |
|---|---|---|---|
url_fetch |
object | null | null |
Optional per-turn fetch budgets. null/absent means the defaults apply. |
url_fetch.max_fetches_per_turn |
integer | 24 |
Total URL fetches (web pages and documents) the model may make in ONE turn. On reaching it the model gets a notice naming the limit and answers from what it has. Raise it for research-heavy workloads. Each page of a paged read (a fetch_url or agentic_fetch call with offset, see Inference — fetch_url offset) counts as one fetch (for agentic_fetch also one inner-model call), and under a tool-approval gate each page is a separate approval. |
url_fetch.max_doc_fetches_per_turn |
integer | 8 |
Sub-cap on document extractions (PDF/DOCX/XLSX — the expensive, possibly-OCR unit) within that total. |
Knowledge search per-turn budget
The built-in search_knowledge tool is bounded per turn. The budget is API-managed (no UI control in the Edit modal, which preserves a stored section untouched) and read fail-safe: an invalid, zero, negative, or non-finite value falls back to the default, so a config typo can never uncap the tool.
| Field | Type | Default | Description |
|---|---|---|---|
knowledge |
object | null | null |
Optional knowledge-search budget. null/absent means the default applies. |
knowledge.max_searches_per_turn |
integer | 12 |
Number of search_knowledge calls the model may make in ONE answer. Every call that is a real search counts, including one for an unknown or locked area or one that fails; a call with an empty query does not. From the next call on, the tool is withdrawn from the tools offered and a call that still arrives gets a notice naming the limit instead of results; the model then answers from the passages it has. If search_knowledge is the only tool offered, the reply ends at once with one final answer written without tools from the passages it has, with no stop note when that answer is delivered. A search that returns only passages already returned earlier in the same answer carries a short note that nothing new was found. |
Upload malware scanning (ClamAV)
Scans uploaded file bytes for malware before they are processed or persisted, using a self-hosted ClamAV daemon (clamd). It is opt-in per gateway and OFF by default — malware scanning is never a global default. When a gateway opts in, its upload byte-ingress paths (chat file attachments, conversation attachments, anonymous form uploads) scan fail-closed: an infected file is rejected (422, code: malware_detected) and an unreachable/erroring scanner rejects rather than accepting unscanned bytes (503, code: scan_unavailable, with Retry-After). Tenant-scoped uploads that have no single gateway (project knowledge, personal My-PII lists, app-feedback evidence images — the last scanned on the reporter's tenant) are scanned when the tenant has scanning enabled on any of its gateways. That enablement read is itself fail-closed: if it cannot be determined whether scanning applies (the tenant's gateway list is unreadable, or a gateway config will not decode) the upload is refused with 503, code: scan_unavailable, not accepted unscanned. An account with no tenant at all (a platform admin's normal shape, or a tenantless user) owns no gateway, so no gateway can have opted in — such a caller's My-PII list / feedback image is knowably not scanned; a tenant id that is present but empty is a malformed row and refuses (503). The ClamAV endpoint is deployment infrastructure configured by your operator (a unix socket, or a host and port), not a config field; the daemon's StreamMaxLength must be at least 110M, the largest upload cap (see clamd size limits below).
| Field | Type | Default | Description |
|---|---|---|---|
av_scan |
object | null | null |
Per-gateway upload malware scanning. null / absent = OFF. |
av_scan.enabled |
boolean | false |
When true, scan this gateway's upload byte-ingress fail-closed. Default OFF. |
clamd size limits. Chat uploads go up to 110 MB, so the operator must set StreamMaxLength, MaxFileSize and MaxScanSize to at least 110M and AlertExceedsMax yes in clamd.conf. A scanner reply that a size limit was exceeded (or a Heuristics.Limits.Exceeded finding) is rejected with 413, code: scan_limit_exceeded and is never treated as clean.
Code interpreter
The code interpreter lets the model run a short program in a sandboxed, network-isolated interpreter and read back its output — for calculation, data analysis, and transforming data during a conversation. It works on the open / EU model stack (the sandbox runs on a self-hostable runner service, independent of any single provider).
The feature is ON by default on every gateway; the per-gateway flag is an opt-OUT. It is available when the deployment-wide runner is configured and the gateway has not explicitly disabled it:
- Deployment-wide runner (required) — your operator must point the gateway at a running sandbox control plane over HTTPS (a non-
https://URL is treated as a misconfiguration and keeps the feature dormant — code egress must be encrypted). When no runner is configured, the code interpreter is fully dormant: the tool is never offered, the system prompt is unchanged, and no request is ever made. - Per-gateway opt-OUT —
code_interpreter.enableddefaults totrue; set it tofalseon a gateway to disable the code interpreter there. An absent /nullvalue leaves it on (the default). Only an exact booleanfalsedisables it; a malformed value (non-booleanenabled, or a non-objectcode_interpreter) is rejected at the write boundary with400, so a fumbled opt-out can never silently leave it enabled.
Runner authentication (mTLS or bearer). The gateway authenticates to the sandbox with a client certificate (mTLS) or a bearer token; the sandbox may additionally enforce an IP allowlist. Configure at most one client-auth method:
| Deployment setting | Purpose |
|---|---|
| Runner URL | HTTPS base URL of the sandbox control plane. Required; a non-https URL keeps the feature dormant. |
| Client certificate (mTLS) | The PEM client certificate. |
| Client private key (mTLS) | The PEM client private key. |
| Bearer token | Optional bearer token, sent as Authorization: Bearer …. |
| Session signing key | Optional. Gateway-only secret for the persistent kernel (see Persistent kernel below). Unset ⇒ stateful sessions unavailable; stateless unaffected. |
- mTLS is all-or-nothing: set both cert and key, or neither. Setting only one, or a PEM that fails to parse, is a fail-closed misconfiguration — the tool is not advertised and no request is ever made (never an unauthenticated fall-through).
- The PEM files are read and parsed once per worker at first use (loaded at start-up); a parse failure is sticky until the service restarts.
- The gateway always verifies the sandbox's server certificate (TLS verification is never disabled). If the sandbox presents a private-CA certificate, add that CA to the gateway's trusted-certificate bundle; for an
IP:portURL the server certificate must carry a matching IP SAN.
In addition, the tool is never offered when the active provider does not support native tool-calling, when the client supplied its own tools, or for a run under the restricted tool profile (the public docs chat), which withholds code execution together with the egress tools. A Tier-1 local_only project does get the tool: the sandbox is Myra-owned infrastructure inside the estate with no network access, so running code there does not leave the project. This holds only while the deployment's runner URL points at that Myra-owned fleet.
| Field | Type | Default | Description |
|---|---|---|---|
code_interpreter |
object | null | null (→ on) |
Container for the code-interpreter opt-out. Absent / null leaves the feature on (the default). A present, non-null, non-object value is rejected with 400. |
code_interpreter.enabled |
boolean | true |
On by default. Set to false to disable the code interpreter on this gateway (opt-out). Absent / null → on. A non-boolean value is rejected with 400. Still requires a runner configured for the deployment. |
code_interpreter.stateful |
boolean | false |
Opt into the persistent kernel (variables survive across turns), layered under enabled. Requires the deployment's session signing key. Default off ⇒ stateless one-shot. See Persistent kernel below. |
Enabling it for a specific tenant/gateway
The code interpreter is on by default, so nothing has to be written to enable it — it is
available on every gateway once the deployment-wide runner is configured. To disable it on a
specific gateway, a tenant administrator PATCHes the gateway config —
PATCH /admin/v1/gateways/{id} with { "config": { "code_interpreter": { "enabled": false } } }.
The caller must be a tenant admin and the gateway must belong to their tenant (a plain
user gets 403; another tenant's gateway gets 404 — indistinguishable from an unknown id, see the API reference). The merge is shallow at the top
level: it sets code_interpreter and leaves every other config key intact — but it
replaces the whole code_interpreter object, so always send the full sub-object. A malformed
code_interpreter (a non-object, or a non-boolean enabled) is rejected with 400.
Two operational facts to plan around:
- Dormant until the runner env is set. The flag alone does nothing: unless the deployment-wide runner points at a running HTTPS sandbox control plane, the capability is fully inert (tool never offered, no request made). Enabling the flag on a deployment whose runner is not configured is a no-op until the runner is provisioned.
-
Config-cache propagation. Gateway config is cached in memory on each gateway instance and revalidated against the database after 5 s (stale-while-revalidate). An admin change takes effect at once on the instance that handled it; every other instance picks it up within about 5 s. So enabling — and, more importantly, disabling — the flag on a gateway that is already serving traffic reaches every instance within about 5 s. (A change written directly to the DB, bypassing the admin API, propagates within the same 5 s.)
- Database blip. If the revalidation read fails with a storage error, the already-cached
config keeps being served for at most
config_cache_ttl(default 60 s) from when it was fetched, then requests fail. A gateway that is deleted or whose stored config is corrupt is never served from cache: the error is returned immediately. - Cold start. An instance with nothing cached fails closed when the database is unreachable; there is no stale config to fall back to.
- Database blip. If the revalidation read fails with a storage error, the already-cached
config keeps being served for at most
PII / Datenschutz gateways — operator judgement, not a runtime block. Enabling the code
interpreter on a PII-active gateway is not blocked at runtime (the only runtime block is
the per-run restricted tool profile; neither the PII axis nor the project tier is consulted for the
code-interpreter offer). Model-generated code is sent to the runner and can carry data the model
saw in context — including PII it transcribes into code literals. The input_files raw-attachment path is separately PII-gated fail-closed (see
below), but the code itself is not. So on a Datenschutz gateway this is an operator decision:
enable it only when the runner is EU-hosted / in-house (there is no code-enforced residency
tie between the runner and a gateway's eu_region_routing — the runner's
location is an operator obligation) and the residual code-literal egress is acceptable for that
gateway's data class.
Runner contract (trust boundary)
The runner is treated as an untrusted upstream. The gateway posts to POST <runner-url>/v1/execute. The request body is data-minimized — it carries only the program, optional stdin, and resource limits; never conversation history, PII, secrets, or tenant identity (the sandbox authenticates the gateway, not the end user):
{ "code": "<program>", "stdin": "<optional>",
"limits": { "wall_seconds": 30, "memory_mb": 512, "output_bytes": 65536 } }
The only request headers are Content-Type, an opaque x-aig-request-id correlation id, and the client-auth header (Authorization, when a bearer token is set). The encoded job is capped at 128 KiB; an over-cap program is rejected before egress with a clear "too large" error.
Data-file analysis (input_files)
On a saved, owned conversation the gateway stages the conversation's data files into the sandbox at /input/<filename> automatically on every code_interpreter run - every chat attachment (newest first), then every selected project-knowledge file - within the bounds below, so the program can read the real file directly (e.g. pandas.read_excel("/input/data.xlsx")). The optional input_files argument is only needed for a file produced earlier in the conversation (by name); a name the model passes, or one the gateway finds in the code as /input/<name>, is staged first and counts against the same bounds. The gateway looks up each file's raw bytes (scoped to the conversation and its owner - no cross-conversation or cross-user access), validates it, and stages it. This lets any model compute exact figures over an uploaded spreadsheet instead of estimating from extracted text, and the raw file is analysed inside the self-hosted sandbox — it is never uploaded to the model provider.
- Accepted files: by extension - data (
xlsx,xlsm,ods,csv,tsv,json), documents (docx,pptx,pdf), text and markup (md,markdown,txt,text,log,html,htm,xml,yaml,yml,rtf) and Python scripts (py,pyw). Zip-container types are magic-verified as zip containers and PDFs for%PDF. Legacy.xls, images,.odtand other types are not staged (and, on the automatic path, are skipped without a note). - Which version is staged (filename resolution): a name may match a chat attachment the user uploaded, a file in the conversation's project knowledge, or a file the model itself generated on an earlier turn (so a follow-up like "add a total row to that spreadsheet you made" can re-open and edit it). When more than one of these shares the same filename, the gateway stages the most-recently-created version — a later generated edit supersedes the upload it was derived from, and a genuine re-upload supersedes an older generated file. If that newest version cannot be loaded (mid-ingest, corrupt, or over a cap) the gateway falls back to the next-available same-named version and notes the substitution to the model rather than failing the run. Resolution is always scoped to the caller's own conversation/project — no cross-conversation, cross-user, or cross-tenant access.
- Bounds (fail-soft): ≤ 8 files, ≤ 8 MiB each, ≤ 16 MiB total. A file that is missing, unowned, corrupt, or over a cap is skipped with a note to the model (naming how to load it instead: reference
/input/<name>in the code or pass it ininput_files) - the rest of the run proceeds. Files still uploading and unsupported types are skipped quietly. - PII gating (fail-closed): raw bytes may enter the in-house sandbox, but the analysis result returned to the model can contain PII (names, salaries) and, on an external-provider gateway, would then leave to the provider. So on a PII-active gateway, data-file staging is allowed only when the gateway has a fail-closed general-PII detector (
pii_protector) whose tool-result masking reliably masks that result before it egresses (the result passes the standard tool-result PII scrub, which reversibly tokenises PII for the provider and restores it in the final answer to the user). A PII-active gateway that masks only withcustom_pii(keyword-only) orpresidio(fails open on an outage outside a PII mandate) does not stage the raw file — the model still runs code, just without the attachment. A non-PII gateway stages freely. - Runner dependency: the gateway emits
input_filesin the/v1/executerequest as[{ "name": "<bare filename>", "b64": "<standard-base64 raw bytes>" }]; the sandbox runner must stage each into the guest/input/<name>(see the internal sandbox design,ops/sandbox/DESIGN.md§1.1). Data-minimization holds at the conversation boundary: the files sent are only this conversation's own attachments, the project files the user selected for the chat (up to 8 files / 16 MiB per run) and files the model asked for by name - never conversation history, other conversations' files, other users' or other tenants' data, or project files the user unchecked or cannot read; and nothing is sent on a gateway whose PII configuration does not allow staging.
The gateway accepts a JSON object response:
{ "stdout": "string", "stderr": "string", "exit_code": 0, "timed_out": false,
"truncated": false, "error": null,
"artifacts": [ { "mime_type": "image/png", "filename": "chart.png", "b64": "<standard-base64 PNG>" },
{ "mime_type": "text/csv", "filename": "results.csv", "b64": "<standard-base64 CSV>" } ] }
Accepted / rejected shape (all response fields optional, but type-strict when present; the gateway fails closed on anything malformed):
stdout/stderr— must be strings when present; a non-string is rejected. Each stream is scrubbed of invalid UTF-8 and capped (64 KB) before being returned to the model.exit_code— must be an integer when present (NaN, Infinity and non-integers are rejected). Absent → reported as “unknown”.timed_out— boolean; anything else is treated asfalse.truncated— boolean; when the sandbox trims a stream tooutput_bytes, the gateway propagates the truncation notice to the model.error— a broker-level rejection reason (e.g.no_isolation_available,busy,job_too_large). Any present, non-nullerrorfails the whole call closed — it is never rendered as an empty success, regardless ofexit_codeor HTTP status (a sandbox that could not isolate the job must not look like a job that ran and produced nothing).artifacts— optional array of files the program produced (a chart, or a data file such as a CSV or.xlsxof results). Each element carriesb64(standard-alphabet base64; base64url is rejected) plus advisorymime_type/filename. Every artifact is validated fail-closed and any that fails is dropped (its bytes never reach the user), not rendered. Three kinds are accepted; the runner's declaredmime_typeis never trusted for the decision:- PNG chart — accepted by magic bytes (filename-independent; a non-PNG labelled
image/pngis rejected), then stored and rendered inline in the conversation, downloadable, and included in chat export via the existing generated-image path. Also gated on pixel dimensions ≤ 25 MP (a small PNG declaring gigapixel dimensions — a browser decompression bomb — is rejected; the same ceiling the document exporter enforces). - Text data file — a
.csv/.txt/.html/.htm(must be valid UTF-8 with no NUL byte; an HTML file — when the runner returns one — at most 8 MiB) or.json(must parse as JSON). Thefilenamemust be a bare filename (a path-bearing or control-character name is rejected); its extension selects the kind and the gateway-pinned content type. Accepted files are delivered as a downloadable file card in the conversation (the same path thewrite_filetool uses); a duplicate name is auto-suffixed (results-2.csv) so it never overwrites an earlier file. Up to 4 data files are persisted per turn. .xlsxworkbook (binary) — a genuine Excel workbook the program produced (e.g.wb.save("report.xlsx")). Accepted by shape, not by the runner's declared type: the bytes must be a ZIP package (PK\x03\x04magic) carrying the[Content_Types].xmlpart and anxl/part (a.docx/.pptxOOXML zip, or a.xlsxname over non-ZIP bytes, is rejected). Thefilenamemust be a bare filename. The gateway stores and serves the bytes verbatim and never parses them (no server-side XXE / zip-bomb surface); it is delivered as a downloadable binary file card, served by an authz'd conversation download route. Shares the same per-artifact / total / count caps below.- Everything else is rejected: an unknown or absent extension, a non-PNG binary that is not a shape-valid
.xlsx, a.docx/.pptx(or other non-spreadsheet OOXML) mislabeled.xlsx, unparseable JSON, a.txt/.csvcontaining binary, an oversize file, or more than 4 files. - Shared caps across all artifacts: per-artifact size ≤ 25 MiB, total ≤ 25 MiB, count ≤ 4 (extras rejected).
- Degrades gracefully: a runner that returns no
artifactsfield (or only PNGs) is fully supported — the run still returns its text output; there is simply nothing extra to deliver.
- PNG chart — accepted by magic bytes (filename-independent; a non-PNG labelled
- The whole response body is size-bounded (36 MiB — room for the 25 MiB artifact ceiling plus its base64; no OOM). A reply over that bound yields “the program's output was too large to return; write fewer or smaller output files” (never retried — the same program answers the same way); a non-
200status (including400/401/413/429/503/500), a connection error, or a timeout yields a friendly “temporarily unavailable” tool result — never a crash or a leak of the sandbox's internal status to the model. A run is limited to 60 s of wall clock.
The model-supplied code and stdin are size-bounded (64 KB each, and ≤ 128 KB combined job) before egress and are never executed by the gateway — they run only inside the runner sandbox. The rendered runner output is fenced as untrusted content, so stdout cannot forge the gateway's content markers or override instructions.
The gateway integration is default-dormant and fail-closed; deploying the sandbox runner service itself is a separate operational step.
Persistent kernel (stateful sessions)
By default every code-interpreter run is stateless — a fresh sandbox per call, with no variables carried between turns. A gateway may opt into a persistent kernel: a live per-user Python kernel whose namespace survives across turns (load a spreadsheet once, then reference the dataframe in a later turn without re-loading), evicted after ~2 hours idle. This is a phase-2 capability enabled for demo / internal gateways; stateless remains the default everywhere else and is unaffected.
Enabling it requires two things beyond the stateless prerequisites:
| Config / setting | Purpose |
|---|---|
code_interpreter.stateful (gateway config, boolean, default false) |
Per-gateway opt-in, layered under code_interpreter.enabled — a stateful-on gateway that isn't offering the tool at all can never mint a kernel. |
| Session signing key (deployment setting) | Gateway-only secret from which the opaque session token is derived. Unset → stateful sessions are silently unavailable (the gateway falls back to the stateless one-shot path); stateless is unaffected either way. |
When both are set and the request has an authenticated tenant, conversation, and user, the gateway mints a per-(tenant, conversation, user) session token — bound additionally to the conversation's project when it is in one — and threads it to the runner; a missing principal falls back to stateless (never a mis-scoped kernel). A conversation whose project binding cannot be confirmed gets no persistent kernel (stateless).
Isolation (per user, not per conversation). The token is "v1:" + HMAC-SHA256(key, "sess:v1:" + tenant + \x1f + conversation + \x1f + user), with + \x1f + "proj:" + project appended for a conversation in a project. Because user is in the pre-image, a different participant in the same live-shared conversation derives a different token → a different kernel → they structurally cannot read each other's variables. The token is an opaque, unguessable map key — the runner never receives the tenant/conversation/user and does not (and cannot) verify the HMAC; the trust boundary remains mTLS + the client-CN pin exactly as for the stateless path. A tampered or guessed token simply misses the runner's session map and gets a fresh kernel — never someone else's. Because the project is in the pre-image, a conversation moved to another project or detached (or whose project is deleted) derives a new token and starts a fresh kernel: variables loaded inside a Local only project — including its raw files — are never visible to a later turn outside it.
Request additions (session mode). Alongside the stateless {code, stdin, limits} body, a session request carries session (the token) and, on a kernel-creating run, session_tags (three opaque HMAC correlators — conv_tag, user_tag, tenant_tag) the runner records so an erasure can destroy kernels by conversation / user / tenant. These are HMACs, never raw ids — the only widening of the data-minimized wire, EU-resident and mTLS-only. A request with no session is byte-for-byte the stateless body.
Response addition. The runner may return kernel_reset: true when it spawned a fresh kernel for this run (first use, idle-evicted, the conversation moved to another project, or a wall-clock timeout wiped the namespace — a timeout SIGKILLs the kernel, so any timeout loses all persistent state). The gateway surfaces a one-line honesty note to the model ("variables from earlier turns are not available; re-create what you need"). A stateless or older runner omits the field → treated as no reset.
GDPR teardown (Art. 17). Kernels are ephemeral (idle-evicted, never persisted to disk beyond the VM's discarded overlay), but the gateway also actively destroys them on the three erasure events — and, for the conversation scope, when a conversation PATCH moves the conversation to another project or detaches it (capacity hygiene: the old kernel is already unreachable) — by calling POST <runner>/v1/session/destroy with { "scope": "conversation" | "user" | "tenant", "tag": "<the matching HMAC tag>" } (same mTLS + CN pin). The tag is computed from the erasure event's tenant/conversation/user via the same derivation, so no gateway-side session tracking is needed and a cross-tenant destroy is impossible (every tag embeds the tenant in its pre-image). The call is best-effort / fail-soft: a runner-unreachable teardown is logged loudly for the retention audit but never blocks the database erasure.
Accepted / rejected (session inputs, at the runner boundary): the runner validates the token shape only (v1: + 64 lowercase hex) fail-closed — a malformed token is a 400; a well-formed but unknown token misses the map and spawns a fresh kernel. The destroy body is validated fail-closed: scope must be one of session/conversation/user/tenant, and tag must be a token (session scope) or a 64-hex tag (the others); anything else is a 400. Capacity is bounded (a small ceiling of live kernels sized to the runner's memory, plus per-tenant and per-user caps); exhaustion returns a clean "temporarily unavailable", never a queue or crash.
The side-channel residual of co-resident per-user micro-VMs on a shared host is a documented, accepted risk for the demo / internal gate (the feature is not enabled for production PII tenants without dedicated-host / SMT-off mitigation).
Context compaction
Context compaction automatically summarises older conversation turns when the estimated input token count exceeds a configured threshold. This keeps long conversations within model context limits while reducing the cost of each subsequent turn.
Context compaction is available for Anthropic models that support the native compact_20260112 strategy only. For other providers — and for Anthropic models without that strategy (for example claude-haiku-4-5, claude-sonnet-4-5, claude-opus-4-5) — the setting is present in the config but injects nothing.
| Field | Type | Default | Description |
|---|---|---|---|
context_compaction |
object | {enabled: true, threshold_tokens: 200000, keep_last_turns: 10} |
Context compaction settings. When the key is absent (or is not an object), the default applies. Set enabled: false — or the key to JSON null — to disable. |
context_compaction.enabled |
boolean | true |
Activate automatic context compaction for this gateway. Strictly boolean: only true enables; any other value (1, "true", null) leaves compaction off. |
context_compaction.threshold_tokens |
integer | 200000 |
Trigger compaction when the estimated input token count reaches this value. A whole number from 50000 (Anthropic API requirement) to 9007199254740991; null or absent = 200000; anything else is refused on write with 400, and a legacy stored malformed value is read as 200000 (logged). |
context_compaction.keep_last_turns |
integer | 10 |
The number of most recent turns the gateway keeps when it recovers from a context-window overflow. A whole number from 1 to 1000; null or absent = 10; anything else is refused on write with 400 (code: invalid_config, field: context_compaction.keep_last_turns), and a legacy stored malformed value is read as 10 (logged). It is not forwarded to Anthropic, whose native context management governs the compaction itself. |
tracing.retention_hours |
integer | 48 |
Accepted as sent; it currently has no effect on retention. The admin UI offers a whole number from 1 to 720. |
See Context compaction on the Anthropic provider page for background and behavioural details.
Compaction retry threshold
compact_error_threshold (top-level integer, default unset = off) is a per-request token budget for API clients that can compact their own history (Claude Code and similar /v1 clients). When a client's conversation outgrows the budget, the gateway asks it once to compact, using the standard 400 context_length_exceeded error. Such clients react to that error by summarizing their history and retrying.
Accepted values: an integer from 1 to 10000000, or 0 / null / unset to turn the gate off. Any other value is rejected with 400 on create and update (validated config fields). If a malformed value is already stored, the gateway treats the gate as off and logs a warning.
Who it applies to: requests authenticated with a gateway API token (the credential a /v1 client such as Claude Code holds). The workspace chat (its session token), agents and sub-agents, Copilot and other requests authenticated as a signed-in user are never gated, because they cannot compact on request. Requests that ask for the gateway's web search - the x-aig-web-search header, or a gateway with web search enabled in mode always (no header needed; not when the request declines all tools with tool_choice none, since no search runs then) - are also never gated: the provider counts the search results it reads, and the client never re-sends them.
How it behaves, per API token:
- Over budget → flagged, not refused. The gateway measures each successful response, streamed or not. It uses the provider-reported input tokens of the turn's first model call: your conversation plus the gateway's own per-request content, such as injected tool definitions and the system prompt. If that exceeds the threshold, the gateway flags the session for 30 minutes. The response itself is delivered normally. Results of tools the gateway runs itself (web search, URL fetch, MCP, code interpreter) feed later model calls in the same turn. Your client never re-sends those results, so they do not count. A turn answered through the gateway's automatic web search has no model call without the results, so that turn is not measured at all. Some calls are neither measured nor gated: ancillary calls a client marks with
x-aig-leg(chat titles, follow-up suggestions), token counting (/v1/messages/count_tokens),/embeddingsand/models. A turn is also not measured when none of its model calls completed (or the gateway answered it with an error), when the provider reported no input usage, or when the gateway itself had to shrink the prompt (automatic context recovery). - Next request unchanged →
400 context_length_exceeded. The message asks the client to compact and retry. - Compacted retry → passes and clears the flag. A retry counts as compacted when its conversation is at least 25 % smaller than the flagged turn's. Both sides are measured the same way: over the conversation your client sent (system + messages), excluding anything the gateway adds. A resend that the gateway enriched with tools therefore never looks compacted by mistake.
- Client cannot compact → let through. The gateway asks only once per flag. If the client re-sends the same conversation after the
400, at any time while the flag lasts, the gateway lets it through and stops asking for 30 minutes. It also stops asking for 30 minutes when the client did compact but the turn is still over budget (for example because of the gateway's own per-request content). The client is never refused turn after turn. - Back under budget → all state cleared.
Limitations:
- The flag is per API token, not per conversation. Two conversations that run interleaved on one token share one flag, so a short request from one can clear the other's flag. Keying the flag per conversation is planned.
- Only chat-shaped requests (a
messagesarray) are measured and gated; the conversation is measured from theirsystemandmessages. Other request formats (audio, images, moderations, the Responses API'sinput) are outside the gate. - The flag lives on the gateway node that served the turn.
Choose a threshold above your gateway's fixed per-request overhead (tool definitions + system prompt). Otherwise every long-enough conversation is asked to compact once and then let through.
Prompt caching
Anthropic prompt caching writes frequently-used parts of the prompt (system instructions, large context blocks) to a cache and bills cache reads at a steep discount. It is on by default; configure per gateway:
| Field | Type | Default | Description |
|---|---|---|---|
prompt_caching |
object | {enabled: true, ttl: "1h"} |
Prompt-caching settings. When the key is absent (or is not an object), prompt caching is enabled by default. Set the key to JSON null to disable it. |
prompt_caching.enabled |
boolean | true |
Activate prompt caching for Anthropic requests. Send a real boolean: only false (or an omitted field) disables; any other value — including the string "false" — is read as enabled. |
prompt_caching.ttl |
string | "1h" |
Cache TTL for written entries. One of "5m" or "1h". The "1h" default applies when the whole prompt_caching key is absent; an explicit prompt_caching object that omits ttl (or carries an unrecognised value) caches with Anthropic's "5m" default. |
Per-request header overrides
These headers can be sent on individual inference requests to override gateway config for that request only.
| Header | Type | Description |
|---|---|---|
x-aig-byok-alias |
string | Use a non-default BYOK provider key alias for this request. Must match an alias stored for the resolved provider (424 provider_key_missing otherwise) and be 1 to 64 letters, digits, ., _, - (400 byok_alias_invalid otherwise). |
x-aig-meta-{key} |
string | Attach a custom key-value pair to the request log entry and make it available in routing rule conditions as meta:{key} (colon notation) and load-balancer sticky fields as meta.{key}. See the caps below. |
x-aig-collect-log |
on = 1/true/yes/on; off = 0/false/no/off (case-sensitive) |
"0", "false", "no" or "off" = skip writing this request to the log table entirely. 1, true, yes or on = log (default when the header is absent). Any other value (including an empty value) or a repeated header is treated as an opt-out, never as "log it": a malformed privacy switch must not log what you meant to withhold. The request is still served (never a 400) and a warning naming the header is written to the gateway log. The opt-out covers cached answers and everything from request processing on, including request-validation 400s, and passes to sub-agent runs. Everything before the cache check is always logged (authentication, IP allow-list, rate-limit, quota, agent-access, number/department/live gate and copilot-action refusals), except the 400 for a malformed x-aig-byok-alias and the refusals of x-aig-ghost-files (invalid_ghost_files, too_many_ghost_files, ghost_files_not_ghost, ghost_files_unsupported_type, ghost_files_too_large, ghost_files_spooled; 400/413/500), which honour the opt-out. The opt-out is not available on the agent-invoke, docs, Entra, sales and MCP-proxy lanes. |
x-aig-collect-log-payload |
on = 1/true/yes/on; off = 0/false/no/off (case-sensitive) |
"0", "false", "no" or "off" = log request metadata but omit the prompt and response body. 1, true, yes or on = log body (default when absent). Any value other than the on/off forms above (garbage, empty, repeated header) omits the body, exactly like "0". Does not affect the gateway-level log_payloads setting. Also strips trace-step content for the request. |
x-aig-provider-{field} |
string | Strip the x-aig-provider- prefix and forward the header to the upstream provider only if the stripped name is allow-listed (anthropic-beta, openai-organization, openai-project). Any other stripped name — a credential, a request-framing / hop-by-hop header, or an unrecognised name — is dropped and logged at warn, so a client can neither inject an upstream credential nor tamper with request framing. At most 16 overrides / 8 KB total per request. Useful for provider-specific beta flags. |
💡 Note: An allow-listed
x-aig-provider-*header is forwarded to whatever provider handles the request, not just the one the name belongs to — except the gateway's own inner calls (the agentic-fetch read, the compaction summary), which receive at mostopenai-organization/openai-project, and only when they use the request's own key. Sendingopenai-organizationto an Anthropic request is harmless (the provider ignores the unknown header). Only the three allow-listed names are ever forwarded.🔒
x-aig-meta-*accepted shape and caps. Client metadata is sanitized at the trust boundary before it becomes a routing input or is persisted to the request log:
- Value — a single string. If the same
x-aig-meta-{key}header is sent more than once, only the first value is used; a value longer than 256 characters is truncated on a UTF-8 character boundary (invalid byte sequences are scrubbed).- Key — the
{key}suffix must be at most 64 characters; a longer key is rejected (dropped, not truncated, so it can never collide with another key or a routing rule).- Count — at most 16 client metadata keys are kept per request. When more are sent, a deterministic subset (the keys sorted lexicographically, first 16) is kept so the same request always routes identically.
- Reserved keys — these are gateway-owned and are dropped if sent by a client: any key beginning
aig_/aig-;spend_read_degradedandspend_unverified; the guardrail protection markers (for exampleguardrail_gap,guardrail_degraded,guardrail_error); and the delegation-lineage keysdelegate_depth,parent_request_idandhuman_root.Over-cap or malformed metadata is dropped or clamped (never a 4xx), and the request log row is always written — an oversized
metaobject is bounded so it can never overflow the column and lose the row.
Knowledge-search reranking
Project knowledge search (hybrid dense + keyword retrieval) ends with a cross-encoder rerank stage that re-scores the fused candidate passages for relevance to the query and keeps the most relevant few. The same stage serves the in-product document search and the narrowing of a large named file. It is on by default and configured by a platform admin through the platform settings — there is no environment variable and no per-gateway field:
| Platform setting | Default | Effect |
|---|---|---|
rag_rerank_model |
bge-reranker-v2-m3 |
The reranker model id served by the EU model fleet. This is the on/off switch: blank (""), absent or malformed switches the rerank stage off and search returns exactly the hybrid-fused order. |
rag_rerank_top_k |
8 |
Passages kept after a rerank in the in-product document search (1–40). The sales endpoint keeps its own request top_k; file narrowing keeps every candidate. |
rag_rerank_timeout_ms |
5000 |
The read deadline of one reranker call (500–30000 ms). The connection and send phases are capped separately at 2 s and 5 s. |
vector_tier_threshold_chunks |
3000 |
Chunks in the shared embedding table from which a tenant is promoted to its own vector-index table (1000–10000000; a malformed stored value stops the promotion job rather than falling back). Small tenants stay on the exact scan (perfect recall, fast below ~3,000 chunks). |
vector_tier_auto_promote_enabled |
false |
Gate for the periodic vector-tier promotion trigger (JSON boolean only; a non-boolean is rejected with 400). Absent or blank is off; a malformed stored value stops the promotion drain (bad_setting, fail-closed) rather than defaulting to on. |
A rerank adds about 100–400 ms to a search (measured: median about 150–180 ms, 95th percentile about 265 ms for 20–40 candidates). The reranker response is treated as untrusted: if the reranker is unavailable, times out, or returns a malformed/incomplete response, retrieval fails open to the pre-rerank hybrid order — it never blanks or drops results and never fails the request. Each passage sent to the reranker is cut to its first 6 000 bytes (the reranker's context window); the full passage is still what you receive and cite.
💡 Note: If the reranker is slow rather than down, every search waits out the timeout before falling back — blank
rag_rerank_modelto stop paying that while the fleet is repaired, and restore it afterwards. The setting is per environment: blanking it on one environment does not change another.
Config and BYOK cache TTLs
These deployment-wide settings tune how long the gateway caches resolved config and decrypted BYOK keys. Both apply per instance, not per gateway.
| Deployment setting | Default | Effect |
|---|---|---|
| Config cache TTL | 30 (seconds) |
How long a gateway's resolved config is cached in memory on each gateway instance. An admin change takes effect at once on the instance that handled it; other instances, and a change written directly to the database, pick it up within this TTL. |
| BYOK cache TTL | 60 (seconds) |
How long a decrypted BYOK (provider key vault) key is held in the in-memory cache after decryption, so a burst of requests does not re-decrypt the stored key on every call. Deleting or replacing a key takes effect at once on the instance that handled it; another instance can keep using its cached copy for up to this TTL (see Deleting a BYOK key). |
Strict secret reads (AIG_CRYPTO_STRICT_READS)
Stored secrets (BYOK provider keys, MCP and OIDC client secrets, bridge credentials and similar) are sealed with the deployment master key. Older rows may still be in an older ciphertext format; a boot job rewraps them to the current format. This deployment-wide switch decides whether the gateway still accepts a legacy-format value when it reads a secret.
| Deployment setting | Default | Effect |
|---|---|---|
AIG_CRYPTO_STRICT_READS |
unset (off) | Unset or empty = off: legacy-format values are still read. Exactly 1 = on: a stored value that is not current-format ciphertext is refused with a typed error (invalid ciphertext format) that names the row, never the value. Any other value (true, yes, 0, ...) is invalid: the gateway refuses to start and the error log shows AIG_CRYPTO_STRICT_READS invalid. |
The setting is read at start-up; change it, then restart the gateway. /readyz shows the active state in the crypto.master_keys detail as strict_reads=on or strict_reads=off. It is set per environment on the host (for the integration environment the host variable is AIG_CRYPTO_STRICT_READS_INT); it is not stored in the database and not managed by the deployment pipeline. Turn it on only after the total line of the boot rewrap report shows strict_reads_gate=open (no legacy-format secret left and no errors).
Encrypted-secret writer (AIG_CRYPTO_WRITE_V3)
New secrets are sealed with the deployment master key. By default the gateway writes the older v2 ciphertext. This deployment-wide switch makes every writer emit the newer v3 ciphertext, which names the key it was sealed with, and makes the boot rewrap move stored values to the active key.
| Deployment setting | Default | Effect |
|---|---|---|
AIG_CRYPTO_WRITE_V3 |
unset (off) | Unset or empty = off: new secrets are written as v2, and the boot rewrap leaves v2/v3 values as they are. Exactly 1 = on: new secrets are written as v3:<key id>:..., and the boot rewrap re-seals v2 values and v3 values under another loaded key to the active key. Any other value (true, yes, 0, ...) is invalid: the gateway refuses to start, the error log shows AIG_CRYPTO_WRITE_V3 invalid, and the rewrap job refuses to run. |
The setting is read at start-up; change it, then restart the gateway. /readyz shows the state in the crypto.master_keys detail as write_v3=on or write_v3=off. It is set per environment on the host (for the integration environment the host variable is AIG_CRYPTO_WRITE_V3_INT); it is not stored in the database and not managed by the deployment pipeline. Turning it off again is safe: v3 values stay readable, and new writes return to v2. Turn it on only when every reader of the stored secrets understands v3 (see the ops rule in the internal secrets page). While it is on, a development or CI database that is not on the integration / beta / production key reports the few migration-supplied secrets sealed under the production key as failed rewrap rows; this is expected there and does not occur on the environment whose key sealed them.
Applying config changes
# Enable caching and set a budget
curl -X PATCH https://<your-gateway-host>/admin/v1/gateways/{id} \
-H "Content-Type: application/json" \
-d '{
"config": {
"cache_ttl": 300,
"budget_usd": 200.00
}
}'
# Disable authentication (development only)
curl -X PATCH https://<your-gateway-host>/admin/v1/gateways/{id} \
-H "Content-Type: application/json" \
-d '{"config": {"auth_required": false}}'
# Add an IP allowlist
curl -X PATCH https://<your-gateway-host>/admin/v1/gateways/{id} \
-H "Content-Type: application/json" \
-d '{"config": {"ip_allowlist": ["10.0.0.0/8"]}}'