Double billing on retries
Timeouts make clients retry, and you pay for the same work twice.
Idempotency
Networks drop, workers restart, queues redeliver. Add an Idempotency-Key header to each logical request and usage for that key is recorded once, however many times you retry.
per idempotency key
no cross-account collisions
Idempotency-Key
The problem
Timeouts make clients retry, and you pay for the same work twice.
Without idempotency, teams avoid retries and accept failures instead.
At-least-once delivery means at-least-once billing, unless you guard against it.
Capabilities
Send Idempotency-Key: <unique string> with POST /api/ainf/inference. If you cannot set headers, an idempotency_key field in the JSON body is accepted.
The usage event for a given key is recorded once. Later requests with the same key are not metered again.
Keys are combined with your account on our side, so your keys can never collide with, or suppress, another customer's usage.
Fail-over happens inside one request, so it never creates a second metered event.
An identical retry inside the cache window is also served from cache and priced at zero.
Without the header, each successful request is metered on its own.
Use cases
Generate the key once per logical request and reuse it on every retry.
Use the message id as the key so redelivery is not metered twice.
Use a stable id per item, such as a SKU or document id plus a job id.
Key each step by run id and step number.
How it works
Create a unique string per logical operation, such as a UUID or a stable job and item id.
Include the same Idempotency-Key on the first attempt and every retry.
A different prompt or a new operation gets a fresh key.
Control
API keys are shown once at creation and stored only as a hash. Revoke any key instantly from Settings.
Every request carries its own receipt: tokens in, tokens out, latency and price. Nothing is billed that you cannot trace.
Per-account rate limits and a free monthly allowance keep experiments safe before they become production.
You choose exactly what you send. Repeat prompts can be served from your cache, and cache hits are never billed.
For developers
Send a prompt and a capability, or name a model. One bearer key, one small JSON body, and a full receipt on every response.
curl https://YOUR-DOMAIN/api/ainf/inference \
-H "Authorization: Bearer $AI_INFERENCE_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1042" \
-d '{"prompt":"Summarise this ticket in one line","capability":"chat"}'The retry is processed normally and returns a response. What the key controls is metering: usage for that key is recorded once. An identical prompt inside the cache window is also served from cache.
Anything unique to the logical operation: a UUID generated before the first attempt, a queue message id, or a job id plus an item id.
Do not. Use a fresh key for every new piece of work so each one is metered correctly.
No. It is namespaced to your account and stored only in hashed form as part of the usage record.
Add one header and stop worrying about double metering.