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

# Create confidential completions

`POST /v1/confidential/completions`

## Request

- Base URL: `https://api.atoma.network`
- URL: `https://api.atoma.network/v1/confidential/completions`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/atomaai/apis/atoma-proxy/docs/v1/confidential/completions/post.ts> (a function with typed inputs; its response is checked against the schema)

This handler processes completions 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 completions 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

## Changes

- **2025-05-12** `f0bf5a2dde0f`: 1 info
  - endpoint added
- **2024-12-06** `45e3254839bd`: 1 breaking
  - api path removed without deprecation

[Operation history](https://skmtc.dev/atomaai/apis/atoma-proxy/changes/v1/confidential/completions/post.md)

---

[API](https://skmtc.dev/atomaai/apis/atoma-proxy.md) - [All operations](https://skmtc.dev/atomaai/apis/atoma-proxy/llms.txt) - [OpenAPI document](https://skmtc.dev/atomaai/apis/atoma-proxy/revisions/07694b7228b0?raw)
