Skip to main content
Network blips happen. To retry a create safely, send an Idempotency-Key header: a repeat with the same key returns the original job instead of starting (and charging for) a new one.
curl -X POST http://localhost:3001/api/v1/images/generate \
  -H "x-api-key: $DAFTY_API_KEY" \
  -H "Idempotency-Key: 9f1c0b3a-batch-42" \
  -H "Content-Type: application/json" \
  -d '{ "prompt": "A calm mountain landscape" }'
Rules:
  • Use a unique key per logical operation (a UUID works well). Max 255 characters.
  • Keys are scoped to your API key and retained ~24h.
  • A retry with the same key returns the same job (202) - no second generation, no second charge.
  • A different key always creates a new job.
Supported on all create endpoints: POST /images/generate, /images/edit, /images/resize, /images/upscale, and /styles/extract.
Idempotency protects sequential retries (timeout → retry). If you fire two identical requests truly in parallel before either is recorded, you may still get two jobs - generate the key once and reuse it on retries.