Attribute API usage and DA spend to individual end-users so you can bill them accurately and detect abuse.
Not yet available. Per-request user attribution (a
userfield on requests) is tracked to be built — today, attribute end-users by giving each app or user segment its own API key and reading per-key usage in Dashboard → Analytics.
If you are building an application on top of OpenDunes — a SaaS product, an internal tool with multiple users, or a multi-tenant platform — you need to know which of your users is responsible for each API call. Today that is done at the key level.
Note: sending a user field in a chat completion request does not error, but the value is silently dropped — it is not stored, not forwarded, and never appears in analytics or exports. Do not rely on it.
Create a dedicated API key for each app, tenant, or user segment you want to track. Every request made with that key is attributed to it in analytics, so per-key usage is your per-segment usage.
Create keys in Dashboard → Keys, or programmatically via the Management API — authenticated with a management key (mk-…, created in Dashboard → Settings → Management Keys):
The 201 response carries the key metadata under api_key and the raw sk- key in raw_key — shown once only, so store it immediately. Then route each tenant's traffic through its own key:
Name keys after the tenant or segment (tenant-acme, mobile-app, free-tier) — the name is how you will recognize them in analytics and exports.
Per-key usage lives in Dashboard → Analytics (session-authenticated — it is a dashboard surface, not a Bearer API):
key_id (plus model, from, to) — download one export per tenant, or one full export and group by key on your side.Download the export CSV from the dashboard, then aggregate. The cost column is total_cost, an integer in micro-DA (1 DA = 1,000,000 micro-DA) — divide by 1,000,000 for DA:
Because total_cost is integer micro-DA, sums reconcile exactly against your balance history — no float drift.
Export a recent window per key and flag segments whose spend exceeds a threshold:
For an automated check without exports, poll GET /v1/activity with each segment's own key — it returns that key's account-wide daily rollups, and a per-segment key means the rollup is that segment's usage.
Because attribution is key-based, no end-user identifier is sent to or stored by OpenDunes. The mapping between a key (tenant-acme) and your actual users lives entirely on your side — if your application handles Algerian personal data, ensure that mapping table complies with your own Law 18-07 obligations.
If you want to enforce a per-user request cap on your side, track request counts in Redis or a similar store keyed by user ID, and short-circuit before calling the OpenDunes API when the user exceeds your limit:
This is separate from OpenDunes' own per-key rate limit — it runs entirely on your infrastructure.