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

# Idempotency

> Retry non-streaming requests safely without being billed twice.

> [!NOTE]
>
> Use a current public model ID from [Models](https://nomask.ai/models) or `GET /models`. Example IDs and options must match the selected model's advertised capabilities and limits.

Networks fail. Idempotency keys let you retry a completion request safely, guaranteed to never be billed twice for the same work.

## How it works

Send an `Idempotency-Key` header (any unique string you generate, such as a UUID) on a non-streaming completion request. If a request with the same key and the same body already succeeded in the last 24 hours, the original response is replayed with an `Idempotency-Replayed: true` header and nothing new is billed.

## Example

```bash theme={"system"}
curl https://api.nomask.ai/v1/chat/completions \
  -H "Authorization: Bearer $NOMASK_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-42-summary-b81f0b1e" \
  -d '{
    "model": "nomask-1.2",
    "messages": [{"role": "user", "content": "Summarize order 42."}]
  }'
```

## Rules and lifetime

* Replays require the same key **and** the same request body. A changed body with a reused key is treated as a new request.
* Keys are scoped to the API key that made the request.
* Stored responses expire after 24 hours.
* Streaming requests do not use this retry cache.
* Only successful responses are stored. A failed request can always be retried.


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