Authenticate every API request with an API key, and run your account with a management key.
Every request to the OpenDunes API carries a key. There are two kinds:
| Key | Starts with | Calls |
|---|---|---|
| API key | sk- | every model, the catalogue, Files, presets, receipts — every route but the management routes |
| management key | mk- | the management routes: the balance, the usage history, keys, guardrails, observability, and feedback on an answer. Never a model |
An expired or disabled key, or a key sent to a route of the other kind, gets a 401.
Send the key as a Bearer token:
Authorization: Bearer $OPENDUNES_API_KEYor in x-api-key, as the Anthropic library sends it:
x-api-key: $OPENDUNES_API_KEYKeep the key in an environment variable — never in source files or version control. The full key is shown once, when it is created; only a hash is kept, so a lost key is replaced, never recovered.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://opendunes.com/v1",
api_key=os.environ["OPENDUNES_API_KEY"],
)
resp = client.chat.completions.create(
model="anthropic/claude-sonnet-5",
messages=[{"role": "user", "content": "Marhba!"}],
)
print(resp.choices[0].message.content)The Anthropic library takes https://opendunes.com as its base URL and sends the key in x-api-key on its own.
Go to your dashboard. A default key is created when you sign up, and you can use it at once. From there you can create more keys, pause one (reversible), revoke one (not), or regenerate one — a new key replaces the old in one step.
| Setting | Takes |
|---|---|
| name | free text |
| cap | an amount in DA, or none |
| cap resets | daily · weekly · monthly · never |
| expiry | a date and time, or none |
| storage | on · off — whether the files this key sends and gets back are kept |
A day, a week and a month are Algeria time; the week starts on Monday. A spent cap stops that key with a 402 (limit_source: "key") while your other keys keep running, and a request admitted under the cap settles in full, even past it. A key reads its own cap and spend at GET /v1/key.
There is no cap on the number of requests a key sends — see Limits.
Create one at Settings → Management keys. Its expiry is fixed when it is created and cannot be changed afterwards.
With a management key you can create and manage API keys from your own code:
curl https://opendunes.com/v1/keys \
-H "Authorization: Bearer $OPENDUNES_MANAGEMENT_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "Souk Bot", "limit": 2000, "limit_reset": "monthly" }'The answer carries the new key once, and its hash — the handle GET · PATCH · DELETE /v1/keys/{hash} take. See the API keys reference.
An app can get an API key on its user's wallet, with the user's approval — see Sign in with OpenDunes.
Regenerate or delete it at once at /dashboard/keys. A regenerated key replaces the old one in a single step; requests with the old key answer 401 from then on.
If you suspect unauthorised use, check /dashboard/activity for every request, filtered by key.