OpenReceipt sub-tags: file-ext, streaming, router-decision

, 7 min read

The receipt envelope is minimal by default: the core payload records what the gateway did (model, provider, token counts, chain hash) and nothing application-specific. Three optional sub-tags give receipt readers more context about input types, streaming and routing, without breaking existing verifiers.

Updated July 2026. This post describes sub-tags as they shipped on the legacy v1 gateway-receipt envelope. The idea is unchanged, but the current wire format is the client-signed OpenReceipt v3 envelope, where registered sub-tags live inside the claims object (spec §4.3) instead of a top-level payload.subtags. The v1 examples below still verify, as v1 and v2 receipts do. The authoritative v3 sub-tag registry is in the spec at signedreceipts.org/spec.

Why sub-tags exist

The core OpenReceipt payload is deliberately narrow, so every verifier, however it was built, can parse and check any receipt. Adding required fields to the payload would break older verifiers that do not know them.

Sub-tags solve that. They live in an optional subtags object inside the payload. A verifier that does not understand sub-tags ignores the key; the signature covers the whole payload, sub-tags included, so verification still succeeds. A verifier that does understand them can read them for context.

Sub-tags are part of the canonical payload before signing, so they are tamper-evident: if someone changes a sub-tag value, the signature check fails.

The three sub-tags

file_ext

Type: string | null. The declared media type or file extension of the request’s main input, when that input is a file or binary blob rather than a text prompt.

It is set when the client sends a multipart or binary request and declares the input type in the X-CloakAPI-Input-Type request header. Without the header, file_ext is left out of the sub-tags object (the key is absent, not null).

Values follow RFC 6838 media-type subtypes: "pdf", "docx", "png", "mp3", "csv" and so on. The gateway does not check that the declared type matches the binary content; that is the client application’s job. The receipt records what was declared, not what was detected.

streaming

Type: boolean. true if the upstream provider returned the response as server-sent events (SSE), false if it returned one JSON body.

Streaming affects receipt completeness. When a response streams, the gateway records the receipt at first-chunk time, using the token counts from the provider’s usage field in the final chunk. If the provider leaves usage out of the final chunk, as some do for streaming responses, the receipt shows token_out: null in the core payload, and "streaming": true explains why.

The gateway sets this sub-tag whenever it can tell whether the response streamed. On non-streaming requests it is false, not omitted.

router_decision

Type in the v1 examples: string | null. A record of how the upstream provider was chosen for the request, when a routing step made that choice. The v1 examples below show it as a short rule name; the v3 registry in the spec defines the current shape.

If no custom rule fired and the default route was used, the field is the string "default". If routing was bypassed, for example because the client named a model and routing was off for that tenant, the field is left out.

Where sub-tags sit in the envelope

In the legacy v1 envelope, sub-tags live inside the payload object under the key subtags. Here is a v1 example with all three present; the v3 equivalent nests them under claims:

{
  "ver": "openreceipt/1",
  "kid": "2026-Q1",
  "payload": {
    "req_id":      "01HZ9QK4WMFVG3C8XSDQVT7R4P",
    "tenant_id":   "t_acme",
    "ts":          "2026-04-10T09:17:44.201Z",
    "model":       "gpt-4o",
    "provider":    "openai",
    "token_in":    2048,
    "token_out":   null,
    "token_cached": 512,
    "latency_ms":  1203,
    "prev_hash":   "sha256:a3f7e2b1...(64 hex chars)...",
    "subtags": {
      "file_ext":        "pdf",
      "streaming":       true,
      "router_decision": "cost-opt-gpt4o"
    }
  },
  "sig": "MEUCIQDx...base64url DER signature..."
}

JCS sorts keys lexicographically, so in canonical form subtags comes after token_in, token_out and token_cached, as the last key of the payload. A verifier that rebuilds the canonical form with any compliant JCS implementation arrives at the same order.

Backwards compatibility

  • A verifier built against the spec before sub-tags existed receives receipts where subtags may or may not be present. If its JCS implementation treats the payload as an opaque JSON object, it includes subtags in the canonical form and the signature checks out, without the verifier knowing what subtags means.
  • Receipts without sub-tags, because the feature was off or the request predates it, simply have no subtags key. A missing key is not an error, and verifiers must not require it.
  • On the v1 envelope the ver field stayed "openreceipt/1": sub-tags were a compatible extension within v1, not a version bump. The later move to the client-signed "v":"v3" envelope was a deliberate breaking change for two-party signing, not for sub-tags; in v3 the same registered sub-tags live under claims.

Implementation note. If your receipt consumer reads sub-tags, check for presence instead of assuming defaults. Check "subtags" in payload before reading any sub-tag, and check each field on its own, because single sub-tags can be absent even when the subtags object is present.

Enabling sub-tags

Sub-tags are optional and off by default, which keeps receipts minimal for readers who do not need the extra fields. A producer adds a sub-tag when the underlying data is available for a request. Turning one on affects later receipts only; it does not rewrite earlier ones.

If an integration depends on sub-tags, confirm they are present before you go to production. A receipt without an expected sub-tag is not a bug: it means the producer did not emit that field.

A receipt without sub-tags

A minimal legacy v1 receipt with no sub-tags is still valid:

{
  "ver": "openreceipt/1",
  "kid": "2026-Q1",
  "payload": {
    "req_id":      "01HZ9QK5BNZP2MK9RTDQWU8S6Q",
    "tenant_id":   "t_acme",
    "ts":          "2026-04-10T09:22:11.889Z",
    "model":       "claude-3-5-sonnet-20241022",
    "provider":    "anthropic",
    "token_in":    310,
    "token_out":   88,
    "token_cached": 0,
    "latency_ms":  541,
    "prev_hash":   "sha256:c4d8f1a2...(64 hex chars)..."
  },
  "sig": "MEQCIBzW...base64url DER signature..."
}

A verifier that canonicalizes the payload as opaque JSON checks both forms the same way. The only difference is what downstream readers can learn: tooling that reads router_decision sees no data for receipts without it, which is the right outcome for an optional field.

All postsRSS feed