Skip to main content
POST
https://api.apimart.ai
/
v1
/
images
/
generations
curl --request POST \
  --url https://api.apimart.ai/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "flux-2-flex",
    "prompt": "A blue cat on the grass",
    "resolution": "1K",
    "size": "16:9"
  }'
{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01KFG5BBFNK1YQDTJDZY0P0QT2"
    }
  ]
}
curl --request POST \
  --url https://api.apimart.ai/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "flux-2-flex",
    "prompt": "A blue cat on the grass",
    "resolution": "1K",
    "size": "16:9"
  }'
{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01KFG5BBFNK1YQDTJDZY0P0QT2"
    }
  ]
}

Supported Models

ModelDescriptionPricing
flux-2-flexFlux 2.0 Flex image generation model (faster, suitable for quick iterations)By resolution (1K/2K)
flux-2-proFlux 2.0 Pro image generation model (higher quality, better details)By resolution (1K/2K)

Authorizations

Authorization
string
required
All endpoints require Bearer Token authenticationGet API Key:Visit API Key Management to get your API KeyAdd to request header:
Authorization: Bearer YOUR_API_KEY

Body

model
string
required
Model name
  • flux-2-flex - Flux 2.0 Flex model (faster, suitable for quick iterations)
  • flux-2-pro - Flux 2.0 Pro model (higher quality, better details)
prompt
string
required
Text description for image generation
resolution
string
default:"1K"
Image resolutionSupported resolutions:
  • 1K - Default, 1080p level
  • 2K - HD, max 2048 pixels
Case insensitive: 1k, 1K, 2k, 2K all work
size
string
default:"1:1"
Image aspect ratioSupported aspect ratios:
  • 1:1 - Square (default)
  • 4:3 - Landscape
  • 3:4 - Portrait
  • 16:9 - Widescreen
  • 9:16 - Vertical
  • 3:2 - Classic landscape
  • 2:3 - Classic portrait
Only these 7 ratios are supported, unsupported ratios will return an error
image_urls
array
Reference image URL listLimitations:
  • Maximum 8 images
  • Must be publicly accessible URL
  • Base64 format not supported

Resolution Reference Table

RatioName1K Size2K Size
1:1Square1440×14401536×1536
4:3Landscape1664×12481824×1368
3:4Portrait1248×16641368×1824
16:9Widescreen1920×10802048×1152
9:16Vertical1080×19201152×2048
3:2Classic Landscape1728×11521872×1248
2:3Classic Portrait1152×17281248×1872

Usage Examples

Basic Text-to-Image
{
    "model": "flux-2-flex",
    "prompt": "A blue cat",
    "resolution": "1K",
    "size": "16:9"
}
High Resolution Generation
{
    "model": "flux-2-pro",
    "prompt": "Detailed landscape painting with mountains and rivers",
    "resolution": "2K",
    "size": "16:9"
}
Image-to-Image (up to 8 reference images)
{
    "model": "flux-2-flex",
    "prompt": "Convert image to watercolor style",
    "image_urls": [
        "https://example.com/input1.jpg",
        "https://example.com/input2.jpg"
    ],
    "resolution": "1K"
}

Response

code
integer
Response status code
data
array
Response data array

Notes

  1. Image URL Requirements: Input images must be publicly accessible URLs, base64 not supported
  2. Result Storage: Generated images are automatically stored, URLs valid for 24 hours
  3. Task Polling: Tasks are processed asynchronously, poll /v1/tasks/{task_id} for results
  4. Input Image Limits: Up to 8 reference images supported