Skip to main content
Encrypted chat has two wire formats. Field encryption keeps the Chat Completions JSON structure visible and encrypts the message contents and supported tool fields. Whole-body encryption wraps the entire JSON request, including messages, attachments and tools, in one encrypted HTTP body. Both use POST /v1/chat/completions or its /api/v1 mirror. The Web App handles transport selection, verification and decryption for you.

Select a transport

  1. Request attestation for your selected encrypted model. Request version 2 of the sealed model binding and open it on the client.
  2. Read encryption_protocol to select the wire format. Use the exact recovered proof_format to select the verifier. Verify the evidence and its binding to the model and encryption key before sending any content.
  3. Follow the corresponding request path below. Stop if the protocol, evidence, or key binding is unknown or fails verification.

Whole-body encryption

Build a Chat Completions JSON request locally, including the exact native model ID recovered from the verified binding. Encrypt the serialized JSON with an EHBP implementation using the enclave’s verified transport key. Send the ciphertext with these headers: The model and enclave routing headers are visible to the gateway. Keep field-encryption headers off this request. On success, use Ehbp-Response-Nonce with the request’s EHBP context to authenticate and decrypt the response. Parse the decrypted data as JSON or, for streaming, as server-sent events. If the request outcome is unknown, avoid automatic replay: each submission can start another inference.

Field encryption

Send a JSON Chat Completions request with ciphertext strings in its encrypted fields. The attestation reports encryption_protocol: "chat-fields-v1". For an attachment-capable route, serialize the supported content array locally and encrypt it as one message field. The outer JSON still carries a ciphertext string.

Keys

The model’s public key comes from the attestation as model_public_key, with signing_algo naming its type: ed25519 (32 bytes) or ecdsa on secp256k1 (64 bytes, or 65 with the 04 prefix). Verify the evidence before using it. See Verify It Yourself. Your key pair matches the model key’s type and lives for the conversation:
  • ed25519: generate an ed25519 key pair. The header carries the 32-byte public key as hex. For key agreement, convert your secret key and the model’s public key to their X25519 forms.
  • ecdsa: generate a secp256k1 key pair. The header carries the uncompressed 65-byte public key as hex. A 64-byte model key is prefixed with 04 before use.
An ephemeral key per message. Every encryption generates a fresh ephemeral key pair, so no two envelopes share a symmetric key.

Encrypting a field

For each messages[].content string:
  1. Agree a shared secret between the ephemeral secret key and the model’s public key. ed25519: X25519 over the converted keys. ecdsa: the x coordinate (32 bytes) of the secp256k1 ECDH point.
  2. Derive the symmetric key with HKDF-SHA256: input the shared secret, no salt, 32 bytes out, with the info string ed25519_encryption for ed25519 or ecdsa_encryption for ecdsa.
  3. Encrypt the UTF-8 plaintext. With an ed25519 key: XChaCha20-Poly1305 with a random 24-byte nonce. With an ecdsa key: AES-256-GCM with a random 12-byte nonce.
  4. Build the envelope: the ephemeral public key, the nonce, then the ciphertext with its authentication tag, concatenated and hex encoded. Replace the content string with it.
On the wire, the encrypted field is a nonblank hex string.

Field-encryption headers

Send one value for each required header. Use the key and signing algorithm specified by verified attestation.

Decrypting field replies

choices[].message.content comes back as an envelope of the same shape. Split off the ephemeral public key and the nonce by the lengths above, agree the shared secret between your conversation secret key and that ephemeral public key, derive the symmetric key with the same HKDF parameters, and decrypt. A reasoning summary, where the model returns one, is an envelope too. With stream: true, buffer a fragmented envelope until it is complete, then authenticate and decrypt it. Assemble the resulting plaintext deltas in order. Never join separate ciphertext envelopes for decryption.

Response Signature Evidence

On supported backends, nito-encrypted-response-evidence: 1 with stream: false returns the original upstream request and response bytes plus signature proof. Your client verifies the signature and its binding to fresh attestation before consuming a reply that requires this assurance. See Response Evidence for fields, verification steps, and limits.

The Encrypted Tool Loop

With nito-encrypted-encrypt-all-fields: 1, the client encrypts the function definitions and tool payloads. Encrypt, as separate envelopes, each tool’s function.name, function.description, and function.parameters (the JSON schema, serialized to a string), any tool_choice function name, and, on later turns, each assistant tool_calls[].function.name and .arguments and each tool message’s content. The reply’s tool calls arrive with the id in plaintext and the name and arguments as envelopes. Decrypt them, run the tool on your side, encrypt the result, and send the next request. Only function tools are accepted in this mode. With whole-body encryption, include supported function definitions, calls and results inside the encrypted JSON instead.

Retrieval and failure handling

To add web context, submit your own query to POST /api/v1/web/search or public URLs to POST /api/v1/web/fetch. Those are separate requests: the retrieval service sees the query or URLs you send. Select the returned material you need, add it to your chat message and encrypt it with the rest of the turn. Field-encryption requests require the encrypted logical model ID and matching headers. Whole-body requests require the exact attested model and enclave routing values. If verification or decryption fails, stop before displaying the content or executing a tool. See What works with encryption for feature availability.

Encrypted Requests on the API

The reference page.

Get Attestation

Where the key comes from.

How It Works

The call, step by step.