Skip to content

Logs API

The Logs API provides access to the structured request log written by the log phase of the gateway. Each entry records full identity, routing, security, token usage, cost, and timing for one inference request.

Base URL: https://<your-gateway-host>/admin/v1


GET /logs

Returns an array of log entries in reverse-chronological order (newest first). Requires the REQUEST_LOGS_VIEW permission (by default the roles admin and tenant_admin). Non-admin callers are always scoped to their own tenant server-side; a spoofed tenant_id is ignored, and a caller with no tenant is refused 403 { "error": "forbidden" } (the query never runs). A platform admin may target one tenant with tenant_id or omit it (and an empty value) for a global, all-tenant view. The global view (and the CSV export) excludes synthetic fixture tenants — e.g. the e2e-synthetic monitoring prober — so it reflects real traffic; a tenant-scoped view (tenant_id=…) still returns them. The console export's column set is listed under Exporting from the console.

curl "https://<your-gateway-host>/admin/v1/logs"

Query parameters

Parameter Type Default Description
tenant_id string — Filter by tenant UUID. Honoured only for callers with the admin role; every other caller (including tenant_admin) is scoped to their own tenant server-side, and a caller with no tenant is refused 403. For an admin, anything other than empty (the global view) or a canonical UUID — including a repeated parameter — is 400 { "code": "bad_param" }.
gateway_id string — Filter by gateway UUID.
provider string — Filter by provider name (e.g. openai, anthropic).
model string — Filter by model name (e.g. gpt-4o).
status integer — Filter by HTTP status code returned to the client (e.g. 200, 429). Must be a three-digit code 100–599; anything else is 400 { "code": "bad_param" }.
blocked integer — 1 to return only blocked requests. Omit to return all. Any other value (including 0) is 400 { "code": "bad_param" }.
trace_id string — Return only the request with this trace id (the trace_id field of an entry; a workflow step's request_ref). Must be one canonical UUID (8-4-4-4-12 hex, either case); anything else — a repeated parameter, a shorter or longer value, a non-hex character, a trailing space — is 400 { "code": "bad_param" }, never the unfiltered log. Empty means no filter. The tenant scope above still applies: another tenant's request is simply not in the result.
guardrail_outcome string — Filter by guardrail result. One of: blocked, scrubbed, flagged, degraded, compliance, any; any other value is rejected with 400. blocked matches a refused request (blocked = 1). A request where a guardrail block only withheld a tool result without refusing it (marker guardrail_withheld) matches neither scrubbed nor flagged (nor blocked); find it with any. degraded matches requests that reached a provider without the protection they were configured to get — any gap marker below, a guardrail_verdict of error or indeterminate, or a truncated meta. A request refused before dispatch is never degraded, however loudly the detector failed: nothing left. compliance matches only the incident markers (today: pii_unmasked_egress_under_mandate) — the auditor's question, unmixed with scanner timeouts, and never time-bounded by default. any matches either: a guardrail fired or there was a gap. See Protection markers below.
since integer — Return only entries at or after this time, as Unix milliseconds. Defaults to 30 days ago when guardrail_outcome=degraded and no since is given: that filter reads the meta markers, which no index can serve, so an unbounded query would scan the whole request log. An explicit since is always honoured, however far back, and the admin console pre-fills the visible From date when you select that filter so the window is never applied silently. compliance and any are not defaulted.
until integer — Return only entries at or before this time, as Unix milliseconds. Use with since for a date range. A since / until that is present but not a plain integer of digits (a decimal, a sign, abc, a repeated parameter), or a since after until (with guardrail_outcome=degraded and no since: an until before that filter's 30-day default start), is 400 { "code": "bad_param" } — never read as "no bound".
metadata_only string — 1 to omit the heavy content columns from each entry (and to skip the X-Read-Reason requirement; each row carries has_content instead) — the prompt, the response, and also block_reason and guardrail_verdict. The meta protection markers are still returned as booleans; only guardrail_error's detector name is withheld, so an export filtered by the markers still says why each row is in it. Use for bulk export. 0 or absent returns every column; any other value (including true) is 400 { "code": "bad_param" }.
limit integer 50 Maximum number of entries to return. Maximum: 200 (a larger value is capped). Anything but a plain integer ≥ 1 is 400 {"code": "invalid_limit"}.
offset integer 0 Skip this many entries (for pagination). Anything but a plain integer ≥ 0 is 400 {"code": "invalid_offset"}.

💡 Note: All filters are optional and can be combined. The result is always ordered newest-first. A filter given twice (a repeated query parameter) or with an unaccepted value is 400 { "code": "bad_param" } — limit / offset answer their own invalid_limit / invalid_offset — so a malformed filter is never read as "no filter". An empty gateway_id / provider / model means no filter.

ClickHouse read path fails closed. When a log read is served from ClickHouse, the response is validated against the expected column schema before anything is returned. A page whose response body exceeds 32 MiB fails as a whole (nothing partial is returned), and so does a page in which a non-Nullable floating-point column carries a non-finite value (ClickHouse writes it as null). A cluster-mode read is refused unless the cluster has exactly one shard.

Reading content: the X-Read-Reason header

Any call that returns prompt or answer content (prompt, prompt_scrubbed, response, response_raw) needs a stated reason: GET /logs without metadata_only=1, GET /logs/{id}, and the trace detail GET /traces/{id} / GET /gateways/{id}/traces/{id} (see Playground). This is a breaking change for callers that read content: they now receive 400 until they send the header. metadata_only=1 needs no reason and reads no content.

Header Rule
X-Read-Reason Free text, sent once, percent-encoded UTF-8 (encodeURIComponent in a browser, because header values must be ASCII); the server decodes it. After decoding and trimming it must be 1 to 500 bytes of valid UTF-8 without ASCII control characters (U+0000–U+001F or U+007F). The header is the only channel: a ?reason= query parameter is ignored (URLs end up in access logs and browser history).
  • Absent, or empty after trimming: 400 { "code": "reason_required" }.
  • Malformed (header sent more than once, a raw byte outside printable ASCII, a bad %XX escape, an ASCII control character (U+0000–U+001F or U+007F), invalid UTF-8, more than 500 bytes after decoding, or more than 1,500 bytes as sent, checked before decoding): 400 { "code": "bad_param" }. The reason is never truncated or defaulted.
  • The reason is checked before anything is read, and a 404 (unknown or another tenant's id) writes no content-read row.

Body carrier (the web app). POST /logs/{id}/read and POST /traces/{id}/read return exactly what the matching GET returns, with the reason in a JSON body instead of a header: Content-Type: application/json and { "reason": "<text>" }. The reason is plain UTF-8 (no percent-encoding; a literal %41 stays %41). The body is the only channel, and the call is audited exactly like the GET (one request_log.content_read row, written before the content is sent). The GET with the header stays supported for API clients. Both carriers share one validator. Answers, all 400:

  • reason_required: no reason key, {}, an empty or whitespace-only body, or a reason that is blank after trimming.
  • bad_param: a reason that is not a string (including JSON null), more than 500 bytes after trimming, or an ASCII control character (U+0000–U+001F or U+007F) in it.
  • malformed_body: a body that is not a JSON object, unparseable JSON, or invalid UTF-8 anywhere in the body.
  • duplicate_key: the key reason repeated in the object.
  • unsupported_content_type: a non-JSON or absent Content-Type (checked even for an empty body).
  • pii_in_query: a ?reason= query parameter.

Every permitted read is written to the audit log as request_log.content_read before any content is sent. If that audit write fails the call answers a sanitised 500 and no content is returned (fail closed). The row's after holds reason and scope (detail, list or trace). A list read writes one row per tenant on the page with after.count and after.ids and no entity_id; an empty page writes none. A trace read is recorded with entity type playground_trace under the gateway's tenant.

Cross-origin browsers. When the admin API is called from a browser on another origin than the gateway (the SPA on its own host), the admin CORS preflight allows X-Read-Reason for the configured SPA origin only. The allowed request headers are this exact list, nothing else is granted and the browser's requested headers are never echoed back: Content-Type, Authorization, x-aig-token, x-aig-policy-conv-id, x-project-id, x-read-reason, x-aig-collect-log. A preflight that asks for any other header is not granted it.

GET /agents/runs result is not covered by this header; it is the agent's own work product, not request-log content.

GET /gateways/{gw}/agents/{agent}/runs/{run} returns the run's trace steps. For the agent's creator they are complete. For anyone else (for example a governance admin) the step bodies (prompt, tool arguments, answer) are returned only with a valid X-Read-Reason, and the read is audited as request_log.content_read under the agent's tenant. Without the header the steps keep only their metadata (step type, order, timing). A malformed header is 400 bad_param; a failed audit write is 500 and returns no bodies.

has_content

Under metadata_only=1 every row carries has_content (1 or 0): whether any of the prompt, the scrubbed prompt, the response or the raw response is stored and non-empty. It lets a console show "no content stored" without fetching the content. The same field (and the row id) is on each recent_blocked entry of stats.

Privacy mode (content_logging_disabled)

A workspace with privacy mode on stores no prompts or answers at all. Content stored before the switch was turned on is not purged and stays readable under the reason rule until the request-log retention removes it. block_reason and guardrail_verdict are not content in this sense and are unchanged.


LogEntry fields

Field Type Description
id string Unique log entry ID.
ts integer Request timestamp as Unix seconds (the stored millisecond value divided by 1,000 and rounded). Note that the since / until query bounds are milliseconds: multiply ts by 1,000 to use it as a bound.
tenant_id string Tenant UUID.
gateway_id string Gateway UUID.
provider string Provider that handled the request (after routing). For a row served from the gateway's response cache (cached = 1), this is the provider that produced the cached answer, not the request's routing alias — a cache hit and its original miss are attributed to the same provider.
model string Model sent to the provider (after routing/rewrite).
status integer The request's logical outcome as an HTTP status code. Normally the status returned to the client. The one exception is a streamed response cut off mid-answer: the wire already carried 200, so the row records the typed error status instead (for example 502 for a truncated stream), and its token usage counts what was delivered, estimated when the provider's closing usage never arrived.
cached integer 1 if the response was served from cache, 0 otherwise.
blocked integer 1 if the request was blocked before reaching the provider, 0 otherwise.
rate_limited integer 1 if the request hit a rate limit, 0 otherwise.
blocked_by string | null Which middleware blocked the request (rate_limit, ip_allowlist, guardrail, quota).
block_kind string | null Why the request was blocked, as a fixed value that is returned even with metadata_only: unconfigured (a fail-closed guardrail that is not set up), unavailable (a fail-closed guardrail that could not run), policy (a guardrail decided to block) or null (not blocked, or blocked by something that is not a guardrail, such as a budget or rate limit). Never carries request content.
block_reason string | null Block reason. pii_in_number means a request-phase regex or keyword scrub matched inside a JSON number, which is never rewritten, so the request was blocked. A keyword, regex, custom_pii or jailbreak block reads redacted:<type>:<12 hex>: the matched value is never stored, and the hex is a keyed hash scoped to the tenant, user and conversation. Rows written before this change may still hold the raw value until retention removes them. This route is gated by REQUEST_LOGS_VIEW, unchanged; the lower-privilege guardrail-events and stats reads withhold block_reason entirely.
meta object The guardrail protection markers for this request — see Protection markers below. When present it always carries at least guardrail_gap, and it is never null. Under metadata_only it carries the boolean markers but not guardrail_error.
guardrail_verdict string | null Verdict of the guardrail pipeline. null when no guardrail produced one — note that a keyword, regex, or PII guardrail can run, and even block, without writing this field; consult blocked_by and detectors_fired for those. One of safe, unsafe, error, or indeterminate. safe and unsafe are content verdicts from Prompt Guard. error means a guardrail backend could not be reached or failed. indeterminate means a guardrail backend answered, and the answer could not be read as a verdict — for example a classifier replica returning repetition garbage behind HTTP 200. When several guardrails run in one request, the health verdicts (indeterminate, then error) take precedence over the content verdicts, so a degraded scan is never masked by a later clean one.
detectors_fired array Names of all guardrails that produced a non-pass verdict (blocked, scrubbed, or flagged). Empty array when no guardrail fired.
scrub_applied integer 1 if a scrub action was applied by any guardrail, 0 otherwise.
input_tokens integer Prompt tokens consumed.
output_tokens integer Completion tokens generated.
cache_creation_tokens integer Prompt-cache write tokens (Anthropic) — the total of both TTL tiers (5-minute and 1-hour).
cache_read_tokens integer Prompt-cache read tokens (Anthropic).
cache_deletion_tokens integer Prompt-cache deletion tokens (Anthropic).
cost_usd number Estimated cost in USD for this request.
latency_ms integer End-to-end request latency in milliseconds.
upstream_latency_ms integer Time waiting for the provider only.
guardrail_latency_ms integer | null Time spent in Tier 2 guardrail sidecar calls, if any.
upstream_attempts integer Provider dials attempted (1 = no retries, >1 = retries/fallbacks, 0 = never dispatched). Failed dials counted from a later release on; older rows may show 0 despite real dials.
fallback_provider string | null Provider used after the primary failed, if any.
fallback_model string | null Model used on the fallback provider, if any.
saved_cost_usd number For cached requests: the cost that would have been incurred without the cache.
request_size_bytes integer Size of the request body in bytes.
trace_id string | null Links this log entry to a detailed execution trace. null when gateway tracing is disabled. See Traces API.
client_request_id string | null The caller's own correlation id — the X-Request-Id request header it sent, when that value conformed (a single header, ^[A-Za-z0-9._\-:+]{1,64}$). null (the key is absent on the wire, like every other null field) when none was sent or the value was rejected. Never the entry's id, which the gateway always mints itself (see client_request_id).
leg_kind string | null Set when the entry is a request the interface made on its own behalf rather than a message a user sent: followup_suggestions (the follow-up chips under an answer), title_generation (the automatic conversation title), compaction (an automatic history summarisation), or files_upload (a raw file upload to Anthropic's Files API that a Local only project refused — only the refusal is logged, as a blocked entry; nothing was sent, so it carries no tokens or cost). null for an ordinary turn and for every API caller. Apart from a refused files_upload entry, these are real, guardrailed model calls and are metered like any other — the field exists because they follow the turn they belong to, so "the newest entry" is often one of them rather than the request being investigated. Reported for filtering client-side; to query by it, use the leg kind on the legs of a request, which is indexed.
is_streaming integer 1 if the response was streamed, 0 otherwise.
api_variant string | null API surface the request used (e.g. the OpenAI-compatible or native Anthropic variant).
user_agent string | null User-Agent header of the client request, if sent.
client_ip string | null Client IP address recorded for the request.
referer string | null Referer header of the client request, if sent.
response_raw string | null Raw LLM response body before PII (personally identifiable information) token restoration. Only present when pii_protector is active and log_payloads: true.
prompt string | null The request's messages, flattened one per line as <role>: <content> (a structured content block array is JSON-serialised; a legacy completions prompt string is recorded as-is). null when log_payloads: false or the body carried neither messages nor prompt. Inline binary is never stored: a base64 attachment (a data:…;base64, URL, a native source.type: "base64" block, or any unbroken base64 run of 1 KiB or more) is replaced by [binary omitted: N bytes], leaving the block type and media_type in place so the entry still shows what was attached. Numbers inside a structured block are kept digit for digit. A malformed body that cannot be written out (for example one carrying NaN or Infinity) is recorded as [content not encodable], not as an empty prompt. Bounded (see below). See Accepted shapes.
payload_expired boolean true when the operator-run payload expiry (scripts/request_log_payload_retention.sh, default 14 days, not scheduled) deleted the prompt and response of this entry; false when the content is present and also when it was never logged. Returned on list rows, GET /logs/{id} and the request-detail view.
payload_expired_at integer | null Unix seconds of the expiry; null when payload_expired is false, and also when the stored marker is unreadable (not a positive integer below 1e11): such a row still reports payload_expired: true, without a date (and a gateway warning), never false.

The following fields are only returned by GET /logs/{id} (single-entry endpoint), not by the list endpoint:

Field Type Description
response string | null Provider response body. null when log_payloads: false, or when the content expired (see payload_expired).
prompt_scrubbed string | null Request messages after PII tokenization (tokens visible, original values absent). Only present when pii_protector detects PII. Inline binary is replaced by the same [binary omitted: N bytes] marker as prompt.

💡 Note: Request and response body content is only stored when log_payloads: true is set in the gateway config (the default). When disabled, all fields above are still logged but the prompt/response text is omitted. Individual requests can suppress payload logging with the x-aig-collect-log-payload: false header. Both switches also stop the turn's replay record from being stored, as does a malformed or inactive user or run-as id (see what is never recorded).

prompt — accepted shapes and what is rejected

The request body is untrusted input; the log entry is written for every request, including ones the gateway refused with 400, so the flatten is total — no body shape can cost the entry.

Body shape Recorded prompt
messages is an array one line per element, <role>: <content>. A content string is taken as-is; an array or object is JSON-serialised; a missing, null, numeric or boolean content contributes an empty line. A role that is not a string (missing, null, an object, a boolean) is recorded as ?. An element that is not an object is recorded as ?:. A content block cjson cannot serialise (NaN, Infinity, over-nesting) contributes an empty line.
messages is present but not an array (a string, a number, an object) Malformed, not absent: the value is JSON-serialised and recorded ("" if it cannot be serialised), and the gateway logs a warning. It is never silently dropped.
the body itself is a JSON scalar (42, true, "text") Malformed, not absent: the scalar is JSON-serialised and recorded, with a warning. (Such a request is refused with 400 before dispatch; its log entry is still written.) A body that is a JSON array carries neither messages nor prompt and is recorded as absent (null).
messages absent or null, legacy prompt is a string the string, as-is.
prompt is present but not a string (an object, an array, a number, a boolean) Malformed, not absent: JSON-serialised and recorded, with a warning. A non-string never reaches the database column.
neither messages nor prompt (or both null) null — absent is not malformed.

In every row above, inline binary is replaced after flattening: any ;base64, introducer and the bytes that follow it (at any length), and any unbroken run of the base64 alphabet (A-Z a-z 0-9 + / =) of 1 KiB or more, become [binary omitted: N bytes]. The scan sees through JSON escaping — a \/ for /, re-escaped up to eight nesting levels — so a serialised block array cannot smuggle bytes through by the encoding the gateway itself produces. Ordinary text survives because whitespace and punctuation break a run: prose, code, hashes, short IDs, JWTs (- and _ break a run) are untouched. What the rule does take, deliberately, is any 1 KiB+ unbroken stretch of that alphabet even when it is not an attachment — a very long number, a hex blob, a one-line PEM body — and what it does not take: a native source.type: "base64" block whose data is shorter than 1 KiB (under 768 bytes of binary: a favicon), and text a client pre-encoded with escapes the gateway never emits (\u002f, MIME line-wrapping) — accepted gaps, since the purpose is bounding what the gateway's own encoding stores, not defeating a client that chooses to bloat its own log. The four payload columns (prompt, response, response_raw, prompt_scrubbed) share one 12 MiB budget per entry, measured in escaped bytes — the entry is written as a single statement under the database's 16 MiB packet limit, and an entry past it was lost outright (not truncated) before this rule existed. Columns are filled in that priority order; a column cut to fit is named in the row's stored meta.aig_payload_truncated (an array of column names — again queryable by SQL, not projected by the API), so "the client sent less" and "the gateway cut it" are distinguishable. Invalid UTF-8 is scrubbed in the same pass. So an oversized or malformed payload can never cost the entry; at worst its payload text is shortened and the row says so. The same binary replacement is applied to prompt_scrubbed; response and response_raw are bounded but not scanned for binary — response is the delivered answer and is read back as the agent run result.

A request refused by a masking detector never stores the refused value in clear. When a regex or keyword detector with action: scrub (or any other detector that masks the request, such as a PII detector) refuses a request instead of masking it (for example pii_in_number for a card sent as a JSON number, or scrub_uncommittable for a keyword that appears as a JSON key), the stored prompt is written masked: the regex or keyword detector's own rule masks each message, and for any other masker, or when the match cannot be verified (a part in which a hit is still found after masking, also once JSON escapes are decoded at every level — for example a \uXXXX-escaped key), the whole message is replaced by [content withheld: refused by a masking guardrail]. When the rule finds the refused value in none of the messages (it sits elsewhere in the body), the whole prompt is stored as one placeholder (counted once in aig_prompt_withheld). Every message part is also replaced by the placeholder when a later masking detector of the request phase (including pii_protector, custom_pii or one added by a role) never ran because the refusal stopped the chain, since the prompt could still carry what that detector would have masked. This is deliberately over-redacting: the entry is evidence of the refusal, not a copy of the refused content. prompt_scrubbed is treated the same way: the rule masks it, or the whole value is replaced by the placeholder when the rule finds nothing in it, so the tokenized excerpt an earlier pii_protector stored, which can still carry a value only the refusing keyword or regex rule matches, never keeps the refused value. The count of withheld message parts (plus a withheld prompt_scrubbed) is recorded in the row's stored meta JSON as aig_prompt_withheld (absent when 0), queryable like aig_prompt_binary_stripped and not projected into the API's meta object. A refusal by a block action keeps the prompt as sent, as before. Refusals because a masker was unavailable (guardrail_unavailable) and pii_protection_required are not covered by this rule.

The same holds for a model answer refused by a masking detector. When a regex, keyword or presidio detector with action: scrub (or any other detector that masks the response) refuses the response instead of masking it (for example pii_in_number, scrub_uncommittable or response_number_not_exact), the stored response and response_raw are written masked, the same way as the prompt: the regex or keyword detector's own rule masks the text, and for any other masker, or when the match cannot be verified, the whole column is replaced by [content withheld: refused by a masking guardrail]. The same whole-column replacement applies when a later masking detector of that phase never ran because the refusal stopped the chain, since the stored text could still carry what that detector would have masked. (Unlike in the prompt, pii_protector and custom_pii only restore values in a response, so they do not count here.) The masked copy is the one used for the database row, the ClickHouse export and the SIEM event. The number of withheld columns is recorded in the row's stored meta JSON as aig_response_withheld (absent when 0), queryable like aig_prompt_withheld and not projected into the API's meta object. A refusal by a block action (including a presidio block) keeps the response as returned, as before. A live-streamed answer is not scanned by response-phase maskers, so this rule does not apply to it.

The number of replacements is recorded in the row's stored meta JSON as aig_prompt_binary_stripped (absent when 0) — queryable as JSON_EXTRACT(meta, '$.aig_prompt_binary_stripped') on request_log, like the other operational flags that ride meta (spend_read_degraded, empty_response); it is not a protection marker and is not projected into the API's meta object. So "the client sent no attachment" and "the attachment bytes were removed from this entry" are distinguishable in the database. Attachment content itself is not held by the request log at all: for a client that posted the bytes inline through the API, this entry is not a copy of them.

Shadow file-claim check keys (aig_cc_*, operational)

On a streamed Workspace turn the stored meta JSON of the entry can carry the file-claim check — operational flags like the ones above, queryable by SQL, not projected into the API's meta object, and not forgeable by a client (x-aig-meta-aig_* headers are refused):

On an entry judged inline (aig_cc_inline), the pre-filter keys (aig_cc_prefilter, aig_cc_reasons, aig_cc_placeholders, aig_cc_unfilled) and the verdict keys are as of the judge's decision; aig_cc_produced and aig_cc_shows_file are always end-of-turn values.

Key Value
aig_cc_prefilter "hit" or "miss" — the pre-filter ran on this turn. Absent = the turn was not eligible (not a streamed Workspace turn, the switch is off, or the turn errored, was blocked, cached, aborted, resumed, or asked not to be logged). A turn judged inline (aig_cc_inline) keeps its keys even when it then failed or was stopped.
aig_cc_reasons hits only: comma list of placeholder_unfilled, reply_file, reply_verb, user_file.
aig_cc_produced "true" when a tool really created or changed a file this turn (failed writes and re-served earlier files do not count) — at the end of the turn, a re-dial's or a Create it now turn's file included.
aig_cc_placeholders, aig_cc_unfilled counts of {{aig_file:…}} placeholders in the raw answer, and of those naming no file created this turn (malformed ones included); absent when 0.
aig_cc_verdict hits only, merged into the entry shortly after it is written (the judge runs after the response): "claimed", "not_claimed", or "none".
aig_cc_tense, aig_cc_upload, aig_cc_user_change, aig_cc_conf with a verdict: past/present/future/none, "true"/"false", "true"/"false", confidence "0.00"–"1.00".
aig_cc_err with "none": unconfigured, transport, request_shape (the judge request could not be encoded exactly, so nothing was sent; it never trips the circuit breaker), timeout, http_<status>, malformed (the judge's answer was rejected), capacity, error, premature (the gateway worker was restarting), spilled (the entry was held in the spill area because the database was briefly unavailable, so the judge never ran for it), test_seam (test deployments only).
aig_cc_judge_ms the judge call's own duration. For a judge that ran after the response it is not part of latency_ms; for an inline judge (aig_cc_inline) it is the time the end of the answer waited.
aig_cc_shows_file "true" when the turn shows a file — one it created or changed, or a re-served file card (a failed write does not count). Taken at the end of the turn, so a re-dial's or a Create it now turn's file is included; the re-dial and the note only act when no file is shown at the moment the inline judge decides — whether the action then worked is aig_cc_redial_produced_file / aig_cc_click_produced_file.
aig_cc_inline "true": the judge ran before the end of the answer and its verdict could act (re-dial / note). The verdict keys are then on the entry from the start.
aig_cc_inline_err with aig_cc_inline: the inline judge produced no verdict (timeout, transport, http_<status>, malformed, unconfigured, error, or breaker_open — the judge was skipped after repeated timeouts) — nothing acted; the verdict keys are then merged later by the after-response judge, as for any other hit.
aig_cc_test "true": the verdict came from the test-only seam (test deployments only) — exclude these entries from any evaluation.
aig_cc_redial_fired judged turns: "true" when the automatic re-dial was armed (claim + change request), else "false".
aig_cc_redial_dialled, aig_cc_redial_produced_file with a re-dial: whether the re-dial call actually went out, and whether the turn then showed a file.
aig_cc_redial_kind with a re-dial: "claim" (the answer claimed a file action), "promise" (it promised to write the file now) or "tool_claim" (it claimed a sandbox run although no tool ran) or "change_claim" (it listed requested edits as applied although no file changed; the re-dial is narrowed to the edit tools).
aig_cc_promise, aig_cc_waits with a verdict: whether the answer promised to write the file now, and whether it waits for the user ("true"/"false").
aig_cc_sandbox_claim the sandbox judge's verdict on the answer: "true"/"false", or "none" when it ran and gave no verdict. Absent = the sandbox call did not run.
aig_cc_sandbox_ms, aig_cc_sandbox_err the sandbox call's own duration, and its error class (malformed, breaker_open, spawn, error, or the transport error class of the call) when it gave no verdict.
aig_cc_change_claim the change judge's verdict on the answer: "true"/"false", or "none" when it ran and gave no verdict. Absent = the change call did not run.
aig_cc_change_ms, aig_cc_change_err the change call's own duration, and its error class (malformed, breaker_open, spawn, error, or the transport error class of the call) when it gave no verdict.
aig_cc_change_note "true": the honest "no file was changed" note was appended to the answer.
aig_cc_tool_note "true": the honest "no tool was run" note was appended to the answer.
aig_cc_connector "true" when a connector (MCP) tool ran this turn; absent otherwise.
aig_cc_badge_shown "true" when the answer was committed with the "No file was created" note.
aig_cc_badge_clicked, aig_cc_click_produced_file on the turn a Create it now click started: "true", and whether that turn produced a file.

A verdict from the judge that runs after the response is merged into MySQL only (not into the optional ClickHouse mirror). Inline verdicts and the outcome keys ride the entry itself, so they reach the mirror with it. Nothing is ever written to an entry whose user was erased. For a tenant with request logging disabled no entry is written at all, so none of these keys is stored for its turns (the check itself still runs — see request logs).

Tool call record (aig_tool_calls, operational)

Every turn that runs tools carries one meta key, aig_tool_calls: a string with one entry per tool call of the turn, in call order, entries joined by ,. It answers "what did the model actually do in this turn" (for example one 80 KB whole-file write_file against a 1 KB edit_file, a large read_file, or a repair loop) without a trace. Only tool names and sizes are stored, never an argument or a result.

<round>:<name>:<arg_bytes>:<result_bytes>:<outcome>
Field Meaning
round the tool round of the turn: 1 is reserved for the gateway-run knowledge presearch (search_knowledge, absent when none ran), which takes wall time like any other call; the model's tool calls start at 2; a call resumed after an approval keeps the round it was paused in; ? if unknown.
name the tool name as the model called it, if it consists of letters, digits, _, ., - and is at most 64 bytes; otherwise the marker invalid.
arg_bytes the size in bytes of the arguments exactly as the model sent them; ? if not known (for example a call resumed from an approval that no longer carries them).
result_bytes the size in bytes of the result that went back to the model; ? if nothing went back to the model for this call (held, dropped, aborted); for a call answered without running (deferred, repeat_stop, bad_input, length_cut) it is the size of that answer.
outcome one of the values below; ? for anything else.
outcome Meaning
ok the tool ran and returned a result.
refused the gateway refused the call (policy, a failed record write, a sub-agent that could not be resumed).
dup an identical side-effecting call was already done this turn; answered without running it again.
bad_input the arguments could not be decoded; the model got an error instead.
length_cut the call was cut off by the output limit; the model got an error instead.
deferred beyond the parallel-call cap of the round; answered without running.
repeat_stop the same call was repeated more often than allowed in one reply; answered with a note.
denied a human reviewer or the approval gate denied the call.
held the turn was suspended for a human review while this call was waiting.
dropped the turn was stopped before the call ran (time budget, round cap, spend cap, delegation deadline).
aborted the call was never reached (the client went away).
replayed on a resumed turn: the call had already run before the suspension and its stored result was returned.

A repeated-call loop stop is not a dropped call: it shows as the last round's real outcomes and the turn ends.

A call held at a suspension (including a sub-agent call whose child paused after it ran) appears as held on the suspending request's entry and again (as ok, denied, replayed and so on) on the entry of the request that resumes the run. The two entries describe different requests, so do not add them up as two calls.

The value never exceeds 4096 bytes, the per-key limit of meta. When the next entry would not fit, it and every later call are not listed; their number is in aig_tool_calls_more (a decimal string). An entry is never cut in half. A turn without tool calls has neither key.

Image-claim check keys (aig_ic_*, operational)

The image-claim check writes its own keys (never the aig_cc_* ones, and its turns are never judged again by the file arm after the response). Same rules as above: queryable by SQL, not projected into the API's meta, not forgeable by a client.

Key Value
aig_ic_prefilter "hit" — the image arm judged this turn (only written on a hit); "phrase" — the turn was selected by the "it is in the chat" phrase class and judged (the phrase alone never appends a note); "link" — the turn was selected by a markdown image link and judged (the link alone never appends a note): a relative or attachment: link, or an https: / sandbox: / data:image link on a request that did not name an image.
aig_ic_inline "true" — judged inline, before the end of the answer.
aig_ic_verdict "claimed", "not_claimed", or "none" (no verdict).
aig_ic_tense, aig_ic_user_image, aig_ic_conf the judge's tense, user_requested_image ("true"/"false") and confidence (2 decimals).
aig_ic_err why there was no verdict: timeout, transport, unconfigured, http_<status>, malformed, breaker_open, error, test_seam.
aig_ic_judge_ms the judge call's duration.
aig_ic_action "redial", "correct" (the honest note was appended) or "none".
aig_ic_det, aig_ic_corrected the deterministic guard recognised a phantom: its class (fabricated_markdown_image for new rows; older rows may also carry false_inline_claim, which no longer produces a note and is judged instead) and "true" when the honest note was appended. Written without a judge call (no aig_ic_prefilter / aig_ic_verdict).
aig_ic_after_redial "true" — the note was appended after a file re-dial or the "Create it now" click leg (judge-free; the row also carries the aig_cc_* keys of that turn).
aig_ic_redial_dialled, aig_ic_redial_produced_image on a re-dialled turn: the re-dial reached the provider; it produced an image.
aig_ic_test "true" — the verdict came from the dev/int test seam.

Two counters describe the conversation record: output_record_entries (entries composed into this turn's system prompt) and ghost_record_entries (entries of a ghost chat's note).

model_version — the served model revision (audit column)

request_log.model_version records the exact model revision the provider actually ran — for example claude-3-5-sonnet-20241022 when the request asked for the alias claude-3-5-sonnet-latest. It complements model (the resolved/requested id that was sent to the provider): comparing the two reveals what an alias resolved to at run time.

  • Source & accepted shape. Captured from the provider's response — untrusted third-party output. On a streamed turn it is the served model echoed in the stream: Anthropic's message_start.message.model, or the top-level model on an OpenAI-family chunk (every OpenAI-compatible provider surfaces it through the shared chunk parser). On a buffered turn it is the parsed body's model (every provider). Only a non-empty string is accepted; it is clamped to 128 characters. A missing value, a JSON null, a number, or an empty string is rejected and the column is left NULL (no distinct served revision observed). On a multi-leg turn (tool loop / failover) the last leg that carried a served revision wins, so model_version matches the model that produced the delivered answer (consistent with model / fallback_model).
  • Coverage. Populated for Anthropic turns of every shape (streaming, compat, native buffered); for OpenAI-family compatible streaming turns (the served model echoed on every chunk, surfaced through the shared chunk parser); and for any native buffered (stream:false) turn whose provider echoes model. It is left NULL only when the provider echoes no usable model (e.g. a buffered provider that omits it). For a pinned model the served id already equals the requested model, so model_version simply confirms it; the column earns its keep on aliases (e.g. -latest) where the two differ.
  • Access. This is an audit column on request_log, intended for direct SQL / analytics queries (SELECT model, model_version FROM request_log …). It is not currently returned by GET /logs or GET /logs/{id}.

client_request_id — the caller's own correlation id

request_log.client_request_id records the X-Request-Id request header the caller sent, when it conformed to the accepted shape (a single header matching ^[A-Za-z0-9._\-:+]{1,64}$; see the per-request headers). It is correlation only: the entry's id — and the X-Request-Id response header — is always the gateway's own id, so a caller cannot choose, repeat, or overflow the key of its own log row (before this change a repeated or over-long client id silently lost the row). A rejected value (empty, over 64 characters, other characters, or the header sent more than once) is dropped and logged server-side; the entry is written without a client id (client_request_id null — absent on the wire) exactly as when nothing was sent. The value is always returned as a string, even when it looks numeric ("007" stays "007"). Unlike the audit columns below it is returned by GET /logs and GET /logs/{id}, appears in the Logs page CSV export (Client Request ID), the tenant export (request_logs.csv) and JSON-format SIEM events; there is no API filter on it and no index — look a customer's id up in SQL or your SIEM within a time window.

token_agent_id — the bound-agent principal (audit column)

request_log.token_agent_id records the agent a per-agent token was bound to when it authenticated the request — the distinct verifiable principal behind the call. It is distinct from agent_id (the invoked agent): for a per-agent token invoking its own agent they match; for a normal/shared token it is NULL. See Per-agent tokens. Like model_version, it is an audit column on request_log for direct SQL/analytics, not returned by GET /logs.

aborted — client-cancelled vs empty completion (audit column)

request_log.aborted is 1 when the client cancelled the request after the response began streaming (for example pressing Stop) or disconnected while a tool loop was still running, and 0 otherwise. It exists to tell a cancel apart from a genuine empty completion among status: 200 rows: a post-header stream cancel is status: 200 with aborted: 1 (token counts are whatever the gateway metered for the output relayed before the Stop — see legs; a cancel before the first token has zero; repeat bytes the gateway withheld from the client — dropped copies of a repeating paragraph, held text — on a cut or aborted leg are billed by the same estimate), whereas a real empty answer is status: 200, output_tokens: 0, aborted: 0. A cancel detected before the response streamed lands as status: 499 (already counted by the client_aborted stats metric). Like model_version and token_agent_id, aborted is an audit column on request_log for direct SQL/analytics — it is not returned by GET /logs.

Protection markers — the meta object

GET /logs and GET /logs/{id} return a meta object answering one question: did the guardrail layer fully protect this request? A blocked or scrubbed request is easy to see — blocked, scrub_applied and detectors_fired all record it. A request the guardrails did not check is not: a detector that failed open, a masking pass that was deliberately skipped, or a scrub that could not be committed sets none of those columns, so it used to be indistinguishable from a clean pass. These markers are that missing fact.

guardrail_gap is always present. guardrail_gap_severity is present only when there is a gap. Every other key is either true or absent, never false — except guardrail_error, which is an object when a detector failed and absent otherwise.

meta key Severity Meaning
guardrail_gap — Always present (whenever this object is). true when the request reached a provider without the protection it was configured to get. false means the layer protected this request; it never means "not reported". The discriminator is dispatch, not blocked: a request refused before dispatch is never a gap — nothing left, even when the refusal happened because the detector errored and its fail mode is closed. A request blocked on the response phase, or by a rate limit, after the prompt already went to the provider, still is one.
guardrail_gap_severity — Present only when guardrail_gap is true: compliance, or degraded. The most severe gap marker on the row wins. info is a marker severity, not a gap severity, and never appears here. Absent whenever guardrail_gap is false.
pii_unmasked_egress_under_mandate compliance Unmasked personal data reached a third-party provider while a PII mandate was in force. An incident, not a diagnostic.
pii_scan_degraded degraded A PII masking layer could not run for this request — on the request/response phase, or at a tool seam whose fail-open forward let a web-search query or a tool result proceed unscanned.
guardrail_degraded degraded A detector errored and the request proceeded unchecked (fail-open). Also written for a tool-seam fail-open forward (the web-search query, a tool result, the prompt-injection scan of tool results) — for a PII forward only where the forwarded bytes actually leave the estate (not on a wholly-local model leg — a prompt-injection pass-through is recorded on every leg, since an unscanned injected result steers a local model just as well), not for a detector the agentic-fetch inner leg's own request phase runs again over the document (an enabled request-phase masker / an enabled injection classifier — that phase records any outage; a disabled or response-only one is re-run by nobody, so its forward at the seam is recorded), and never for content that did not leave after all: a query or result a later detector withholds, or a web-search turn whose later query is withheld (every query is then withheld).
guardrail_error degraded An object naming which detector failed: { "name": …, "error_class": … }. Last-writer-wins across the phases and seams of one turn: a tool-seam forward overwrites a request-phase detector's record on the same row.
scrub_uncommittable degraded A scrub matched but could not be written back without corrupting the document (a keyword/pattern hit a JSON key or delimiter), so it was not applied. On the request phase the request proceeded unmasked by that detector (tier 2 still masks); on the response phase the response was blocked instead of delivered corrupted.
presidio_no_scannable_fields degraded The request body carried text only in a carrier the scanner cannot read, so nothing was scanned.
presidio_response_shape_unrecognized degraded The response body decoded to JSON but matched no provider shape the content-only walker knows, so it was passed unscanned rather than rewritten (which would corrupt structure). Content may have reached the caller unmasked; the response phase never blocks.
aig_meta_truncated degraded request_log.meta exceeded its storage cap and was truncated, so some keys were dropped. Every other marker on such a row is therefore unknown, not false — and since guardrail_gap: false is a positive statement that the request was protected, a truncated row reports guardrail_gap: true with this marker as the reason rather than making a claim it cannot support.
pii_mandate_masker_unavailable info The masker that satisfies an active PII mandate could not run, so the request was refused rather than sent unprotected — or, at a tool seam, the model-generated web-search query or a tool result was withheld mid-turn rather than forwarded unscanned. Not a gap and not degraded — nothing egressed, which is the point. Recorded because the alternative outcome is invisible, and so that "this gateway refuses (or withholds) when Presidio is down" is attributable to the mandate rather than looking like a broken guardrail. This is the one place a detector's own fail_open: true does not win. A tool-seam withhold sets neither blocked nor a verdict nor any gap marker, so the withhold itself contributes to no guardrail_outcome filter arm (any included — the row can still match scrubbed when its request phase masked); it is visible as this key, as its badge in the log browser, and as a PiiServiceFailure row in the model-error triage queue.
pii_guardrail_failure info The request was refused because a PII masking detector (custom_pii, pii_protector, presidio) could not run and failed closed, or because the PII scan of stored content or tool labels could not run. Only on a blocked row; blocked_by is then the detector's name (or PII scan of stored content / PII scan of tool labels). The compliance report counts such a row under blocked_pii_gate (unless blocked_by is a rate limit, IP allowlist, budget or model block) and your SIEM receives it as PII_BLOCK. Rows logged before it existed do not carry it. API-only (no Logs page badge). Not a gap — nothing egressed.
pii_floor_forced_by_mandate info The German PERSON / LOCATION floor was applied to the model leg (a request- or response-phase scan, or a tool result bound for the model) because this request is under a PII mandate, not because of the detector's language. Correct behaviour and the point of the mandate — but it has a visible cost, since both types drop to the German 0.6 threshold and ordinary place names in English text are masked. Surfaced so an operator can explain masking they did not configure without reading source. Not a gap: protection was added, not lost. On a local-only gateway of an enforcing tenant a chat turn's model leg is exempt from the mandate (first-party inference), so this key is absent there even though the mandate is in force — see the next row; an agent-shaped run on that gateway (an invoke, a scheduled prompt task, the workflow copilot, a draft preview) is not exempt and does record it. Stamped only once every field's scan answered; an outage that a fail_open: true detector forwards leaves it absent.
pii_egress_floor_forced_by_mandate info The egress-leg twin of the row above: the floor was applied to the model-generated web-search query — bytes that leave for the search provider — because a mandate is in force, whatever the detector's language says. This is the leg a local-only exemption does not reach, so on a local-only gateway of an enforcing tenant a row can carry this key beside pii_floor_off_by_language: the model leg ran without the floor (exempt), the search query ran with it. Stamped only after the query scan succeeded; on a Presidio outage the query is withheld under a mandate, and where no mandate is in force a fail_open: true forward leaves it absent and records the gap markers instead. It records that the floor ran on the scan: on a gateway with two pii_protector detectors, a second detector's fail-closed withhold can still stop the query from egressing after the first stamped it. Not a gap.
guardrail_history_removed info A request-phase block detector matched only in earlier conversation turns, so those turns were masked or dropped before dispatch and the request continued. An array of { "detector", "type", "entries": [{ "index", "action" }] }; index is the 0-based position in the conversation array and action is masked or dropped; an item may carry "inserted": "removed" (the only value) when the gateway left the exchanges it re-inserted for earlier file edits out of the request, in which case entries may be empty and index counts positions in the conversation as sent to the provider, that is, without those exchanges (when this happens: Earlier conversation turns). Positions only, never the matched text. An array-valued marker (with guardrail_block_where and detector_types_fired the only non-boolean ones); it is capped at 4096 bytes encoded, and there is always exactly one item per detector that changed the history; when the list is too long the entries of all items are trimmed to a common length (possibly to "entries": []) and every trimmed item carries "truncated": true. If even the entry-less items of all detectors would not fit, the request is blocked (fail closed). A stored value that does not have this shape is dropped from the response (and logged), never returned half-valid. API-only: it is returned by GET /logs and GET /logs/{id} and the export, but the Logs page shows no badge for it. Not a gap: the matched content did not egress. See Earlier conversation turns.
guardrail_block_where info WHERE a keyword / regex guardrail's request-phase block matched: system:instructions, user, tool_result:<tool> or fetched:<host> (a string). It names the location only, never the matched term. It is written only when the location is known. Also written, on a request that was not refused, when a keyword / regex block in the agent's own tool loop withheld a tool result (tool_result:<tool> or fetched:<host>) or failed an agentic fetch (fetched:<host>); then it holds the first such location of the request, and it is dropped if the request is refused afterwards by a block that records no location (details). A stored value outside the closed format is dropped from the response and logged. Shown in the gateway's Show recent activity table (column Where) and next to the detector on the Logs page. Not a gap. See Keyword guardrail — match location.
detector_types_fired info The distinct detector types that fired on this request (keyword, regex, presidio, jailbreak, …): an array of strings, each type once, in the order the types first fired (detectors_fired can repeat a detector once per leg, phase or tool result; this list does not). A type is the detector's kind from the guardrail configuration, never request content; it tells you what a renamed detector is. Absent when no detector fired, when no fired detector has a recorded type, and on rows logged before it existed. A stored value that is not an array of 1 to 32 distinct type identifiers (lowercase letters, digits and _, starting with a letter, at most 32 characters) is dropped whole from the response and logged. Shown as the Type column of the guardrail events table (gateway Show recent activity, Dashboard and Live monitor Recent guardrail events). Not a gap.
guardrail_withheld info A guardrail block withheld content from the model without refusing the request: a tool result in the agent's own tool loop, or an agentic fetch whose reader leg was blocked (the model gets Inner agent failed). Written for a keyword, regex or Presidio block (and any other detector that withholds through the tool-result scan's block path); the detector is in detectors_fired. A jailbreak / prompt_injection block of a tool result does not set it (it records no detector on the row). blocked stays 0 because the request continued. A boolean true, absent otherwise; an analyzer outage that withholds a result does not set it. Shown as Outcome Blocked (not styled as a refusal; Reason: withheld from the model; the request continued) in the guardrail events table (gateway Show recent activity; the strip above it counts the row as blocked), and as the result withheld badge on the Logs page. A row with this marker never matches the guardrail_outcome filter scrubbed or flagged; it matches any, and blocked only if the request was also refused. It stays set when the request is refused afterwards (for example by a response-phase block), so it can appear next to blocked: 1; the table then shows the refusal. Not a gap. See Keyword guardrail — inside the tool loop.
pii_floor_off_by_language info The mirror of the row above: some PII detector on this request ran without the PERSON / LOCATION floor, because it carries an explicit English language ("en", "en-GB", …; rows written before this release carry it for any explicit non-German language) and no mandate applied to that leg (on a local-only gateway of an enforcing tenant that is a chat turn's leg, never an agent-shaped run's). PERSON and LOCATION were then held to the English 0.9 confidence instead of 0.6 (or, on a detector whose ticked list omits them and whose selection does not bind, not analysed at all), so names and cities scoring 0.6–0.9 (typical for German or Danish ones) were not detected — and, on a masking detector, not masked. An explicit entity_score_thresholds override can still set a different bar for either type. Not a gap — the layer did exactly what it was configured to do — but the configuration reduces protection, and without this marker a request that lost the floor to a dropdown looked identical to one that never had a floor to lose. Read it as a fact about the request, not about one detector: on a gateway with two PII detectors it means some detector ran without the floor. It also appears for a response-phase scan, and for a presidio detector that blocks or flags when its ticked list names PERSON or LOCATION — binding suppresses the coverage union but not the 0.6 threshold, so such a detector stops acting on the German name band (for a flagging detector, "not masked" reads as "not flagged"). It is not written for a masking scan whose text read as non-English (German, Danish, Norwegian, Swedish, French or Dutch) — that scan got the floor from its content. It never appears for a leg that ran under a PII mandate, where the floor is applied regardless, nor for a bound detector whose ticked list names neither floor type, where the floor would have changed nothing. It describes the leg it ran on: on a local-only gateway of an enforcing tenant the model leg is exempt from the mandate while the web-search query is not, so one row can carry this beside pii_egress_floor_forced_by_mandate — both true. There is deliberately no matching audit-log event: the config-save boundary cannot see whether a mandate is in force, so a config-level "the floor was disabled" would be false on exactly the mandated tenants. The change itself is gated by a confirmation in the Guardrail Builder; an API PATCH and a guardrail-config import are not gated, so for those paths this marker is the whole record.
pii_masking_skipped_local info A masking detector was deliberately skipped on a leg of this turn that routed to a first-party local model, where the data does not leave the estate — so this is not a gap. Surfaced so that correct behaviour stops looking like a broken guardrail. It does not assert that every leg stayed local: a turn can carry this marker and pii_unmasked_egress_under_mandate, because the two count different detector sets.

The privacy state of a chat turn (meta.privacy_state)

A turn sent from the web app chat also records which privacy mode the composer showed when the user sent it, beside what the gateway applied. This answers "I switched privacy off but the answer was still masked" from the log row alone. It is a record, not a guardrail: it never changes routing, masking or the answer, and it is not a protection marker (so it never sets guardrail_gap).

"privacy_state": {
  "ui": { "mode": "public", "control": "pill", "outcome": "blocked", "block": "busy" },
  "applied": { "served": "upstream", "mode": "masked", "mandate": true, "overrides": { "status": "ok", "unmask_requested": 0, "unmask_honored": 0, "unmask_denied": 0, "mask_requested": 0 } },
  "mismatch": "mandate"
}
Key Meaning
ui.mode protected, masked or public: the mode the composer showed at send.
ui.control, ui.outcome, ui.block The last privacy control the user used since the previous turn (pill or switch), whether it switched the mode or was blocked, and why (for example busy while an answer was being written). All three are absent when no control was used.
ui is the string "invalid" The client sent the header but not in the exact format. The value is never echoed; the row records only that it was unusable.
applied What the gateway did: served (upstream, cache or refused), the mode it applied, whether a PII mandate was in force, and the counts of the turn's unmask / mask requests (overrides). unmask_requested is the number of distinct valid unmask values left after any value that is also asked to be masked is dropped (the mask request wins). overrides.status is ok for a well-formed override (an empty one, {} or two empty lists, is well-formed and records zero counts) and malformed when the override was not an object of unmask / mask lists or none of its entries was usable. mode and mandate appear only for a turn that reached a provider.
mismatch Present only when the shown mode differs from what was applied: mandate (a PII mandate masked a turn the user saw as public) or route (any other difference between the shown and the applied mode).

A request that does not carry the header (an API client, a background request of the chat interface, an older app build) has no privacy_state key at all. It is returned by GET /logs (also with metadata_only=1, which is what the Logs list sends and what a bulk export uses: the export carries the privacy state too) and GET /logs/{id}; it holds no message content. In the Logs list a row with a record shows a neutral shown: <mode> badge (a turn answered from the cache or refused says so in the badge, because nothing was compared there); a mismatch shows a warning badge naming the reason, and an unusable header shows an invalid badge.

Filter for the gap rows with guardrail_outcome=degraded; they are also included in guardrail_outcome=any. The verdict (error / indeterminate) and the failed detector name are compared byte-exact: a verdict of ERROR is not a gap, an all-space detector name is one. This is the same rule that the meta decoding below applies. A boolean marker counts unless it is absent, null or false; a malformed value (for example the string "true") counts as set, so it fails closed as a gap or incident and never reads as protection. Use guardrail_outcome=compliance for the incident markers alone.

meta is present only when the endpoint projects it. GET /logs/{id} always returns it, and so does GET /logs — under metadata_only with the boolean markers only (no guardrail_error). On GET /gateways/{ID}/guardrail-events it is returned only to callers with the REQUEST_LOGS_VIEW permission — and those callers also get the gap events themselves, while a caller without it sees the narrower "a detector acted" event set that endpoint has always returned. A row is never handed back with a gap it cannot explain.

What is deliberately not returned. guardrail_error.message is the verbatim, unbounded response body of an untrusted guardrail backend and can echo the scanned text, so only name and error_class cross the wire. The meta object is a curated set, not a passthrough of the stored column: client-supplied x-aig-meta-* values and the gateway's operational diagnostics (aig_stream_error, aig_no_dispatch, aig_mcp_policy_dropped, aig_prompt_binary_stripped, aig_payload_truncated, threat_taxonomy, spend_read_degraded, spend_unverified) are stored on the row and reachable by direct SQL (JSON_EXTRACT(meta, '$.<key>')), but are not part of this response.

Rejected at the write boundary. Two separate guarantees, and it is worth being precise about which is enforced where. A client cannot forge these keys: an x-aig-meta-* request header that would land on one of them is dropped at the trust boundary, so every value in this object is gateway-authored. Within the gateway, all marker writes go through one shared writer that refuses a key outside the set above — that keeps a new marker from being stored in a form no reader knows how to return, but it is a single-writer convention enforced by review, not something the language prevents.

Rejected filter values. guardrail_outcome accepts only the six values listed above (blocked, scrubbed, flagged, degraded, compliance, any). Anything else is 400; it is never silently ignored, because an ignored filter would answer "how many requests bypassed protection?" with the unfiltered log.


GET /logs/{id}

Returns a single log entry by its ID. Requires the REQUEST_LOGS_VIEW permission (by default the roles admin and tenant_admin); non-admin callers may only read entries belonging to their own tenant.

curl "https://<your-gateway-host>/admin/v1/logs/log_abc789"

Requires the X-Read-Reason header (400 without it; the read is audited). POST /admin/v1/logs/{id}/read with { "reason": "..." } is the same read with the reason in the body. Returns a LogEntry object. The single-log response is narrower than a list row — it omits trace_id, rate_limited, is_streaming, api_variant, user_agent, client_ip, referer, and leg_kind (use the list endpoint when you need those); client_request_id is on both. Returns 404 { "error": "not found" } if the id does not exist or belongs to another tenant (identical answer, recorded as access.denied); 503 on a storage failure; 500 if the audit row cannot be written (no content is returned). A platform admin can read any tenant's entry.


GET /request-logs/{id}/legs

Returns the per-leg billing ledger for a single request, ordered by sequence ascending. One request can produce several legs — the primary provider call, any fallback attempt, each round of a server-side tool loop or length-cap auto-continuation (every model round the gateway makes in one turn is its own dispatch the provider bills separately), and side services (guardrails, web search) — each recorded as its own row. Use this endpoint to break a single LogEntry down into its individual provider/service calls and their costs. The parent LogEntry input_tokens / output_tokens / cost_usd are the sum across every leg of the request. If the client disconnects mid-stream, the output generated before the disconnect is billed as a partial leg (status 499, error_class cancelled). Where the provider had already reported usage for the cut leg, that is billed; where it had not yet (OpenAI-compatible endpoints send usage only in a trailing chunk), the gateway estimates the tokens from the output it had received from the provider before the Stop (streamed: what was relayed to you; buffered: what the gateway had collected so far) and the request it sent (about 3.5 characters per token). A stopped turn is therefore never free, and you are never billed for output the gateway had not received: notes the gateway wrote itself (for example the hint appended when a model ended its turn with only an unparseable tool call) are shown to you but never counted as output tokens. A cancel before the first token is billed only what the provider reported (typically nothing).

A leg's creation time is the time of the request, also when the entry was held briefly in the spill area during a database fault and written later; its department is the one the user belonged to at request time (see Request pipeline). If that department could not be decided at request time (the lookup failed, or the database could not be reached), the parent entry's meta.aig_spill_department_at_replay is true.

Requires the REQUEST_LOGS_VIEW permission (by default the roles admin and tenant_admin). Non-admin callers may only read legs for a request belonging to their own tenant; another tenant's request answers the same 404 as an unknown id.

curl "https://<your-gateway-host>/admin/v1/request-logs/log_abc789/legs"

Response

Array of leg rows. Returns 404 { "error": "not found" } if the request log id does not exist, the same 404 if the caller is not an admin and the request belongs to another tenant (recorded as access.denied), and 503 { "error": "temporarily unavailable; retry later" } on a storage failure (a failed read; retry).

Field Type Description
request_log_id string Parent request log id this leg belongs to.
sequence integer Leg order within the request (0-based; the first leg is 0).
tenant_id string Tenant UUID.
gateway_id string Gateway UUID.
conversation_id string | null Conversation the request belongs to, if any.
user_id string | null User attributed to the request, if any.
token_id string | null Auth token used, if any.
trace_id string | null Linked execution trace, if tracing is enabled.
turn_id string | null Conversation turn id, if any.
kind string Leg kind — e.g. main (the request's own model call), tool_loop (a model call after a server-side tool ran), continuation (a length-cap auto-continue), compaction (the gateway's conversation-summary call), agentic_fetch_inner (the model call that reads a page for the agentic web fetch), an interface-made call (followup_suggestions, title_generation), or a side-service call: pii_scrub (a PII detector), guardrail (a prompt-guard or prompt-injection check), document_extract (document text extraction or OCR), web_search_query (a web-search request) or code_interpreter. The gateway's inner calls (compaction, agentic_fetch_inner) are billed legs like any other. The media legs — one leg per request the gateway sends to a self-hosted media service, never billed (zero tokens and cost), metadata only (no prompt, no image, no hash): image_generation / image_edit (service flux, model the image model; a refused (error_class busy) attempt and its one retry are two legs), background_removal (service bgremove, model birefnet), and video_generation (service video; the video submit only — the clip renders asynchronously afterwards, so an accepted leg means "job started", not "clip made"; model is the model the video service confirmed, null when it confirmed none or refused the submit). The kind is the tool's mode (generate / edit / background removal / video). A request the gateway refuses before calling the service (no image attached, an invalid argument) has no leg. Media legs are never billable, so the usage views list them only with billable_only=0, or in the per-service view; with billable_only=0 the per-token / per-user / per-agent views need a model, so a video_generation leg without a model shows only per model (as myra / no model) and per service. The seed and the edit source are not on the leg: they are recorded with the stored image (seed, source_sha256, sent_sha256 on the image). Pairing the two is a database-level join (the image's internal chat_generated_image.request_id is not returned by the API): it equals the leg's turn_id when the leg has one, else its request_log_id, within the same conversation and tenant. The join is per turn, not per call — a turn with several image calls (or a busy retry) has several legs and images, and nothing pairs one leg with one image.
provider string Provider that served the leg.
model string | null Model used for the leg.
service string | null Service name for non-inference legs (e.g. web_search).
region string | null Provider region, if recorded.
residency_zone string | null Frozen dispatch-time model-residency zone: eu (positively EU-vouched), non_eu (positively non-EU — a US-owned provider, AWS Bedrock / Google Vertex / Azure in any region included, or a China host), or unknown (unprovable at dispatch — variable routing, a base-URL override, an OpenAI route sent to the gateway's own Azure endpoint (azure_endpoint), or a region-configurable/self-hosted provider). null for non-dispatch legs (guardrail, PII, search). Immutable evidence, computed at dispatch and never recomputed from current config. Covers the model-inference axis only. See EU data residency — Residency evidence.
tier string Pricing tier (standard when not set).
byok integer 1 if the leg ran on the workspace's own provider key (or its own model endpoint), 0 if Myra paid for it. Recorded from the key the call actually used, fallbacks included; legs recorded before October 2026 always read 0.
is_billable integer 1 if the leg is billable.
status integer | null HTTP status for the leg — the upstream's response status, or a gateway-synthesized status for a locally-terminated leg (a client disconnect mid-response records a synthetic 499, "client closed request"). null for a media-service request that got no usable answer (error_class transport).
error_class string | null Classified error, if the leg failed or was interrupted — e.g. cancelled (client disconnected mid-stream), stream_error (mid-stream read error), provider_error (the provider's stream emitted a mid-stream error event, e.g. Anthropic overloaded_error, on every route, native passthrough included, and it stays provider_error even if a finish chunk follows the error frame; the leg records the event's HTTP status — default 500 — instead of a misleading 200, and the request's status is 502), truncated (a streamed answer ended without its finish event — on the native Messages route without message_stop or with message_stop but no stop reason, on the native OpenAI-compatible routes with [DONE] but no finish reason (the bytes relayed to you are the provider's own and are never rewritten; the estimate appears only in the log row), on the chat-completions route without a finish_reason chunk, including a stream that does end with [DONE] (or, from an Anthropic upstream, message_stop) but never sent a finish reason or usage — so the answer may be incomplete; such a leg is billed from the gateway's estimate like any other cut leg, never as zero tokens, while the request's status and the relayed answer are unchanged; the leg keeps status 200 and sets partial to 1 when model answer text had already been delivered. On a streamed legacy /completions request that text is the choices[0].text of each chunk, so such a leg is billed from the estimate, not as zero output tokens. Whitespace-only model text counts as delivered; the gateway's own interrupted note never does. This applies to live and buffered streams alike. A stream whose finish arrived but only the closing [DONE] was lost stays a clean leg; so does, on the chat-completions route, an Anthropic upstream whose stop reason arrived (message_delta) but that lost only message_stop), tool_repeat_stop (the gateway stopped a model that repeated the same tool call), reasoning_runaway (the gateway cut a stream that produced only reasoning) and text_loop_stop (the model repeated the same paragraph, or the same block of 2 to 16 paragraphs, and the gateway stopped it at the fourth copy of the paragraph or once the block was written 3 times plus the first paragraph of a 4th copy; a block starting at the first or second paragraph is shown once, plus any cut-off start of a 4th copy, when the block-repeat guard drops its copies; when the 4th copy's first paragraph was held back and then released, the stop can come one paragraph later and that paragraph is shown) — each a deliberate stop with status 200 and partial 0; usage is estimated, except for a text_loop_stop whose loop was recognised in the chunk that already carried the provider's finish reason, which is billed from the provider's own usage; the leg's stop_reason is stop for a text_loop_stop whose provider finish was a length cap and otherwise the provider's own finish (content_filter, tool_calls) unchanged; a loop recognised only after the provider's stream had already ended (a dead leg, no finish) was not cut by the gateway and ends exactly like the uncut leg (truncated when the stream broke off before [DONE] or ended at [DONE] without a finish reason), billed like any other dead leg —, pods_unavailable (a guardrail leg whose self-hosted check service could not be reached), dead_turn_discarded (the leg was a dead turn, whitespace-only or empty with a stop finish, that the gateway discarded and re-dispatched once; it keeps status 200 and partial 0, is non-billable (is_billable 0), and the follow-up leg carries the answer; on a buffered or a live-streamed request alike), rate_limited, or an HTTP class. null on a clean leg. Media legs (image_generation, image_edit, background_removal, video_generation) use busy (the service refused for capacity, 429/503), transport (no usable answer: a connection or read failure, a timeout, a reply too large to read, a service address that could not be used) or failed (any other error status, or a 200 whose result the gateway rejected: not a usable PNG, an image outside the size limits, a video submit answer without a valid job id).
partial integer 1 if the leg was interrupted / incomplete (e.g. a client-aborted stream — the pre-abort output is still billed). partial counts relayed answer text only: a cut leg that had sent only reasoning or tool-call input records 0, and its error_class still marks it.
upstream_request_id string | null Provider-side request id, if returned.
input_tokens integer Prompt tokens for the leg.
output_tokens integer Completion tokens for the leg.
cache_creation_tokens integer Prompt-cache write tokens — the total of both TTL tiers (5-minute and 1-hour).
cache_creation_1h_tokens integer The part of cache_creation_tokens written with a 1-hour TTL. Priced once at the 1-hour cache-write rate; the remainder (cache_creation_tokens - cache_creation_1h_tokens) at the 5-minute rate.
cache_read_tokens integer Prompt-cache read tokens.
cache_deletion_tokens integer Prompt-cache deletion tokens.
units number | null Metered units for service legs.
unit_kind string | null Unit the leg is metered in.
price_input_per_1k number | null Snapshot input price per 1,000 tokens.
price_output_per_1k number | null Snapshot output price per 1,000 tokens.
price_cache_write_5m_per_1k number | null Snapshot 5-minute cache-write price per 1,000 tokens.
price_cache_write_1h_per_1k number | null Snapshot 1-hour cache-write price per 1,000 tokens.
price_cache_read_per_1k number | null Snapshot cache-read price per 1,000 tokens.
pricing_source string | null Where the price snapshot came from.
cost_usd number | null Cost in USD for the leg.
saved_cost_usd number | null Cost saved by caching on this leg.
currency string Currency of the cost figures (e.g. USD).
started_at_ms integer | null When the gateway sent this leg's call, in epoch milliseconds. Side-service and media legs derive it as the end minus the measured duration. null for legs without a call of their own and for rows written before this field existed.
ended_at_ms integer | null When the leg ended, in epoch milliseconds. null for rows written before this field existed or when the recorded value was invalid.
latency_ms integer | null Leg duration in milliseconds, exactly ended_at_ms - started_at_ms; null when started_at_ms is null or when the recorded value was invalid. Rows written before this change may hold the time since the request's first call instead.
started_at string | null Deprecated, always null. Use started_at_ms.
ended_at string | null Deprecated, always null. Use ended_at_ms.
created_at string When the leg row was inserted.

The endpoint returns the full ledger row, so additional identity and bookkeeping columns may also be present.


Examples

⭐ Example: The following examples show common query patterns for the Logs API.

Fetching the last 100 requests

curl "https://<your-gateway-host>/admin/v1/logs?limit=100"

Fetching logs for a specific gateway

curl "https://<your-gateway-host>/admin/v1/logs?gateway_id=gw_xyz789&limit=50"

Fetching only blocked requests for a tenant

curl "https://<your-gateway-host>/admin/v1/logs?tenant_id=3f6b2c1e-8a4d-4b7e-9c2f-1d5e7a9b0c3d&blocked=1&limit=50"

Fetching every request the guardrail layer touched — or failed to

# The guardrail acted (blocked / scrubbed / flagged) OR there was a protection gap.
curl "https://<your-gateway-host>/admin/v1/logs?gateway_id=gw_xyz789&guardrail_outcome=any&limit=50"

Fetching only the requests that were NOT fully protected

# "How many requests bypassed protection?" — a fail-open detector error, an uncommittable
# scrub, an unscannable body, or unmasked PII egressing under a mandate.
curl "https://<your-gateway-host>/admin/v1/logs?gateway_id=gw_xyz789&guardrail_outcome=degraded&limit=50"

Fetching only guardrail-blocked requests

curl "https://<your-gateway-host>/admin/v1/logs?gateway_id=gw_xyz789&guardrail_outcome=blocked&limit=50"

Fetching logs since a Unix timestamp (the since bound is milliseconds)

curl "https://<your-gateway-host>/admin/v1/logs?since=1742544000000&limit=200"

Fetching the last hour of OpenAI requests

SINCE=$(date -d "1 hour ago" +%s)000   # convert seconds to ms
curl "https://<your-gateway-host>/admin/v1/logs?provider=openai&since=${SINCE}&limit=500"

Paginating through a large result set

# Page 1
curl "https://<your-gateway-host>/admin/v1/logs?gateway_id=gw_xyz789&limit=100&offset=0"

# Page 2
curl "https://<your-gateway-host>/admin/v1/logs?gateway_id=gw_xyz789&limit=100&offset=100"

Example log entry

{
  "id": "log_abc789",
  "ts": 1742551232,
  "tenant_id": "ten_abc123",
  "gateway_id": "gw_xyz789",
  "provider": "openai",
  "model": "gpt-4o",
  "status": 200,
  "cached": 0,
  "blocked": 0,
  "rate_limited": 0,
  "blocked_by": null,
  "block_reason": null,
  "meta": { "guardrail_gap": false },
  "guardrail_verdict": null,
  "detectors_fired": [],
  "scrub_applied": 0,
  "input_tokens": 512,
  "output_tokens": 128,
  "cache_creation_tokens": 0,
  "cache_read_tokens": 0,
  "cache_deletion_tokens": 0,
  "cost_usd": 0.00448,
  "latency_ms": 842,
  "upstream_latency_ms": 780,
  "guardrail_latency_ms": null,
  "upstream_attempts": 1,
  "fallback_provider": null,
  "fallback_model": null,
  "saved_cost_usd": 0,
  "request_size_bytes": 1024,
  "trace_id": null,
  "client_request_id": "order-4711-retry-2",
  "is_streaming": 1,
  "api_variant": null,
  "user_agent": "curl/8.0.1",
  "client_ip": "203.0.113.7",
  "referer": null,
  "response_raw": null,
  "prompt": null
}

See also