Description

This endpoint generates images based on a given prompt using AI. It supports various customization options and returns URLs to the generated images.

Endpoint

POST /api/v1/generate-image

Headers

  • Content-Type: application/json
  • Authorization: Bearer <API_KEY> (required)

Request Body

{
  "model": "string", // Optional. The model to use for image generation. Default: "FLUX.1-schnell".
  "prompt": "string", // Required. The text prompt for image generation.
  "image_size": "string", // Optional. Size and aspect ratio of the generated image. Default: "landscape_4_3".
  "num_inference_steps": "number", // Optional. Number of inference steps. Leave blank to use default for the selected model.
  "seed": "number", // Optional. Seed for reproducible results.
  "num_images": "number" // Optional. Number of images to generate. Default: 1.
}

Model Options

Currently, the supported models and their cost per image:

  • FLUX.1-schnell: 3 credits per image generated
  • FLUX.1-dev: 25 credits per image generated
  • FLUX.1-pro: 50 credits per image generated

Image Size Options

  • square_hd
  • square
  • portrait_4_3
  • portrait_16_9
  • landscape_4_3
  • landscape_16_9

Responses

Success (200)

Returns the generated image information.

{
  "images": [
    {
      "url": "string", // URL to the generated image
      "width": "number",
      "height": "number"
    }
  ],
  "seed": "number",
  "has_nsfw_concepts": "boolean[]",
  "prompt": "string"
}
  • Content-Type: application/json
  • X-RateLimit-Limit: The rate limit for the user.
  • X-RateLimit-Remaining: The remaining number of requests for the user.

Bad Request (400)

Returned if the request is invalid.

{
  "error": "prompt parameter is required"
}

Internal Server Error (500)

Returned if there’s an error during the image generation process.

{
  "error": "Failed to generate image: [error message]"
}

Example Request

curl -X POST https://app.dumplingai.com/api/v1/generate-image \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
  "model": "FLUX.1-schnell",
  "prompt": "A serene landscape with mountains and a lake",
  "image_size": "landscape_16_9",
  "num_images": 2
}'

Notes

  • The seed parameter can be used to generate reproducible results. The same seed and prompt will produce the same image for a given model version.
  • The has_nsfw_concepts field in the response indicates whether any NSFW (Not Safe For Work) content was detected in the generated images.
  • Images are temporarily stored (for ~24 hours) and accessible via the returned URLs.

Rate Limiting

Rate limit headers (X-RateLimit-Limit and X-RateLimit-Remaining) are included in the response to indicate the user’s current rate limit status.