---
title: "Create confidential chat completions"
method: POST
path: "/v1/confidential/chat/completions"
tags: ["Confidential Chat"]
---

# Create confidential chat completions

`POST /v1/confidential/chat/completions`

This handler processes chat completion requests in a confidential manner, providing additional
encryption and security measures for sensitive data processing. It supports both streaming and
non-streaming responses while maintaining data confidentiality through AEAD encryption and TEE hardware,
for full private AI compute.

## Returns

Returns a `Result` containing either:
* An HTTP response with the chat completion result
* A streaming SSE connection for real-time completions
* An `AtomaProxyError` error if the request processing fails

## Errors

Returns `AtomaProxyError::InvalidBody` if:
* The 'stream' field is missing or invalid in the payload

Returns `AtomaProxyError::InternalError` if:
* The inference service request fails
* Response processing encounters errors
* State manager updates fail

## Security Features

* Utilizes AEAD encryption for request/response data
* Supports TEE (Trusted Execution Environment) processing
* Implements secure key exchange using X25519
* Maintains confidentiality throughout the request lifecycle

## Request body

- ConfidentialComputeRequest — A request for confidential computation that includes encrypted data and associated cryptographic parameters
  - `ciphertext` string, required — The encrypted payload that needs to be processed (base64 encoded)
  - `client_dh_public_key` string, required — Client's public key for Diffie-Hellman key exchange (base64 encoded)
  - `model_name` string, required — Model name
  - `node_dh_public_key` string, required — Node's public key for Diffie-Hellman key exchange (base64 encoded)
  - `nonce` string, required — Cryptographic nonce used for encryption (base64 encoded)
  - `num_compute_units` integer, nullable — Number of compute units to be used for the request, for image generations, as this value is known in advance (the number of pixels to generate)
  - `plaintext_body_hash` string, required — Hash of the original plaintext body for integrity verification (base64 encoded)
  - `salt` string, required — Salt value used in key derivation (base64 encoded)
  - `stack_small_id` integer, required — Unique identifier for the small stack being used
  - `stream` boolean, nullable — Indicates whether this is a streaming request

## Response `200`

Confidential chat completions

- ConfidentialComputeResponse — Represents a response from a confidential compute request
  - `ciphertext` string, required — Encrypted response body (base64 encoded)
  - `nonce` string, required — Nonce used for encryption (base64 encoded)
  - `response_hash` string, nullable — Hash of the response body (base64 encoded)
  - `signature` string, nullable — Signature of the response body (base64 encoded)
  - `usage` Usage
    - `completion_tokens` integer, required — The number of completion tokens used
    - `completion_tokens_details` CompletionTokensDetails, required — The details of the completion tokens
      - `accepted_prediction_tokens` integer, required — The number of tokens in the completion
      - `audio_tokens` integer, required — The number of audio tokens
      - `reasoning_tokens` integer, required — The number of reasoning tokens
      - `rejected_prediction_tokens` integer, required — The number of rejected prediction tokens
    - `prompt_tokens` integer, required — The number of prompt tokens used
    - `prompt_tokens_details` PromptTokensDetails, required
      - `audio_tokens` integer, required — The number of audio tokens
      - `cached_tokens` integer, required — The number of cached tokens
    - `total_tokens` integer, required — The total number of tokens used

## Other responses

- `400` — Bad request
- `401` — Unauthorized
- `500` — Internal server error

---

[API](https://skmtc.net/atomaai/apis/atoma-proxy.md) · [All operations](https://skmtc.net/atomaai/apis/atoma-proxy/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/atomaai/atoma-proxy/revisions/07694b7228b0/schema)
