POST/v1/images/generations

Image Generation

Generate images from text prompts using DALL-E, Flux, Stable Diffusion, and other image models.

Available Models

ModelProviderSizesFeatures
dall-e-3OpenAI1024×1024, 1024×1792, 1792×1024HDPrompt Revision
dall-e-2OpenAI256×256, 512×512, 1024×1024Multi-image
flux-1.1-proBlack Forest Labs1024×1024, 1024×768, 768×1024Photorealistic
flux-devBlack Forest Labs1024×1024, 1024×768Fast
stable-diffusion-xlStability AI1024×1024, 1152×896, 896×1152Multi-image
ideogram-v2Ideogram1024×1024Text-in-Image

Basic Usage

Generate an image with a text prompt:

TypeScript
const response = await client.images.generate({
  model: 'dall-e-3',
  prompt: 'A serene mountain landscape at sunset, digital art style',
  size: '1024x1024',
  quality: 'hd',
  n: 1
});

console.log(response.data[0].url);

Request Body

json
{
  "model": "dall-e-3",           // Required: Image model ID
  "prompt": "A beautiful...",    // Required: Text description
  "n": 1,                        // Optional: Number of images (1-4)
  "size": "1024x1024",           // Optional: Image dimensions
  "quality": "standard",         // Optional: "standard" or "hd"
  "style": "vivid",              // Optional: "vivid" or "natural"
  "response_format": "url"       // Optional: "url" or "b64_json"
}

Parameters

ParameterTypeDescription
modelRequiredstringImage model ID (e.g., "dall-e-3", "flux-1.1-pro")
promptRequiredstringText description of the desired image (max 4000 chars)
nintegerNumber of images (1-4). DALL-E 3 only supports n=1.
sizestringImage dimensions. Options vary by model.
qualitystring"standard" or "hd". HD costs more but higher quality.
stylestring"vivid" (hyper-real) or "natural" (more realistic). DALL-E 3 only.
response_formatstring"url" (default) or "b64_json" for base64 data

Response

json
{
  "created": 1706123456,
  "data": [
    {
      "url": "https://...",              // Image URL (expires in 1 hour)
      "revised_prompt": "A beautiful..." // DALL-E 3 revised prompt
    }
  ]
}

Note: Image URLs expire after 1 hour. Download and store images if you need them longer.

Model Examples

Flux 1.1 Pro

Excellent for photorealistic images and complex scenes:

TypeScript
const response = await client.images.generate({
  model: 'flux-1.1-pro',
  prompt: 'Cyberpunk cityscape with neon lights and flying cars',
  size: '1024x1024',
  n: 1
});

// Download the image
const imageUrl = response.data[0].url;

Stable Diffusion XL

Generate multiple variations at once:

TypeScript
const response = await client.images.generate({
  model: 'stable-diffusion-xl',
  prompt: 'A majestic lion in the savanna, photorealistic, 8k',
  size: '1024x1024',
  n: 4  // Generate multiple variations
});

response.data.forEach((image, i) => {
  console.log(`Image ${i + 1}: ${image.url}`);
});

Base64 Response Format

Use response_format: "b64_json" to get image data directly instead of a URL:

TypeScript
const response = await client.images.generate({
  model: 'dall-e-3',
  prompt: 'Abstract art with vibrant colors',
  response_format: 'b64_json',
  size: '1024x1024'
});

// Decode and save base64 image
const imageData = response.data[0].b64_json;
const buffer = Buffer.from(imageData, 'base64');
fs.writeFileSync('image.png', buffer);

Prompt Tips

Be Specific

Instead of "a dog", try "a golden retriever puppy sitting in a sunny meadow, professional photography, shallow depth of field".

Include Art Style

Specify the style: "oil painting", "digital art", "watercolor", "photorealistic", "anime style", "3D render".

Add Lighting & Mood

Describe lighting: "golden hour", "dramatic shadows", "neon lights", "soft ambient lighting".

Use Quality Modifiers

Add quality keywords: "8k", "highly detailed", "award-winning", "masterpiece", "trending on artstation".

cURL Example

Bash
curl https://api.llmhub.one/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $LLMHUB_API_KEY" \
  -d '{
    "model": "dall-e-3",
    "prompt": "A futuristic robot in a garden",
    "size": "1024x1024",
    "quality": "hd",
    "n": 1
  }'

Pricing

Image generation is priced per image. Costs vary by model, size, and quality:

ModelSizeQualityPrice/Image
DALL-E 31024×1024Standard€0.040
DALL-E 31024×1024HD€0.080
Flux 1.1 Pro1024×1024€0.040

Related Guides