Generate Image

POST /api/v1/generate-image

Generate one or more images from a text prompt using AI models. Returns file paths to the generated images stored in Supabase Storage.

Request Body

Name Type Required Default Description
prompt string Yes Description of the image to generate
model string No nano-banana Model key
Values: "nano-banana", "nano-banana-pro", "flux-2-max", "flux-2-pro", "flux-2-flex", "flux-2-klein-9b", "flux-2-klein-4b", "gpt-image-1.5", "gpt-image-1", "gpt-image-1-mini", "midjourney-v7", "midjourney-v6-1", "runway-gen4-image", "runway-gen4-image-turbo", "grok-imagine-image", "seedream-4-5", "seedream-4-0", "riverflow-2-0-pro", "riverflow-2-0-fast", "kling-image-v3", "wan-2-6-image"
aspectRatio string No 1:1 Aspect ratio
Values: "1:1", "16:9", "9:16", "4:3", "3:4", "2:3", "3:2", "4:5", "5:4", "21:9"
resolution string No 1K Image resolution
Values: "1K", "2K", "4K"
count number No 1 Number of images to generate (1-4)
negativePrompt string No What to avoid in the image
seed number No Seed for reproducibility
Example Request
curl -X POST https://api.dalnulla.com/api/v1/generate-image \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "prompt": "A sunset over mountains, oil painting style",
    "model": "nano-banana",
    "aspectRatio": "16:9",
    "resolution": "1K"
  }'

Responses

Success

200 OK
{
  "filePath": "user-id/generated/generated_ref_1234567890.png",
  "prompt": "A sunset over mountains, oil painting style",
  "provider": "gemini",
  "results": [
    {
      "filePath": "user-id/generated/generated_ref_1234567890.png",
      "prompt": "A sunset over mountains, oil painting style",
      "provider": "gemini"
    }
  ]
}

Errors

400 Bad Request
{
  "error": "Unknown model",
  "model": "invalid-model"
}
401 Unauthorized
{
  "error": "Unauthorized: Invalid or expired token"
}
402 Payment Required
{
  "error": "Insufficient credits. Required: 50, Remaining: 10"
}
403 Forbidden
{
  "error": "This model requires a Pro subscription",
  "code": "MODEL_REQUIRES_SUBSCRIPTION",
  "model": "flux-2-pro",
  "requiredTier": "Pro"
}
500 Internal Server Error
{
  "error": "Failed to generate image"
}