The Ducklygen API

Every model in the catalog, from your own code. One key, one balance, the same prices as the studio.

1 · Authenticate

Create a key in Settings, API keys. Send it with every request as a Bearer token. Keys start with dk_live_ and work only on Ducklygen; keep them on your server, never in a browser or an app.

curl https://ducklygen.com/api/v1/api/catalog/me \
  -H "Authorization: Bearer $DUCKLYGEN_API_KEY"

3 · Start a render

One call prices your exact inputs and charges your balance. The response comes back at once with status queued; the render runs in the background. Send an Idempotency-Key header so a retried request never charges twice.

curl -X POST https://ducklygen.com/api/v1/api/catalog/generations \
  -H "Authorization: Bearer $DUCKLYGEN_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "modelId": "image-model-id",
  "inputs": {
    "prompt": "rubber duck floating on teal water, soft light"
  }
}'

Check the price first (optional)

The same inputs, priced without starting anything. The answer is in cents.

curl -X POST https://ducklygen.com/api/v1/api/catalog/quote \
  -H "Authorization: Bearer $DUCKLYGEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"modelId":"image-model-id","inputs":{"prompt":"rubber duck floating on teal water, soft light"}}'

4 · Poll and download

Ask for the render every few seconds until status is succeeded, failed or refunded. On success, download the file from contentUrl with the same key. A text model returns its answer in textOutput instead.

curl https://ducklygen.com/api/v1/api/catalog/generations/ID \
  -H "Authorization: Bearer $DUCKLYGEN_API_KEY"

curl https://ducklygen.com/api/v1/api/catalog/generations/ID/content \
  -H "Authorization: Bearer $DUCKLYGEN_API_KEY" \
  -o result.png

Endpoints

Base URLhttps://ducklygen.com/api/v1/api/catalog

GET/meYour key and balance
GET/modelsEvery model
GET/models/detail?id=MODEL_IDOne model and its fields
POST/quotePrice for exact inputs
POST/generationsStart a render
GET/generationsYour recent renders
GET/generations/IDOne render's status
GET/generations/ID/contentThe result file
DELETE/generations/IDDelete a render

Errors and limits

Errors come back as JSON with a code and a message. 401: missing, wrong or revoked key. 400: a field is invalid (the details name it). 402: not enough balance. 409 API_KEY_DAILY_CAP: the key's own daily cap is reached. 429: too many requests, slow down. A failed render is refunded automatically.

Prices and balance

API renders use the same balance as the studio and cost the same. Every amount in the API is in euro cents: costCents is what a render charged, balanceCents what is left.