> ## 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.

# How Private AI works

> The two proof layers and request flow behind Phala's TEE-only inference API.

Every model on `https://inference.phala.com/v1` requires verified upstream serving. Ordinary SDK calls use TLS; use a verification client to establish the gateway identity and pin the channel.

The platform runs inference behind an **Attested Confidential Inference (ACI)** gateway. The gateway is a
workload running inside a Trusted Execution Environment (TEE, Intel TDX). It does two things a normal
API cannot:

1. It proves which code is running, in a real TEE, with an **attestation report**.
2. It signs a **per-response receipt** that ties your exact request and response to that attested
   workload.

You do not have to trust the platform's word. You fetch these artifacts and check the signatures and
hashes yourself. This page explains the model. To run the checks, see
[Verify a response](https://docs.phala.com/phala-cloud/confidential-ai/verify/verify-signature.md).

## The two proof layers

> [card] [Attestation report](https://docs.phala.com/phala-cloud/confidential-ai/verify/verify-attestation.md)
>
> Proves the gateway is a specific workload running in a genuine TEE, and publishes the keys it
> signs with. Fetch it from `GET /v1/aci/attestation?nonce=`.

> [card] [Signed receipt](https://docs.phala.com/phala-cloud/confidential-ai/confidential-model/receipts-and-sessions.md)
>
> Proves what the gateway received and returned for one request, signed by a key from the attested
> report. Fetch it from `GET /v1/aci/receipts/{id}`.

The report answers "who served me?". The receipt answers "what did they do with my request?". A
receipt is only meaningful once you have verified the report, because the report is what tells you
the receipt's signing key is bound to a genuine TEE.

## Request flow

```mermaid theme={"system"}
flowchart LR
  user["Your app<br/>OpenAI SDK"]
  upstream["Upstream model<br/>provider"]
  subgraph gw["Gateway (TEE)"]
    direction TB
    fe["Frontend"]
    be["Backend<br/>provider verification"]
    fe --> be
  end
  user <-->|"TLS or E2EE"| fe
  be <-->|"verified channel"| upstream
```

1. You call the API over TLS, or add [E2EE](https://docs.phala.com/phala-cloud/confidential-ai/confidential-model/e2ee-encryption.md)
   for field-level encryption.
2. The gateway records your request and computes its hash.
3. When verified serving is required, the backend verifies the upstream provider and enforces a
   [channel binding](https://docs.phala.com/phala-cloud/confidential-ai/confidential-model/verified-upstreams.md#channel-binding) before forwarding. If it cannot, it does not
   send your prompt (fail-closed).
4. The response returns through the gateway, which signs the receipt after it has observed the final
   response bytes.

On a TEE-only endpoint, every admitted inference request requires verified serving. Where
verification is optional, send `provider.aci_verified: true` or session pins to require it.
Check the receipt to determine how a response was served.

## What you can verify

After one request you hold enough to check, locally:

* The gateway is a genuine TEE workload with a known identity (attestation report).
* The receipt was signed by a key that report endorses.
* The signed request hash matches the request you sent, and the signed response hash matches the
  response you received.
* When attestation was required, the upstream was verified and the channel was bound before your prompt
  was forwarded.

Continue with the concept pages below, or jump to the hands-on
[Verify a response](https://docs.phala.com/phala-cloud/confidential-ai/verify/verify-signature.md) guide.

## Related

> [card] [Verify a response](https://docs.phala.com/phala-cloud/confidential-ai/verify/typescript-sdk.md)

> [card] [Verified upstreams](https://docs.phala.com/phala-cloud/confidential-ai/confidential-model/verified-upstreams.md)

> [card] [Receipts and sessions](https://docs.phala.com/phala-cloud/confidential-ai/confidential-model/receipts-and-sessions.md)

> [card] [Attestation report](https://docs.phala.com/phala-cloud/confidential-ai/verify/verify-attestation.md)


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