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-kontext-pro",
    "prompt": "Change hair color to blue",
    "image_urls": ["https://example.com/input.png"],
    "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-kontext-pro",
    "prompt": "Change hair color to blue",
    "image_urls": ["https://example.com/input.png"],
    "size": "16:9"
  }'
{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01KFG5BBFNK1YQDTJDZY0P0QT2"
    }
  ]
}

Supported Models

ModelDescriptionPricing
flux-kontext-proFlux Kontext Pro image editing modelFixed price
flux-kontext-maxFlux Kontext Max image editing model (higher quality)Fixed price

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-kontext-pro - Kontext Pro model
  • flux-kontext-max - Kontext Max model (higher quality)
prompt
string
required
Text description for image generation
image_urls
array
Input image URL listLimitations:
  • Only 1 image supported
  • Must be publicly accessible URL
  • Base64 format not supported
size
string
default:"With image: match_input_image, Without: 16:9"
Image aspect ratioSupported aspect ratios:
  • match_input_image - Match input image ratio (default when image provided)
  • auto - Same as match_input_image
  • 1:1 - Square
  • 4:3 - Landscape 4:3
  • 3:4 - Portrait 3:4
  • 16:9 - Landscape widescreen (default without image)
  • 9:16 - Portrait vertical
  • 3:2 - Landscape 3:2
  • 2:3 - Portrait 2:3
  • 21:9 - Ultra-wide
  • 9:21 - Ultra-tall
response_format
string
default:"png"
Output image format
  • png - PNG format (default)
  • jpg - JPEG format
safety_tolerance
integer
default:"2"
Safety toleranceRange: 0-6, higher values are more permissive
prompt_upsampling
boolean
default:"false"
Enable prompt enhancement
  • true - Enable
  • false - Disable (default)

Usage Examples

Image Editing (with input image)
{
    "model": "flux-kontext-pro",
    "prompt": "Change background to beach",
    "image_urls": ["https://example.com/photo.jpg"]
}
Text-to-Image (without input image)
{
    "model": "flux-kontext-pro",
    "prompt": "A blue cat",
    "size": "16:9"
}

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: Only 1 image supported