> ## Documentation Index
> Fetch the complete documentation index at: https://docs.phala.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Verified upstreams

> How the gateway verifies a confidential provider before forwarding: the channel binding it enforces, the attested session it records, and the typed claims you read.

Every model on `https://inference.phala.com/v1` requires verified upstream serving.

When verified serving is required, the gateway verifies the upstream before it sends your prompt
and refuses to send if it cannot. Verification produces three things: a **channel binding** the gateway
enforces on the wire, an **attested session** it records, and the **typed claims** inside that
session. The receipt's `upstream.verified` event ties a response to all three.

## Channel binding

Verifying an upstream's attestation is not enough on its own: a genuine enclave could exist while
the gateway talks to a different server. Channel binding closes that gap. The value the gateway
verifies is the value it enforces on the connection before forwarding.

| Binding | What it is | How the gateway enforces it |
| - | - | - |
| `tls_spki_sha256` | SHA-256 of the upstream's TLS public key (SPKI). | Pins the upstream HTTPS connection to that key. |
| `e2ee_public_key_sha256` | SHA-256 of the upstream's end-to-end public key. | Encrypts the request body to that key, so only the attested enclave can decrypt it. |
| `proxy_image_sha256` (Privatemode) | `provider`, `proxy_image_digest`, and `credential_sha256` identify a co-deployed proxy and its credential. | Checks the credential and forwards only to the private proxy pinned in the gateway's measured deployment; the proxy verifies and encrypts the provider hop. |

The proxy binding covers the measured proxy deployment, not the specific provider workload that
served a request. An observed provider manifest alone does not establish that workload binding.

