Limits, caps & scopes
Rate limits protect the platform; optional per-key caps and scopes let you protect yourself.
Rate limits
Each API key is limited to 100 requests/minute by default, shared across all server instances. Exceeding it returns 429 with a rate_limit_error — back off and retry.
Spend caps
Attach a daily and/or monthly USD cap to any key. Once a window’s spend (plus the next call’s estimate) would exceed the cap, the call is rejected with 402 — protecting against a runaway loop draining your wallet.
Tokens-per-minute (TPM)
Optionally cap a key’s tokens per minute. Useful for agents that burst. Over the limit returns 429.
Scoped keys
Restrict a key to specific models and/or modalities (chat, image, tts, audio, embeddings). A request outside the scope returns 403. Combine with caps to issue safe, narrow keys to teammates or CI.
| Policy | Effect | On violation |
|---|---|---|
daily_usd / monthly_usd | Spend window cap | 402 |
tpm | Tokens per minute | 429 |
allowed_models | Model allow-list | 403 |
allowed_kinds | Modality allow-list | 403 |
Policies are configured per key (DB-driven, no redeploy). A key with no policy is unlimited within the global rate limit.
Idempotency
Send an Idempotency-Key header with POST /v1/chat/completions to safely retry a request
after a network blip without being billed twice. A repeated non-streaming request replays
the original result; streaming requests use the key as a single-use duplicate guard.
curl https://api.aix.theaimart.co/v1/chat/completions \
-H "Authorization: Bearer $AIX_KEY" \
-H "Idempotency-Key: 7b3f-unique-per-attempt" \
-H "Content-Type: application/json" \
-d '{ "model": "deepseek-ai/DeepSeek-V3.2", "messages": [{"role":"user","content":"hello"}] }'