End users
Identify your own users with the end-user header: per-user limits, reports and business billing.
If your product serves many people, tell us which of your users each request is for. Business workspaces must send it on every request; for everyone else it is optional.
The end-user header
Messages API
curl "$KEYDAN_API_BASE/v1/messages" \
-H "x-api-key: $KEYDAN_API_KEY" \
-H "X-End-User: u_3f9a1c7e" \
-H "Content-Type: application/json" \
-d '{"model": "kd-balanced", "max_tokens": 256,
"messages": [{"role": "user", "content": "Hello"}]}'In the Chat Completions API you can also use the user field (the header wins when both are sent):
Chat Completions API
{
"model": "kd-balanced",
"user": "u_3f9a1c7e",
"messages": [{"role": "user", "content": "Hello"}]
}X-End-User: 1 to 128 characters ofA-Z a-z 0-9 . _ : @ + = / -.- Send a stable pseudonym, never a name or an e-mail address:
pseudonym
# a stable pseudonym: never send a name or an e-mail
end_user = hex(HMAC_SHA256(your_secret, your_internal_user_id))[:32]What it is used for
- Per-user limits: requests per minute and concurrency per end user, set in your dashboard.
- Blocking: block one end user without touching the rest.
- Reports: usage per end user in your dashboard.
- Better caching: requests of one end user reuse each other's prompt cache more often.
- Business billing: an active end user is a distinct id with at least one served request in a calendar month (UTC); business plans are billed per active end user.
Errors
400 end_user_required: a business workspace sent no end-user id.400 bad_end_user: the id is empty, too long or has other characters.403 end_user_blocked: you blocked this end user in your dashboard.429 end_user_rpm/end_user_concurrency: this end user is over their own limit.