Every verified session carries at least one enforceable binding. A "verified" result without an enforceable binding is rejected in the gateway itself:
a provider can never be verified but unpinned. Which provider uses which binding is on the
[Confidential providers](https://docs.phala.com/phala-cloud/confidential-ai/confidential-model/providers.md) page.

The receipt’s `upstream.verified.required` records endpoint or request policy. It is `true` on a
TEE-only endpoint or with an ACI serving constraint; otherwise it is `false`, even when verification
succeeds. When verification is required, if the gateway cannot verify the
upstream or enforce the binding on the actual connection, it does not send your prompt. If the
binding stops matching, the gateway re-verifies before forwarding; retries cannot bypass this.

```mermaid theme={"system"}
flowchart TD
  A["Confidential request"] --> B{"Upstream verified<br/>and binding enforceable?"}
  B -->|"Yes"| C["Forward prompt over bound channel"]
  B -->|"No"| D["Reject. Prompt is not sent."]
```

### Confirm the binding

For a fail-closed client policy:

1. Verify the gateway attestation report and receipt signature, including the exact request and
   response hashes.
2. Require `upstream.verified.result: verified`, `required: true`, and a `session_id`.
3. Fetch the full session, verify its content address and evidence digest, and appraise
   `channel_binding` under your policy.

The [ACI TypeScript SDK](https://docs.phala.com/phala-cloud/confidential-ai/verify/verify-signature.md) and
[Private AI Proxy](https://docs.phala.com/phala-cloud/confidential-ai/agents/private-ai-proxy.md) implement client checks. cURL inspection alone does
not establish channel binding. On a TEE-only endpoint verification is required for every inference
request. On an endpoint where verification is optional, set `provider.aci_verified: true` to
require verified serving.

## Attested sessions

When the gateway verifies an upstream, it records an **attested session**: an immutable snapshot of
the verified channel. A session is the channel, not a model. One channel can serve many models, so a
router-backed provider can share one session across models, with the served model recorded on the receipt. A
session captures:

* the verified upstream identity and endpoint;
* the enforced channel binding;
* the typed claims about the TEE, each with its source; and
* the byte-preserving evidence the verifier checked.

The `session_id` is the SHA-256 of the full session document in canonical JCS form, as 64 lowercase
hex characters. Any change to the document produces a different id, so recomputing the hash proves
the session you fetched is exactly the one the receipt cited.

```text theme={"system"}
response  → x-receipt-id
receipt   → upstream.verified { result, required, model_id, session_id }
session   → { binding, claims (+ reasons), evidence }
```

Fetch [`GET /v1/aci/sessions/{session_id}`](https://docs.phala.com/phala-cloud/confidential-ai/confidential-model/api-reference/sessions) for the provider, binding,
claims, and evidence. You do not enforce the binding yourself; you confirm after the fact that the
gateway did: `result` is `verified` and the cited session carries the binding. Check `required`
to distinguish demanded verification (`true`) from a best-effort verified result (`false`).

## Claims

Claims are in the session cited by the receipt; the receipt’s `upstream.verified` event does not
embed the complete claim set. TCB means Trusted Computing Base.

A session never says "trusted". It carries a fixed set of claims, each with a `status` and, unless `unknown`,
a `source` and a `reason`, so a hardware-proven fact and an operator's assertion never look alike.

```json theme={"system"}
{
"tee_attested": {
  "status": "asserted",
  "source": "hardware_proven",
  "reason": "verified the TEE quote and bound the request channel"
}
}
```

| `status` | Meaning |
| - | - |
| `asserted` | The verifier's evidence backs this claim. |
| `refuted` | The evidence contradicts the claim, for example a stale platform TCB. Recorded, not hidden. |
| `unknown` | The claim was not established. Never a silent pass. |

| `source` | Assurance |
| - | - |
| `hardware_proven` | From the verified TEE quote or its collateral. Strongest. |
| `verifier_derived` | Computed by the verifier from verified evidence. |
| `provider_asserted` | Published by the provider, not independently proven. |
| `operator_asserted` | Declared by the gateway operator. Weakest. |

| Claim | Asks |
| - | - |
| `tee_attested` | Is a TEE identity bound to the channel, directly or through a measured proxy? Inspect the source. |
| `tcb_up_to_date` | Is the platform's Trusted Computing Base current? |
| `os_known_good` | Does the OS or platform image map to reviewed source? |
| `serving_software_known_good` | Does the serving software meet this verifier’s software acceptance policy? |
| `gpu_attested` | Which provider-specific GPU checks were accepted, and what do they establish? |
| `model_weights_provenance` | Are the served weights and quantization what they claim to be? |

Privatemode reports `tee_attested: asserted` with `source: verifier_derived` under
`privatemode-proxy/co-deployed-contrast/v1`. It relies on the measured co-deployed proxy and its
Contrast-attested secret path rather than a provider quote verified directly by the gateway.
Its other common claims remain `unknown`.

### TCB freshness

When a verifier reports a separate TCB status, `tcb_up_to_date` is tri-state: `UpToDate` asserts
it, another reported status refutes it, and an absent status leaves it `unknown`. Tinfoil is an
exception: its verifier requires an up-to-date TCB but exposes no separate status, so a verified
result asserts the claim with source `verifier_derived`.

### GPU attestation

GPU assurance depends on the provider and gateway release. Chutes and Phala record supplemental
nonce-matched GPU checks. The newer Chutes verifier authenticates NRAS platform JWTs. Phala's
generic path decodes tokens without checking their signatures. ArmetAI requires signed NRAS
verification and commits the GPU evidence into the CPU quote's report data.
Apply the [provider-specific policy](https://github.com/Dstack-TEE/private-ai-gateway/blob/main/docs/providers/README.md)
to decide what the result establishes about the serving workload.

If your policy requires direct hardware proof, require `tee_attested: asserted` with source
`hardware_proven`. Evaluate software, TCB, GPU, and model-weight claims independently.
See [Confidential providers](https://docs.phala.com/phala-cloud/confidential-ai/confidential-model/providers.md) for the coverage of each adapter.

### Fields to check in `extra`

For a Phala-direct session:

| Field | Expected | Meaning |
| - | - | - |
| `canonical_model_id` | Acceptable model mapping under your policy | **Verify this.** Naming may differ; see [model ids](https://docs.phala.com/phala-cloud/confidential-ai/confidential-model/attested-routing.md#list-the-models-you-can-use) |
| `tcb_status` | Acceptable under your policy | Platform TCB status reported by quote collateral; `OutOfDate` is not a freshness pass |
| `tdx_debug_mode` | `false` | `true` means debug mode, and confidentiality does not hold |
| `os_image_is_dev` | `false` | Reject development images in production |
| `production_os_image` | `true` | |
| `compose_hash_verified` | `true` | The measured compose matches what was declared |
| `report_data_nonce_matched` | `true` | The upstream evidence matches the upstream verifier's challenge; this is separate from your gateway-attestation nonce |
| `gpu_evidence_nonce_matched` | `true` when GPU evidence is present | Supplemental check reports a nonce match; not authenticated GPU identity or CPU binding |
| `tls_spki_from_report_data` | `true` | The TLS channel binding comes from hardware measurement, not a spoken claim |
| `trust_boundary` | `phala-dstack-cvm` | |

Which keys appear in `extra` depends on the upstream provider that served the session, so treat this
list as a starting point rather than a fixed schema.

### Inspecting the images in the measured compose

For a Phala-direct JSON evidence bundle, set `SID` to the session id cited by your receipt:

curl -fsS "[https://inference.phala.com/v1/aci/sessions/\$SID](https://inference.phala.com/v1/aci/sessions/\$SID)" \\
-H "Authorization: Bearer \$PHALA\_AI\_API\_KEY" \\
\| jq -r '.evidence.data' | sed 's|^data:application/json;base64,||' | base64 -d \\
\| jq -r '\[.all\_attestations\[] | .info.tcb\_info | (if type=="string" then fromjson else . end)
\| .app\_compose | fromjson | .docker\_compose\_file] | join("\n")' \\
\| grep -E 'image:|--served-model-name'

## Related

> [card] [Confidential providers](https://docs.phala.com/phala-cloud/confidential-ai/confidential-model/providers.md)
>
> Binding type and asserted claims per provider.

> [card] [Receipts](https://docs.phala.com/phala-cloud/confidential-ai/confidential-model/receipts-and-sessions.md)
>
> The `upstream.verified` event that cites a session.

> [card] [Session endpoint](https://docs.phala.com/phala-cloud/confidential-ai/confidential-model/api-reference/sessions.md)
>
> Fetch a session by id, or list current sessions.

> [card] [Trust boundary](https://docs.phala.com/phala-cloud/confidential-ai/confidential-model/trust-boundary.md)
>
> What the gateway does and does not protect.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.