Skip to main content

Darkfield API

Everything the studio makes, from your own code: price a request, make images, video and voice, and read the results. The same prices, credits and checks as the studio.

Start in three steps

  1. Create a key on your account page. Choose what it may do: read, make, upload.
  2. Send it with every request in the Authorization header.
  3. Price a request with /quote, then make it with /generations at the price you accept.

API keys

Keys

A key acts as you and spends your credits. It is shown once, when you create it; we keep only a fingerprint of it. Keep it on your server, never in a web page or an app people download. Revoke it on your account page the moment it may have leaked.

Authorization: Bearer hk_live_…

Your first request

Price an image, then make it. maxCredits is the most you accept to pay: if the price is higher, nothing is held and you get a 409.

curl http://localhost:3000/api/v1/quote \
  -H "Authorization: Bearer $HEMERA_KEY" \
  -H "Content-Type: application/json" \
  -d '{"request":{"tool":"image","inputs":{"prompt":"a green glass bottle on stone"},"settings":{"aspect":"1:1"}}}'
curl http://localhost:3000/api/v1/generations \
  -H "Authorization: Bearer $HEMERA_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-1042-hero" \
  -d '{"request":{"tool":"image","inputs":{"prompt":"a green glass bottle on stone"},"settings":{"aspect":"1:1"}},"maxCredits":10}'

curl http://localhost:3000/api/v1/generations/<id> -H "Authorization: Bearer $HEMERA_KEY"

Safe retries

Send a clientRequestId (or an Idempotency-Key header) with each new generation. If the connection drops and you send it again, you get the same generation back, and you are charged once.

Results

A generation runs in the background. Read it with GET /generations/{id} until status is succeeded, failed or blocked. Its files are short-lived signed links: download them, do not store the links.

Your own files

Three steps: POST /uploads gives a link, you PUT the file to it, then POST /uploads/{id}/confirm checks it. Use the file's id in a request's inputs.

Limits

Per key: 60 calls a minute, 1000 an hour, and 60 paid calls an hour. A key can also have its own daily credit ceiling. Over a limit you get 429 with Retry-After.

Errors

Every error has the same shape: an HTTP status, a code, a sentence and details. 401 the key, 402 not enough credits, 403 the key's permission, 404 not found (also for someone else's ids), 409 the price rose, 422 refused, 429 a limit.

{ "error": { "code": "insufficient_credits", "message": "…", "requiredCredits": 40, "availableCredits": 12 } }

Reference

Every endpoint, field and answer is in the OpenAPI document. Import it into Postman, Insomnia or a code generator.

OpenAPI document

Claude, ChatGPT and other assistants

Darkfield also speaks MCP, so an AI assistant can price and prepare work for you. It can never spend on its own: every paid step waits for your yes on Darkfield.

Connect an assistant