List, create, change and delete API keys with a management key.
API keys authenticate every request to the OpenDunes API. Keys look like sk- followed by a random string — they are shown once at creation; only a hash is stored on our servers. A default key is created automatically when you sign up.
Programmatic key management goes through /v1/keys. It authenticates with a management key (mk-…) — a separate credential from your API keys, created at Settings → Management Keys; an API key there answers 401. For interactive management, use the Keys page.
A key is named by its hash: the SHA-256 of the key, in lowercase hex. Every amount is in DA.
The openai SDK has no keys resource, so call the endpoints directly with httpx.
import os
import httpx
headers = {"Authorization": f"Bearer {os.environ['OPENDUNES_MANAGEMENT_KEY']}"}
resp = httpx.get("https://opendunes.com/v1/keys", headers=headers)
keys = resp.json()["data"]
# [{ "hash", "name", "label", "disabled", "limit", "limit_remaining", "limit_reset", "usage", … }, ...]Active keys, 100 at a time; pass params={"offset": 100} for the next page and {"include_disabled": "true"} for the disabled ones.
resp = httpx.post(
"https://opendunes.com/v1/keys",
headers=headers,
json={
"name": "production-backend",
"limit": 2000, # optional spending cap in DA
"limit_reset": "monthly", # optional: daily, weekly or monthly
},
)
data = resp.json() # 201
key_hash = data["data"]["hash"]
raw_key = data["key"] # returned ONCE — store it in your secret manager nowresp = httpx.patch(
f"https://opendunes.com/v1/keys/{key_hash}",
headers=headers,
json={"limit": 5000, "disabled": False},
)
# → { "data": { … the key, changed … } }PATCH takes name, limit, limit_reset, storage and disabled. A disabled key answers 401 until it is enabled again.
httpx.delete(f"https://opendunes.com/v1/keys/{key_hash}", headers=headers)
# → { "deleted": true }Requests with a deleted key answer 401. A hash that is not one of your keys is a 404.