Skip to main content
The Dafty API turns a prompt into an on-brand image. Generation is asynchronous: you create a job, then poll it until it completes and returns image URLs.

1. Get an API key

Create a key from your dashboard at /api-keys. The plaintext key is shown once - store it securely. Send it on every request as x-api-key (or Authorization: Bearer).

2. Start a generation

curl -X POST http://localhost:3001/api/v1/images/generate \
  -H "x-api-key: $DAFTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A minimalist logo of a mountain at sunrise, flat vector style",
    "aspectRatio": "1:1",
    "quality": "high",
    "resolution": "2K",
    "variations": 2
  }'
Returns 202 Accepted with a pending job:
{ "data": { "id": "3f9a4c2e-...", "type": "image.generate", "status": "pending", "createdAt": "..." } }
Only prompt is required. aspectRatio, quality (low|medium|high), and resolution (1K|2K|4K) have sensible defaults. Optionally pass a saved styleId and up to 4 references (image URLs or upload/job ids).

3. Poll for the result

Use ?wait=true to long-poll until the job finishes (up to ~55s):
curl "http://localhost:3001/api/v1/jobs/3f9a4c2e-...?wait=true" \
  -H "x-api-key: $DAFTY_API_KEY"
{
  "data": {
    "id": "3f9a4c2e-...",
    "type": "image.generate",
    "status": "completed",
    "result": { "images": [{ "url": "https://cdn.../original.png", "width": 2048, "height": 2048 }] }
  }
}
Read the image from data.result.images[0].url. See Polling & wait for the loop and backoff details.

Next steps