---
title: "Generate image"
method: POST
path: "/images/generations"
tags: ["Images"]
---

# Generate image

`POST /images/generations`

## Request

- Base URL: `https://www.aimagicx.com/api/v1`
- URL: `https://www.aimagicx.com/api/v1/images/generations`
- Auth: HTTP bearer

Creates an image given a text prompt using Flux, Stable Diffusion, and other models.

## Query parameters

- `async` boolean

## Request body

- ImageGenerationRequest
  - `prompt` string, required: Text description of the image
  - `model` string: Model ID
  - `size` '512x512' | '1024x1024' | '1792x1024' | '1024x1792'
  - `n` integer: Number of images (1-10)
  - `upscale` '2x' | '4x', nullable: Upscale factor
  - `style` 'vivid' | 'natural'
  - `negative_prompt` string, nullable: What to avoid in the image
  - `seed` integer, nullable: Random seed for reproducibility

## Response `200`

Successful response

- union
  - ImageGenerationResponse
    - `created` integer
    - `data` object[]
      - `url` string, uri
      - `revised_prompt` string
      - `width` integer
      - `height` integer
    - `model` string
    - `model_tier` string
    - `usage` Usage
      - `credits_used` integer
      - `credits_breakdown` object
      - `prompt_tokens` integer
      - `completion_tokens` integer
      - `total_tokens` integer
  - AsyncJobResponse
    - `id` string: Job ID for polling
    - `status` 'pending' | 'processing' | 'completed' | 'failed'
    - `created` integer
    - `model` string
    - `estimated_credits` integer

## Other responses

- `400`: Bad request - invalid parameters
- `401`: Unauthorized - invalid or missing API key
- `429`: Rate limit exceeded

---

[API](https://skmtc.dev/aimagicx/apis/ai-magicx-api.md) - [All operations](https://skmtc.dev/aimagicx/apis/ai-magicx-api/llms.txt) - [OpenAPI document](https://skmtc.dev/aimagicx/apis/ai-magicx-api/revisions/08210272abb4?raw)
