Dracon AI API — Reference

Every endpoint, request/response shape, error code, and the recommended client retry policy. For the formal internal spec, see apis/docs/external-consumer-guide-2026-06-12.md in the public repo.

Get an API key

Base URL & auth

All endpoints are at https://dracon.uk. AI endpoints use the x-api-key header. Auth endpoints use a session cookie (set automatically when you sign in via the magic-link flow).

POST https://dracon.uk/api/v1/ai/chat/completions
Content-Type: application/json
x-api-key: dracon_628ca0502df74aa1862b72a74968b508

{
  "lane": "writing",
  "project_id": "my-app",
  "messages": [{ "role": "user", "content": "Hello" }],
  "max_tokens": 4096
}

Endpoints

AI completions

MethodPathAuth
POST/api/v1/ai/chat/completionsx-api-key
POST/api/v1/ai/chat/streamx-api-key (SSE)
POST/api/v1/ai/imagex-api-key
POST/api/v1/ai/musicx-api-key
POST/api/v1/ai/soundfxx-api-key
POST/api/v1/ai/ttsx-api-key

BYOK (Bring Your Own Key)

MethodPathPurpose
POST/api/v1/keysUpload a provider key (OpenAI, Anthropic, …)
GET/api/v1/keysList stored providers
DELETE/api/v1/keys/{provider}Remove a stored key

Auth & key management

MethodPathAuthPurpose
POST/api/v1/auth/request-magic-linknoneSend a magic link to your email
POST/api/v1/auth/verify-codenoneConsume a magic-link code, get session cookies
GET/api/v1/auth/sessionsessionGet current session info
GET/api/v1/mesession or api keyGet current user profile
POST/api/v1/auth/api-keyssession + OriginCreate a new API key (returns plaintext once)
GET/api/v1/auth/api-keys/listsessionList your API keys (no plaintext)
POST/api/v1/auth/api-keys/revokesession + OriginRevoke a key by id

Request shapes

Chat completions (POST /api/v1/ai/chat/completions)

{
  "lane": "writing",          // required, must be in AI_ALLOWED_LANES
  "project_id": "my-app",   // required, ≤128 chars
  "messages": [                 // 1–128 messages, each ≤64 KB
    { "role": "user", "content": "Hello" }
  ],
  "model": "gpt-4o",         // optional, defaults to lane default
  "max_tokens": 4096             // optional, default 4096
}

Response:

{
  "content": "Hello, how can I help?",
  "model_used": "gemini-2.5-flash",
  "finish_reason": "stop",
  "usage": { "completion_tokens": 182, "prompt_tokens": 22, "total_tokens": 204 }
}

The model field is optional. For the free lane, Dracon selects from the verified free providers in priority order: Gemini 2.5 Flash, Mistral Medium, and NVIDIA Nemotron. The wildcard OpenRouter free router and unreliable free models are not served as first-class free-lane options.

API key creation (POST /api/v1/auth/api-keys)

{
  "name": "my-app",    // required, alphanumeric
  "scope": "ai"      // optional, default "ai"
}

Response (201):

{
  "key": "dracon_628ca0502df74aa1862b72a74968b508",
  "key_id": "2e4b82aa-ae48-44bb-b9e2-9a30d5b81605",
  "key_prefix": "dracon_6",
  "name": "my-app",
  "scope": "ai"
}

The plaintext key is shown once. The server stores only a hash. There is no "show me the key again" endpoint.

Error codes

Errors return JSON with error (string code) and request_id (UUID). Always log request_id when reporting issues.

CodeHTTPMeaning
missing api key401No x-api-key header
invalid api key401Key revoked or not found
missing_authentication401No session cookie or api key
csrf_origin403State-changing request from browser with wrong Origin
maximum_keys4005-key limit reached
rate_limited429Honour retry-after header
messages cannot be empty400messages: []
message content exceeds maximum length400Single message > 64 KB
total message content exceeds 8MB limit400Sum of all messages > 8 MB
lane is required400lane empty or missing
project_id is required400project_id present but empty
deserialization error422project_id field omitted from JSON
unknown lane400lane not in AI_ALLOWED_LANES
upstream AI service timed out504Provider did not respond in 60s; retry with backoff

Retry policy

No per-call charge is enforced by the Dracon API layer in the current deployment. The preview limits below are the enforceable limits.

  1. 401 with expired or invalid api key — the key is dead. Re-prompt the user to create a new one. Do not retry.
  2. 429 with retry-after — honour the header. Back off.
  3. 504 — retry once with exponential backoff (e.g. 2s, 4s, 8s). After 3 attempts, surface the error.
  4. 5xx (any other) — retry once. If still failing, surface.
  5. Network error — retry with backoff. Log the request_id from any prior response for traceability.

CORS for browser clients

If you call the API from a browser served from a different domain, your origin must be in the apex CORS allowlist. The apex currently allows https://dracon.uk. To add your origin, contact the operator (admin@dracon.uk) with:

Same-origin browser clients (your app at https://dracon.uk/...) work out of the box — CORS only applies cross-origin.

Operational limits


Need a key? Sign up in 60 seconds.