All pages
Powered by GitBook
1 of 64

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Alibaba Cloud

qwen-image

This documentation is valid for the following list of our models:

  • alibaba/qwen-image

Model Overview

A high-performance image generation base model that can handle intricate text rendering and perform accurate image editing.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate an image of the specified size using a simple prompt.

Response

We obtained the following 1024x768 image by running this code example:

Try in Playground
Quickstart guide
'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.'
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "alibaba/qwen-image",
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses."
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'alibaba/qwen-image',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log('Generation:', data);
}

main();
{
  "images": [
    {
      "url": "https://cdn.aimlapi.com/eagle/files/kangaroo/0WBwo2ruHEK9vpmtxu04G.jpeg",
      "width": 1024,
      "height": 768,
      "content_type": "image/jpeg"
    }
  ],
  "timings": {
    "inference": 5.732342581963167
  },
  "seed": 4128479875,
  "has_nsfw_concepts": [
    false
  ],
  "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses."
}

OpenAI

ByteDance

RecraftAI

Stability AI

Google

xAI

Reve

Topaz Labs

Tencent

z-image-turbo-lora

This documentation is valid for the following list of our models:

  • alibaba/z-image-turbo-lora

Model Overview

An ultra-fast 6B-parameter text-to-image model with LoRA support.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate an image of the specified size using a simple prompt.

Response

We obtained the following 1440x512 image by running this code example:

z-image-turbo

This documentation is valid for the following list of our models:

  • alibaba/z-image-turbo

Try in Playground

Model Overview

An ultra-fast 6B-parameter text-to-image model.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image of the specified size using a simple prompt.

Response

We obtained the following 1440x512 image by running this code example:

Try in Playground
Quickstart guide

flux-realism

This documentation is valid for the following list of our models:

  • flux-realism

Model Overview

A state-of-the-art model designed to generate photorealistic images from textual descriptions. It allows users to create lifelike visuals without the need for extensive realism-related prompts.

Model
Generated image properties

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate an image of the specified size using a simple prompt.

The maximum value for both width and height is 1536, and the minimum is 512. The value must be a multiple of 32.

Response

We obtained the following 1472x512 image by running this code example. The textures look significantly more realistic compared to the earlier FLUX models.

We were also curious how the model would perform with more large-scale scenes. Here's what we got with the prompt 'Epic battle of spaceships'.

qwen-image-edit

This documentation is valid for the following list of our models:

  • alibaba/qwen-image-edit

Model Overview

The image editing variant of our 20B model. It expands the model’s distinctive text rendering abilities to editing tasks, making accurate text modifications within images possible.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate an image using an input image and a prompt that defines how it should be edited.

Response

We obtained the following 1184x896 image by running this code example:

flux-pro/v1.1

This documentation is valid for the following list of our models:

  • flux-pro/v1.1

flux/srpo/text-to-image

This documentation is valid for the following list of our models:

  • flux/srpo

flux-2-pro

This documentation is valid for the following list of our models:

  • blackforestlabs/flux-2-pro

flux/dev/image-to-image

This documentation is valid for the following list of our models:

  • flux/dev/image-to-image

DALL·E 2

This documentation is valid for the following list of our models:

  • dall-e-2

Grok 2 Image

This documentation is valid for the following list of our models:

  • x-ai/grok-2-image

import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "alibaba/z-image-turbo",
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
            "image_size": {
                "width": 1440,
                "height": 512
            },
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'alibaba/z-image-turbo',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
      image_size: {
        width: 1440,
        height: 512
      },
    }),
  });

  const data = await response.json();
  console.log('Generation:', data);
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/flamingo/files/b/0a84de46/GTZfn0tOOQzXlC2Wvpzz9.png"
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 10500
    }
  }
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "alibaba/z-image-turbo-lora",
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
            "image_size": {
                "width": 1440,
                "height": 512
            },
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'alibaba/z-image-turbo-lora',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
      image_size: {
        width: 1440,
        height: 512
      },
    }),
  });

  const data = await response.json();
  console.log('Generation:', data);
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/flamingo/files/b/0a84de54/-IaUBYEQiYqRaeT7oZvus.png"
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 17850
    }
  }
}

Try in Playground

Model Overview

flux-pro/v1.1 is a new image generation model with inference speed increased sixfold compared to the previous flux-pro. It also features enhanced generation quality and greater accuracy in following prompts.

Model
Properties of Generated Images

flux-pro/v1.1

Format: JPEG, PNG Min size: 256x256 Max size: 1440x1440 Default size: 1024x768 For both height and width, the value must be a multiple of 32.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image of the specified size using a simple prompt.

The maximum value for both width and height is 1440, and the minimum is 256. The value must be a multiple of 32.

Response

We obtained the following 1024x320 image (JPEG) by running this code example:

"A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses."

Try in Playground

Model Overview

flux/dev model upgraded with Tencent’s SRPO technique.

Model
Generated image properties

flux/srpo

Format: PNG Min size: 512x512 Max size: 1536x1536 Default size: 1024x768 For both height and width, the value must be a multiple of 32.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image using a simple prompt.

Response

We obtained the following 1440x512 image by running this code example:

'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.'

Try in Playground

Model Overview

An advanced text-to-image model optimized for high-quality manipulation.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image of the specified size using a simple prompt.

Response

We obtained the following nice 1472x512 image by running this code example:

"A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses."

Try in Playground

Model Overview

A state-of-the-art image generation model that utilizes a 12 billion parameter rectified flow transformer architecture. It is designed to generate high-quality images from textual descriptions, making it a powerful tool for developers and creatives.

Model
Generated image properties

flux/dev/image-to-image

Format: PNG Fixed size: Matches the dimensions of the reference image.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate a new image using the one from the flux/dev Quick Example as a reference — and make a simple change to it with a prompt.

Response
Reference Image
Generated Image

Try in Playground

Model Overview

An advanced AI system designed to generate high-quality images and artwork from textual descriptions. It builds upon its predecessor, DALL·E 1, utilizing improved techniques to create images that are more realistic and contextually accurate.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image of the specified size using a simple prompt.

Response

We obtained the following 1024x1024 image by running this code example:

"A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses."

Try in Playground

Model Overview

xAI’s flagship image generation model as of summer 2025, producing photorealistic visuals from text prompts.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image of the specified size using a simple prompt.

Response

We obtained the following 720x960 image by running this code example:

"A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses."

flux-realism

Format: JPEG, PNG Min size: 512x512 Max size: 1536x1536 Default size: 1024x768 For both height and width, the value must be a multiple of 32.

Try in Playground
Quickstart guide
'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.'
'Epic battle of spaceships'
Try in Playground
qwen-image
Quickstart guide
'Make the dinosaur sit on a lounge chair with its back to the camera, looking toward the water. The setting sun has almost disappeared below the horizon.'

flux-2-edit

This documentation is valid for the following list of our models:

  • blackforestlabs/flux-2-edit

Model Overview

A 4MP photorealistic, production-grade editor with advanced multi-reference control capabilities.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate an image using two input images and a prompt that defines how they should be edited.

Response
Reference Images
Generated Image

Seedream 4.0 (Text-to-Image)

This documentation is valid for the following list of our models:

  • bytedance/seedream-v4-text-to-image

Model Overview

Ultra-fast, consistent in character rendering, and matching in quality.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate an image of the specified size using a simple prompt.

Response

We obtained the following 4096x4096 image by running this code example:

Seedream 4.5

This documentation is valid for the following list of our models:

  • bytedance/seedream-4-5

Model Overview

The model combines both text-to-image and image-to-image capabilities. Compared to , this model significantly improves editing consistency (preserving subject details, lighting, and color tone), the quality of portraits and small text.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate a new image using the one from as a reference — and make a simple change to it with a prompt.

Response
Reference Images
Generated Image

Imagen 4 Ultra Preview

This documentation is valid for the following list of our models:

  • imagen-4.0-ultra-generate-preview-06-06

Model Overview

Google’s highest quality image generation model as of July 2025. Supports automatic AI prompt enhancement and pre-moderation of generated content.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate an image of the specified aspect ratio using a simple prompt.

Response

So we obtained the following 1408x768 image by running this code example:

flux-2-lora-edit

This documentation is valid for the following list of our models:

  • blackforestlabs/flux-2-lora-edit

Model Overview

This image-to-image model enables you to apply your trained LoRA adapters, producing domain-specific outputs aligned with your brand aesthetic, expert content areas, or specialized visual constraints.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate an image of the specified size using two input images and a prompt that defines how they should be edited.

Response
Reference Images
Generated Image

flux/srpo/image-to-image

This documentation is valid for the following list of our models:

  • flux/srpo/image-to-image

Model Overview

model upgraded with Tencent’s SRPO technique.

Model
Generated image properties

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate a new image using the one from the as a reference — and make a simple change to it with a prompt.

Response
Reference Image
Generated Image

flux-pro/v1.1-ultra

This documentation is valid for the following list of our models:

  • flux-pro/v1.1-ultra

Model Overview

An advanced AI image generator designed to create high-resolution images rapidly and efficiently. It is optimized for various applications, including content creation, e-commerce, and advertising, providing users with the ability to generate visually appealing images at unprecedented speeds.

Model
Generated image properties

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate an image using a simple prompt.

Response

We obtained the following 2752x1536 image by running this code example:

flux/schnell

This documentation is valid for the following list of our models:

  • flux/schnell

Model Overview

A state-of-the-art text-to-image generation model designed to create high-quality images from textual descriptions. With a robust architecture of 12 billion parameters, it leverages advanced techniques to produce images that rival those generated by leading closed-source models.

Model
Generated image properties

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate an image of the specified size using a simple prompt.

The minimum size is 64x64, and the minimum is 1536x1536. The width and height value must be a multiple of 32.

Response

We obtained the following 1440x512 image by running this code example:

USO (Image-to-Image)

This documentation is valid for the following list of our models:

  • bytedance/uso

Model Overview

USO (Unified Style-Subject Optimized) — a single model that seamlessly combines style-based and subject-based image generation.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate an image of the specified size using a simple prompt.

Response
Reference Image
Generated Image

reve/remix-edit-image

This documentation is valid for the following list of our models:

  • reve/remix-edit-image

Model Overview

The model takes multiple images as input, with the prompt defining how they are used or combined.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate an image using two input images and a prompt that defines how they should be edited.

Response
Reference Images
Generated Image

reve/edit-image

This documentation is valid for the following list of our models:

  • reve/edit-image

Model Overview

The model allows you to modify images using plain text commands: adjust colors, text, and perspectives.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate a new image using the one from the as a reference — and make a simple change to it with a prompt.

Response
Reference Image
Generated Image

flux-2-pro-edit

This documentation is valid for the following list of our models:

  • blackforestlabs/flux-2-pro-edit

Model Overview

An advanced image editing model optimized for high-quality manipulation, style transfer, and sequential editing tasks.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate an image of the specified size using two input images and a prompt that defines how they should be edited.

Response
Reference Images
Generated Image

Recraft v3

This documentation is valid for the following list of our models:

  • recraft-v3

Model Overview

A state-of-the-art image generation model specifically designed for professional designers, featuring advanced text generation capabilities, anatomical accuracy, and precise style control. It stands out for its ability to generate images with extended text content and vector art support.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate an image using a simple prompt.

Response

We obtained the following 2048x1024 image by running this code example:

One of recraft-v3’s strengths is its wide range of supported styles. By default, it generates realistic images, but we tried a few others—here’s what we got:

Style Experiments

When the 'vector_illustration' style is selected, the model generates an SVG vector format! For preview purposes, we took a screenshot ☝️️

flux-2-lora

This documentation is valid for the following list of our models:

  • blackforestlabs/flux-2-lora

flux/dev

This documentation is valid for the following list of our models:

  • flux/dev

flux-pro

This documentation is valid for the following list of our models:

  • flux-pro

Seedream 3.0

This documentation is valid for the following list of our models:

  • bytedance/seedream-3.0

Imagen 4 Fast Generate

This documentation is valid for the following list of our models:

  • google/imagen-4.0-fast-generate-001

Imagen 4 Generate

This documentation is valid for the following list of our models:

  • google/imagen-4.0-generate-001

Flux

Flux, a subsidiary project of Black Forest Labs, is represented in our API by the following models:

Model
Generated image properties

Imagen 4 Preview

This documentation is valid for the following list of our models:

  • google/imagen4/preview

Seededit 3.0 (Image-to-Image)

This documentation is valid for the following list of our models:

  • bytedance/seededit-3.0-i2i

Sharpen

This documentation is valid for the following list of our models:

  • topaz-labs/sharpen

flux/kontext-pro/text-to-image

This documentation is valid for the following list of our models:

  • flux/kontext-pro/text-to-image

flux/kontext-max/text-to-image

This documentation is valid for the following list of our models:

  • flux/kontext-max/text-to-image

Imagen 3

This documentation is valid for the following list of our models:

  • imagen-3.0-generate-002

Nano Banana Pro (Gemini 3 Pro Image)

This documentation is valid for the following list of our models:

  • google/nano-banana-pro

DALL·E 3

This documentation is valid for the following list of our models:

  • dall-e-3

flux-2

This documentation is valid for the following list of our models:

  • blackforestlabs/flux-2

Hunyuan Image v3

This documentation is valid for the following list of our models:

  • hunyuan/hunyuan-image-v3-text-to-image

reve/create-image

This documentation is valid for the following list of our models:

  • reve/create-image

import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
            "model": "flux-pro/v1.1",
            'image_size': {
                "width": 1024,
                "height": 320
            }
        }
    )
    
    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux-pro/v1.1',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
      image_size: {
        width: 1024,
        height: 320
      },
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  images: [
    {
      url: 'https://cdn.aimlapi.com/squirrel/files/zebra/i1zUlcHZ0o3V2DEeyi2bL_6a366eac61354652a0430750e53bc839.jpg',
      width: 1024,
      height: 320,
      content_type: 'image/jpeg'
    }
  ],
  timings: {},
  seed: 1345862631,
  has_nsfw_concepts: [ false ],
  prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.'
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "flux/srpo",
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
            "image_size": {
                "width": 1440,
                "height": 512
            }  
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux/srpo',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
      image_size: {
                width: 1440,
                height: 512
            }
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  "images": [
    {
      "url": "https://cdn.aimlapi.com/eagle/files/zebra/GtH4bTLhiXD7YTwYAlO21.jpeg",
      "width": 1440,
      "height": 512,
      "content_type": "image/jpeg"
    }
  ],
  "timings": {
    "inference": 0.747110141441226
  },
  "seed": 490733907,
  "has_nsfw_concepts": [
    false
  ],
  "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
  "data": [
    {
      "url": "https://cdn.aimlapi.com/eagle/files/zebra/GtH4bTLhiXD7YTwYAlO21.jpeg",
      "width": 1440,
      "height": 512,
      "content_type": "image/jpeg"
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 52500
    }
  }
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json"
        },
        json={
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
            "model": "blackforestlabs/flux-2-pro",
            "image_size": {
                "width": 1472,
                "height": 512 
            }
        }
    )
    
    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__": 
    main()   
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'blackforestlabs/flux-2-pro',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
      image_size: {
        width: 1472,
        height: 512
      },
    }),
  });

  const data = await response.json();
  console.log('Generation:', data);
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/flamingo/files/b/0a847b9d/C6y_7teCcSaSqeYkhIrnt.png"
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 63000
    }
  }
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "flux/dev/image-to-image",
            "prompt": "Add a bird to the foreground of the photo.",
            "image_url": "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
            "strength": 0.8
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux/dev/image-to-image',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
      image_url: 'https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png',
      strength: 0.8,
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  images: [
    {
      url: 'https://cdn.aimlapi.com/eagle/files/elephant/RmRsL9NMW_kkRy6MemjZJ_ac9897dd871842e2a689b8bc24b4bf08.jpg',
      width: 1472,
      height: 512,
      content_type: 'image/jpeg'
    }
  ],
  timings: { inference: 4.4450759180035675 },
  seed: 3082066483,
  has_nsfw_concepts: [ false ],
  prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.'
}
import requests
import json

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
            "model": "dall-e-2"
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'dall-e-2',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
      quality: 'hd'
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  created: 1756972085,
  data: [
    {
      url: 'https://oaidalleapiprodscus.blob.core.windows.net/private/org-5drZvxmo1TGoMx2jeKKGAGSh/user-eKr1xiaNRxSYqgKrXfgZzSAJ/img-lrG5yb73YupujdUiDfx1sUpo.png?st=2025-09-04T06%3A48%3A05Z&se=2025-09-04T08%3A48%3A05Z&sp=r&sv=2024-08-04&sr=b&rscd=inline&rsct=image/png&skoid=0e2a3d55-e963-40c9-9c89-2a1aa28cb3ac&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2025-09-04T03%3A29%3A29Z&ske=2025-09-05T03%3A29%3A29Z&sks=b&skv=2024-08-04&sig=5mTzRo50JWr%2BuoqSOAXW9WZ0%2Bak93/rMwp2sZo3sLYE%3D'
    }
  ]
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "x-ai/grok-2-image",
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses."
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'x-ai/grok-2-image',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log('Generation:', data);
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/xolmis/xai-imgen/xai-tmp-imgen-81fc6308-29a8-46c8-8d5a-16060c0724e8.jpeg",
      "revised_prompt": "A high-resolution photograph of a T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses. The T-Rex is facing slightly to the right, with its sunglasses clearly visible. The background features a calm ocean and a few palm trees, set during the day with natural, soft lighting. The beach is relatively empty, focusing attention on the T-Rex. There are no distracting elements like birds or other animals, ensuring the T-Rex remains the central figure in the composition. The overall mood is serene and tranquil, emphasizing the unusual yet peaceful scene."
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 147000
    }
  }
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
            "model": "flux-realism",
            "image_size": {
                "width": 1472,
                "height": 512
            }
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux-realism',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
      image_size: {
        width: 1472,
        height: 512
      },
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  images: [
    {
      url: 'https://cdn.aimlapi.com/eagle/files/elephant/RmRsL9NMW_kkRy6MemjZJ_ac9897dd871842e2a689b8bc24b4bf08.jpg',
      width: 1472,
      height: 512,
      content_type: 'image/jpeg'
    }
  ],
  timings: { inference: 4.4450759180035675 },
  seed: 3082066483,
  has_nsfw_concepts: [ false ],
  prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.'
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "alibaba/qwen-image-edit",
            "prompt": "Make the dinosaur sit on a lounge chair with its back to the camera, looking toward the water. The setting sun has almost disappeared below the horizon.",
            "image": "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png"
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()

const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
  method: 'POST',
  headers: {
    // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
    'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'alibaba/qwen-image-edit',
    prompt: 'Make the dinosaur sit on a lounge chair with its back to the camera, looking toward the water. The setting sun has almost disappeared below the horizon.',
    image: 'https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png',        
  }),
});

const data = await response.json();
console.log(JSON.stringify(data, null, 2));
{
  "created": 1756832341,
  "data": [
    {
      "url": "https://dashscope-result-sgp.oss-ap-southeast-1.aliyuncs.com/7d/06/20250903/1955eee6/ac748d89-d6b1-4d4e-bc65-eea543098bb9-1.png?Expires=1757438140&OSSAccessKeyId=LTAI5tRcsWJEymQaTsKbKqGf&Signature=aDhUphXV84V1nPMmdRl49ShSKxY%3D"
    }
  ]
}
"style": "digital_illustration/handmade_3d"
Quickstart guide
"style": "digital_illustration/infantile_sketch"
"style": "vector_illustration"
"style": "digital_illustration/2d_art_poster"

Try in Playground

Model Overview

This text-to-image model enables you to apply your trained LoRA adapters, producing domain-specific outputs aligned with your brand aesthetic, expert content areas, or specialized visual constraints.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image of the specified size using a simple prompt.

Response

We obtained the following nice 1472x512 image by running this code example:

"A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses."

Try in Playground

Model Overview

A state-of-the-art image generation model that utilizes a 12 billion parameter rectified flow transformer architecture. It is designed to generate high-quality images from textual descriptions, making it a powerful tool for developers and creatives.

Model
Generated image properties

flux/dev

Format: PNG Min size: 512x512 Max size: 1536x1536 Default size: 1024x768 For both height and width, the value must be a multiple of 32.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image using a simple prompt.

Response

We obtained the following 1024x768 image by running this code example:

'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.'

Try in Playground

Model Overview

This is first version of Flux Pro, but it generates images of unmatched quality, outperforming popular models like Midjourney v6.0, DALL·E 3 (HD), and SD3-Ultra.

You can also view a detailed comparison of this model on our main website.

Model
Properties of Generated Images

flux-pro

Format: JPEG, PNG Min size: 256x256 Max size: 1440x1440 Default size: 1024x768 For both height and width, the value must be a multiple of 32.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image of the specified size using a simple prompt.

The maximum value for both width and height is 1440, and the minimum is 256. The value must be a multiple of 32.

Response

We obtained the following nice 1024x320 image by running this code example:

"A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses."

Try in Playground

Model Overview

This bilingual (Chinese-English) image generation model supports arbitrary image dimensions — as long as the product of width and height remains within a generous limit (up to 2K). It offers faster response times, improved rendering of small text and layouts, stronger visual aesthetics and structural consistency, and high fidelity in fine details.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image of the specified size using a simple prompt.

Response

We obtained the following 1888x301 image by running this code example:

'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.'

Here’s an example of a 555×543 image generated using the same prompt:

'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.'

Try in Playground

Model Overview

This model is optimized for speed, offering faster image generation compared to other Imagen 4 variants like Imagen 4 Generate 001 (standard) and Imagen 4 Ultra Generate 001 (higher quality, slower).

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image of the specified aspect ratio using a simple prompt.

Response

So we obtained the following 1408x768 image by running this code example:

In reality, raccoons shouldn’t be given ice cream or chocolate—it’s harmful to their metabolism. But in the AI world, raccoons party like there’s no tomorrow.

Try in Playground

Model Overview

An advanced text-to-image model delivering a balance of speed and image quality.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image of the specified aspect ratio using a simple prompt.

Response

So we obtained the following 1408x768 image by running this code example:

In reality, raccoons shouldn’t be given ice cream or chocolate—it’s harmful to their metabolism. But in the AI world, raccoons party like there’s no tomorrow.

Format: PNG Min size: 64x64 Max size: 1536x1536 Default size: 1024x768 For both height and width, the value must be a multiple of 32.

Format: PNG Min size: 512x512 Max size: 1536x1536 Default size: 1024x768 For both height and width, the value must be a multiple of 32.

Format: PNG Fixed size: Matches the dimensions of the reference image.

Format: JPEG, PNG Image size can't be set directly — only a preset aspect ratio can be chosen. Default aspect ratio and size: 1:1, 1024x1024

Format: JPEG, PNG Image size can't be set directly — only a preset aspect ratio can be chosen. Default aspect ratio and size: 16:9, 1184x880 (well, not quite 16:9)

Format: JPEG, PNG Image size can't be set directly — only a preset aspect ratio can be chosen. Default aspect ratio and size: 1:1, 1024x1024

Format: JPEG, PNG Image size can't be set directly — only a preset aspect ratio can be chosen. Default aspect ratio and size: 16:9, 1184x880 (well, not quite 16:9)

flux-pro

Format: JPG, PNG Min size: 256x256 Max size: 1440x1440 Default size: 1024x768 For both height and width, the value must be a multiple of 32.

flux-pro/v1.1

Format: JPG, PNG Min size: 256x256 Max size: 1440x1440 Default size: 1024x768 For both height and width, the value must be a multiple of 32.

flux-pro/v1.1-ultra

Format: JPG, PNG Fixed size: 2752x1536

flux-realism

Format: JPG, PNG Min size: 512x512 Max size: 1536x1536 Default size: 1024x768 For both height and width, the value must be a multiple of 32.

Try in Playground

Model Overview

Google’s highest quality image generation model as of May 2025.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image of the specified aspect ratio using a simple prompt.

Response

So we obtained the following 1408x768 image by running this code example:

In reality, raccoons shouldn’t be given ice cream or chocolate—it’s harmful to their metabolism. But in the AI world, raccoons party like there’s no tomorrow.

Try in Playground

Model Overview

This model can process and generate 4K images, editing selected areas naturally and precisely while faithfully preserving the visual fidelity of non-edited areas.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image of the specified size using a simple prompt.

Response
Reference Image
Generated Image
More generated images

Model Overview

The model produces sharper visuals, eliminating blur and improving clarity across the subject or the entire frame.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's sharpen a relatively strongly blurred image using the Strong mode while adjusting the strength parameter.

Response
Blurred Image
Deblurred Image

For clarity, we’ve created a split image showing the results of different parameter settings.

Try in Playground

Model Overview

A new Flux model optimized for faster generation speed.

Model
Properties of Generated Images

flux/kontext-pro/text-to-image

Format: JPEG, PNG Image size can't be set directly — only a preset aspect ratio can be chosen. Default aspect ratio and size: 1:1, 1024x1024

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image of the specified size using a simple prompt.

Response

We obtained the following 1568x672 image by running this code example:

'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.'

Try in Playground

Model Overview

A new Flux model optimized for maximum image quality.

Model
Properties of Generated Images

flux/kontext-max/text-to-image

Format: JPEG, PNG Image size can't be set directly — only a preset aspect ratio can be chosen. Default aspect ratio and size: 1:1, 1024x1024

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image of the specified size using a simple prompt.

Response

We obtained the following 1568x672 image by running this code example:

'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.'

Try in Playground

Model Overview

Google's latest text-to-image AI model, designed to generate high-quality, photorealistic images from text descriptions with improved detail, lighting, and fewer artifacts. It boasts enhanced natural language understanding and better text rendering.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image of the specified size using a simple prompt.

Note that prompt enhancement is enabled by default. The model will also return the enhanced prompt in the response. If you prefer not to use this feature, set the parameter enhance_prompt to False.

Response

Default aspect ratio is 1:1, so we obtained the following 1024x1024 image by running this code example:

In reality, raccoons shouldn’t be given ice cream or chocolate—it’s harmful to their metabolism. But in the AI world, raccoons party like there’s no tomorrow.

google/gemini-3-pro-image-preview

Both IDs listed above refer to the same model; we support them for backward compatibility.

Try in Playground

Model Overview

Google’s smartest text-to-image model as of the November 2025 preview release.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image of the specified aspect ratio using a simple prompt.

Response

So we obtained the following 1024x1024 image by running this code example:

"aspect_ratio": "1:1", "resolution": "1K"

Here’s an example of the output using alternative resolution and aspect_ratio parameters:

"aspect_ratio": "16:9", "resolution": "2K"

Try in Playground

Model Overview

This model represents a significant leap forward in AI-driven image creation, capable of generating images from text inputs. This model processes prompts with enhanced neural network architectures, resulting in images that are not only relevant but also rich in detail and diversity. DALL·E 3's deep learning techniques analyze and understand complex descriptions, allowing for the generation of visuals across a wide range of styles and subjects.

You can also view a detailed comparison of this model on our main website.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image using a simple prompt.

Note that the model applies automatic prompt enhancement, and this behavior cannot be disabled. The enhanced prompt is also returned in the response (see the revised_prompt parameter in the response).

Response
"A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses."

Try in Playground

Model Overview

A 4MP photorealistic, production-grade text-to-image generator.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image of the specified size using a simple prompt.

Response

We obtained the following nice 1472x512 image by running this code example:

"A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses."

Try in Playground

Model Overview

An advanced capabilities of Hunyuan Image 3.0 to generate compelling visuals that seamlessly enhance and communicate your written content.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image using a simple prompt.

Response

We obtained the following 1280x768 image by running this code example:

A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.

Try in Playground

Model Overview

A model trained from the ground up for strong prompt adherence, refined aesthetics, and typography.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image of the specified size using a simple prompt.

Response

We obtained the following nice 1360x768 image by running this code example:

"A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses."
Image #1
"Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect."
Image #2

Try in Playground
Quickstart guide
Try in Playground
Gemini 2.5 Flash Image (Nano Banana)
Quickstart guide
"A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses."
Image #1
"Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect."
Image #2

Try in Playground
Seedream 4.0
Quickstart guide
the flux/dev Quick Example
Try in Playground
Quickstart guide
In reality, raccoons shouldn’t be given ice cream or chocolate—it’s harmful to their metabolism. But in the AI world, raccoons party like there’s no tomorrow.
Image #1
"Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect."
Image #2

Try in Playground
Quickstart guide

flux/srpo/image-to-image

Format: JPEG, PNG Fixed size: Matches the dimensions of the reference image.

Try in Playground
flux/dev/image-to-image
Quickstart guide
flux/dev Quick Example

flux-pro/v1.1-ultra

Format: JPEG, PNG Fixed size: 2752x1536

Try in Playground
Quickstart guide
'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.'

flux/schnell

Format: PNG Min size: 64x64 Max size: 1536x1536 Default size: 1024x768 For both height and width, the value must be a multiple of 32.

Try in Playground
Quickstart guide
'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.'
(original)
"The T-Rex is wearing a business suit, sitting in a cozy small café, drinking from a mug. Blur the background slightly to create a bokeh effect."
Try in Playground
Quickstart guide
Image #1
"Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect."
Image #2

Quickstart guide

Try in Playground
Quickstart guide
flux/dev Quick Example
Image #1
"Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect."
Image #2

Try in Playground
Quickstart guide

Stable Diffusion v3.5 Large

This documentation is valid for the following list of our models:

  • stable-diffusion-v35-large

Model Overview

A state-of-the-art text-to-image generative model designed to create high-resolution images based on textual prompts. It excels in producing diverse and high-quality outputs, making it suitable for professional applications.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate an image using a simple prompt.

Response

We obtained the following 1024x576 image by running this code example:

Extra pictures

Gemini 2.5 Flash Image Edit (Nano Banana)

This documentation is valid for the following list of our models:

  • google/gemini-2.5-flash-image-edit

Model Overview

The model takes multiple images as input, with the prompt defining how they are used or combined.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Aspect ratio/Resolution Table
Aspect ratio
Resolution
Credits

Quick Example

Let's generate an image using two input images and a prompt that defines how they should be edited.

Response
Reference Images
Generated Image

Gemini 2.5 Flash Image (Nano Banana)

This documentation is valid for the following list of our models:

  • google/gemini-2.5-flash-image

Model Overview

Google’s smartest image generation model as of August 2025.

Images produced or modified with Gemini 2.5 Flash Image carry an invisible SynthID digital watermark, allowing them to be recognized as AI-generated or edited.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate an image of the specified aspect ratio using a simple prompt.

Response

So we obtained the following 1024x1024 image by running this code example:

Seedream 4.0 Edit (Image-to-image)

This documentation is valid for the following list of our models:

  • bytedance/seedream-v4-edit

Model Overview

The model supports background replacement, object editing, style and color adjustments, lighting and texture enhancements, and artistic filters, while ensuring character consistency and allowing iterative refinement.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate an image using two input images and a prompt that defines how they should be edited.

Response
Reference Image
Generated Image

Stable Diffusion v3 Medium

This documentation is valid for the following list of our models:

  • stable-diffusion-v3-medium

Model Overview

An advanced text-to-image generation model that utilizes a Multimodal Diffusion Transformer (MMDiT) architecture to produce high-quality images from textual descriptions.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate an image using a simple prompt.

Response

We obtained the following 1024x576 image by running this code example:

Sharpen Generative

This documentation is valid for the following list of our models:

  • topaz-labs/sharpen-gen

Model Overview

A next-level sharpening model powered by generative AI, capable of recovering missing details during the refocusing/resharpening process.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's sharpen a relatively strongly blurred image using the Strong mode while adjusting the strength parameter.

Response
Blurred Image
Deblurred Image

Imagen 4 Ultra Generate

This documentation is valid for the following list of our models:

  • google/imagen-4.0-ultra-generate-001

import requests
import json

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "recraft-v3",
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses."
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'recraft-v3',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses. Realistic photo.',
      
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  images: [
    {
      url: 'https://cdn.aimlapi.com/eagle/files/koala/Z1MUK5lqaL70uC5Mn6Rlj_image.webp',
      content_type: 'image/webp',
      file_name: 'image.webp',
      file_size: 347808
    }
  ]
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json"
        },
        json={
            "model": "blackforestlabs/flux-2-lora",
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
            "image_size": {
                "width": 1472,
                "height": 512 
            }
        }
    )
    
    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__": 
    main()   
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'blackforestlabs/flux-2-lora',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
      image_size: {
        width: 1472,
        height: 512
      },
    }),
  });

  const data = await response.json();
  console.log('Generation:', data);
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/flamingo/files/b/0a847b04/UNSH9jzS_1AHujNGtda30.png"
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 44100
    }
  }
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "flux/dev",
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux/dev',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  "images": [
    {
      "url": "https://cdn.aimlapi.com/eagle/files/monkey/zS_fT2UFKmLqlbEHYCRys.jpeg",
      "width": 1024,
      "height": 768,
      "content_type": "image/jpeg"
    }
  ],
  "timings": {
    "inference": 1.226824438199401
  },
  "seed": 1765470393,
  "has_nsfw_concepts": [
    false
  ],
  "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses."
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json"
        },
        json={
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
            "model": "flux-pro",
            "image_size": {
                "width": 1024,
                "height": 320 
            }
        }
    )
    
    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__": 
    main()   
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux-pro',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
      image_size: {
        width: 1024,
        height: 320
      },
    }),
  });

  const data = await response.json();
  console.log('Generation:', data);
}

main();
{
  images: [
    {
      url: 'https://cdn.aimlapi.com/squirrel/files/elephant/G1UYumZngIkBozNrfiztZ_8d758419045c4c16b563511d6f5f3966.jpg',
      width: 1024,
      height: 320,
      content_type: 'image/jpeg'
    }
  ],
  timings: {},
  seed: 711728385,
  has_nsfw_concepts: [ false ],
  prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.'
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "bytedance/seedream-3.0",
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
            "aspect_ratio": "16:9",        
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'bytedance/seedream-3.0',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
      aspect_ratio: '16:9',
    }),
  });

  const data = await response.json();
  console.log('Generation:', data);
}

main();
Generation: {'created': 1751616711, 'data': [{'url': 'https://ark-content-generation-v2-ap-southeast-1.tos-ap-southeast-1.volces.com/seedream-3-0-t2i/02175161671039622600af416b2ca58c9c8a1e1bf93fac0335693.jpeg?X-Tos-Algorithm=TOS4-HMAC-SHA256&X-Tos-Credential=AKLTYjg3ZjNlOGM0YzQyNGE1MmI2MDFiOTM3Y2IwMTY3OTE%2F20250704%2Fap-southeast-1%2Ftos%2Frequest&X-Tos-Date=20250704T081151Z&X-Tos-Expires=86400&X-Tos-Signature=76ad6d2e0eb218521b9ce0bfdc98eaf2aa683e9a0d3840624fb4d413a1fd360e&X-Tos-SignedHeaders=host&x-tos-process=image%2Fwatermark%2Cimage_YXNzZXRzL3dhdGVybWFyay5wbmc_eC10b3MtcHJvY2Vzcz1pbWFnZS9yZXNpemUsUF81'}]}
import requests
import json   # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "prompt": "Racoon eating ice-cream",
            "model": "google/imagen-4.0-fast-generate-001",
            "aspect_ratio": "16:9"
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'google/imagen-4.0-fast-generate-001',
      prompt: 'Racoon eating ice-cream',
      aspect_ratio: '16:9'
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  "data": [
    {
      "mime_type": "image/png",
      "url": "https://cdn.aimlapi.com/generations/guepard/1758236595733-514db8bc-7cba-4d7b-8d6b-237c20375995.png",
      "prompt": "A raccoon, with a mischievous grin, holds a melting cone of mint chocolate chip ice cream in its front paws, enjoying a warm summer day in a picturesque park. The sunlight creates a gentle, golden glow around the raccoon, illuminating the soft, fluffy fur. The cone is dripping with ice cream, creating a scene of playful chaos. A detailed, high-quality photo with a shallow depth of field, blurring the background foliage, creating a soft and dreamy aesthetic. The vibrant green trees and lush grass provide a beautiful and tranquil setting for the raccoon's treat."
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 42000
    }
  }
}
import requests
import json   # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "prompt": "Racoon eating ice-cream",
            "model": "google/imagen-4.0-generate-001",
            "aspect_ratio": "16:9"
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'google/imagen-4.0-generate-001',
      prompt: 'Racoon eating ice-cream',
      aspect_ratio: '16:9'
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  "data": [
    {
      "mime_type": "image/png",
      "url": "https://cdn.aimlapi.com/generations/guepard/1758236160134-5fcac25f-0c87-4145-b24b-98ccebab5c0c.png",
      "prompt": "A mischievous racoon, with beady eyes and a striped tail, is caught mid-lick, enjoying a stolen ice cream cone. Its small paws cradle the melting treat, and its face is smeared with the creamy sweetness, indicating a thorough and enthusiastic indulgence. The scene is set in a cluttered alleyway, with discarded boxes and old bricks forming a backdrop to the racoon's illicit feast."
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 84000
    }
  }
}
import requests
import json   # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "prompt": "Racoon eating ice-cream",
            "model": "google/imagen4/preview",
            "aspect_ratio": "16:9"
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'google/imagen4/preview',
      prompt: 'Racoon eating ice-cream',
      aspect_ratio: '16:9'
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  images: [
    {
      url: 'https://cdn.aimlapi.com/eagle/files/panda/tI_UTxAzqLqWZZqSoNqsO_output.png',
      content_type: 'image/png',
      file_name: 'output.png',
      file_size: 1665805
    }
  ],
  seed: 3360388064
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "bytedance/seededit-3.0-i2i",
            "image": "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
            "prompt": "Add a bird to the foreground of the photo.",
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
  method: 'POST',
  headers: {
    // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
    'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'bytedance/seededit-3.0-i2i',
    prompt: 'Add a bird to the foreground of the photo.',
    image: 'https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png',        
  }),
});

const data = await response.json();
console.log(JSON.stringify(data, null, 2));
{
  "created": 1754408583,
  "data": [
    {
      "url": "https://ark-content-generation-v2-ap-southeast-1.tos-ap-southeast-1.volces.com/seededit-3-0-i2i/0217544085757151f54867e2807e9e62dfa0a3e2d06531a7ce49c.jpeg?X-Tos-Algorithm=TOS4-HMAC-SHA256&X-Tos-Credential=AKLTYWJkZTExNjA1ZDUyNDc3YzhjNTM5OGIyNjBhNDcyOTQ%2F20250805%2Fap-southeast-1%2Ftos%2Frequest&X-Tos-Date=20250805T154303Z&X-Tos-Expires=86400&X-Tos-Signature=e37babdb426ccd6e36f96a019145af3ea8a6e5cb21f3761d8aa3eae32b24d738&X-Tos-SignedHeaders=host"
    }
  ]
}
import requests
import json

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
          "model": "topaz-labs/sharpen",
          "image_url": "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blurred-landscape.png",
          "mode": "Strong",
          "strength": 0.9,
          "minor_denoise": 0.9,
          "output_format": "png",
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
    const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
      method: 'POST',
      headers: {
        // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
        'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        model: 'topaz-labs/sharpen',
        image_url: 'https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blurred-landscape.png',
        mode: 'Strong',
        strength: 0.9,
        minor_denoise: 0.9,
        output_format: 'png',
      }),
    });
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/komodo/output/6435616/ddb723c4-ed16-42f4-8818-9ca4de176ea7.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Checksum-Mode=ENABLED&X-Amz-Credential=ccc352dcd71a436e5fd697125a1be9f8%2F20251027%2Fauto%2Fs3%2Faws4_request&X-Amz-Date=20251027T162246Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&x-id=GetObject&X-Amz-Signature=4f4c449772b258bcf53e7257444698e2e486832e77ab5835728afc4aabfa0f8c"
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 210000
    }
  }
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
            "model": "flux/kontext-pro/text-to-image",
            "aspect_ratio": "21:9"   
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux/kontext-pro/text-to-image',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
      aspect_ratio: '21:9',
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  "images": [
    {
      "url": "https://cdn.aimlapi.com/squirrel/files/koala/6e4yw7_YnA8tEe03QW8wW_5298e11de5a24f1f9cf4f277cbdd3316.jpg",
      "width": 1568,
      "height": 672,
      "content_type": "image/jpeg"
    }
  ],
  "timings": {},
  "seed": 2561481494,
  "has_nsfw_concepts": [
    false
  ],
  "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses."
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
            "model": "flux/kontext-max/text-to-image",
            "aspect_ratio": '21:9'
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux/kontext-max/text-to-image',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
      
      aspect_ratio: '21:9',
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  images: [
    {
      url: 'https://cdn.aimlapi.com/squirrel/files/monkey/zP2cXFuTA4Bd0GbZAAb8y_be6eb84f036744dcbb2e155296b96be1.jpg',
      width: 1568,
      height: 672,
      content_type: 'image/jpeg'
    }
  ],
  timings: {},
  seed: 1617845674,
  has_nsfw_concepts: [ false ],
  prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.'
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "prompt": "Racoon eating ice-cream",
            "model": "imagen-3.0-generate-002",
            "convert_base64_to_url": True,
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'imagen-3.0-generate-002',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
      convert_base64_to_url: true
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  data: [
    {
      mime_type: 'image/png',
      url: 'https://cdn.aimlapi.com/generations/guepard/1756970940506-11b77754-ca2a-4995-a260-d75adfb9885c.png',
      prompt: 'A playful raccoon with a mischievous grin is indulging in a scoop of creamy, strawberry ice cream. Its black mask and fluffy tail are prominent features as it delicately licks the cool treat with its pink tongue. The raccoon is perched on a park bench, the soft daylight illuminating its fur and the vibrant color of the ice cream. The background is a slightly blurred, idyllic summer scene with a few scattered trees and a lush green lawn. The overall image captures a moment of unexpected delight, with the raccoon enjoying a sweet summer treat in a natural and relaxing setting. This picture captures the charming side of this often misunderstood animal, showcasing its playful curiosity and enjoyment of simple pleasures. The image has a soft, nostalgic quality, using natural light and a shallow depth of field to focus on the raccoon and its ice-cream.'
    }
  ]
}
import requests
import json

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "google/nano-banana-pro",
            "prompt": "Racoon eating ice-cream",
            "aspect_ratio": "1:1",
            "resolution": "1K"
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'google/nano-banana-pro',
      prompt: 'Racoon eating ice-cream',
      aspect_ratio: '1:1',
      resolution: '1K'
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  "description": "",
  "data": [
    {
      "url": "https://cdn.aimlapi.com/flamingo/files/b/monkey/rvEPfEJe--7Nf41TwCGy3.png",
      "content_type": "image/png",
      "width": null,
      "height": null,
      "file_name": "rvEPfEJe--7Nf41TwCGy3.png"
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 315000
    }
  }
}
import requests
import json

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
            "model": "dall-e-3",
            "quality": "hd"
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'dall-e-3',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
      quality: 'hd',
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  created: 1756973055,
  data: [
    {
      revised_prompt: 'A massive T-Rex is taking a well-deserved vacation at a tranquil beach. The charismatic dinosaur lies leisurely on a large, comfortable sun lounger. Its tiny, clawed hands hold a pair of fashionable sunglasses in place over its sharp, menacing eyes, adding an air of humor to the otherwise intimidating figure. The soothing sound of the waves and the gentle warmth of the sun create a calming atmosphere around the chilling predator, lending the scene an amusing contradiction.',
      url: 'https://oaidalleapiprodscus.blob.core.windows.net/private/org-5drZvxmo1TGoMx2jeKKGAGSh/user-eKr1xiaNRxSYqgKrXfgZzSAJ/img-B7BCSmDWQgWlGA2vu24HSzqS.png?st=2025-09-04T07%3A04%3A15Z&se=2025-09-04T09%3A04%3A15Z&sp=r&sv=2024-08-04&sr=b&rscd=inline&rsct=image/png&skoid=38e27a3b-6174-4d3e-90ac-d7d9ad49543f&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2025-09-04T02%3A45%3A18Z&ske=2025-09-05T02%3A45%3A18Z&sks=b&skv=2024-08-04&sig=fGRfHnpFybyg6wwJw7PYXJKM1AF1NWwD/W5qPKIha7U%3D'
    }
  ]
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json"
        },
        json={
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
            "model": "blackforestlabs/flux-2",
            "image_size": {
                "width": 1472,
                "height": 512 
            }
        }
    )
    
    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__": 
    main()   
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'blackforestlabs/flux-2',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
      image_size: {
        width: 1472,
        height: 512
      },
    }),
  });

  const data = await response.json();
  console.log('Generation:', data);
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/flamingo/files/b/0a84799e/1kYzoFE6V9Jx2Rfmmn_4M.png"
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 25200
    }
  }
}
import requests
import json

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "hunyuan/hunyuan-image-v3-text-to-image",
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
            "image_size": "landscape_16_9"
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'hunyuan/hunyuan-image-v3-text-to-image',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses. Realistic photo.',
      image_size: 'landscape_16_9'
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
    "data": [
        {
            "url": "https://v3b.fal.media/files/b/lion/JdrvNguTlt29LmURRbKKN.png",
            "content_type": "image/png",
            "file_name": null,
            "file_size": null,
            "width": 1280,
            "height": 768
        }
    ],
    "meta": {
        "usage": {
            "tokens_used": 210000
        }
    }
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json"
        },
        json={
            "model": "reve/create-image",
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
            "aspect_ratio": "16:9"
        }
    )
    
    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__": 
    main()   
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'reve/create-image',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
      aspect_ratio: '16:9'
    }),
  });

  const data = await response.json();
  console.log('Generation:', data);
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/phoenix/1759280291545-6280787e-7e4a-44c9-addf-608314a3cb58.png",
      "b64_json": null,
      "request_id": "rsid-f08b8f47354d688d6de93c400fdaf31c",
      "content_violation": false
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 126000
    }
  }
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "blackforestlabs/flux-2-edit",
            "prompt": "Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.",
            "image_urls": [
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg"
            ],
            "guidance_scale": 19
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'blackforestlabs/flux-2-edit',
      prompt: 'Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.',
      image_urls: [
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg"
            ],
      guidance_scale: 19
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/flamingo/files/b/0a847ab7/KtavVJcI8jz5cN49wXF0e.png"
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 75601
    }
  }
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "bytedance/seedream-v4-text-to-image",
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
            "image_size": {
                "width": 4096,
                "height": 4096
            },
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'bytedance/seedream-3.0',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
      image_size: {
        width: 4096,
        height: 4096
      },
    }),
  });

  const data = await response.json();
  console.log('Generation:', data);
}

main();
{
  "images": [
    {
      "url": "https://v3b.fal.media/files/b/lion/O0byJzpkMBsjWFUMSRelX_ae55fef23aa54a1cad92c3abdf8f5337.png",
      "content_type": "image/png",
      "file_name": "ae55fef23aa54a1cad92c3abdf8f5337.png",
      "file_size": 3282232,
      "width": null,
      "height": null
    }
  ],
  "seed": 1367947822,
  "data": [
    {
      "url": "https://v3b.fal.media/files/b/lion/O0byJzpkMBsjWFUMSRelX_ae55fef23aa54a1cad92c3abdf8f5337.png",
      "content_type": "image/png",
      "file_name": "ae55fef23aa54a1cad92c3abdf8f5337.png",
      "file_size": 3282232,
      "width": null,
      "height": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 63000
    }
  }
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "bytedance/seedream-4-5",
            "prompt": "Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.",
            "image_urls": [
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg"
            ]
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'bytedance/seedream-4-5',
      prompt: 'Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.',
      image_urls: [
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg"
            ]
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/bison/seedream-4-5/02176522545211712014becacfaf8a37949eaec3c8139753caaae_0.jpeg?X-Tos-Algorithm=TOS4-HMAC-SHA256&X-Tos-Credential=AKLTYWJkZTExNjA1ZDUyNDc3YzhjNTM5OGIyNjBhNDcyOTQ%2F20251208%2Fap-southeast-1%2Ftos%2Frequest&X-Tos-Date=20251208T202437Z&X-Tos-Expires=86400&X-Tos-Signature=9be05c928d39a74abc5c06bff5759a28449256d72f1d062933479f279bc672cb&X-Tos-SignedHeaders=host",
      "size": "2048x2048"
    }
  ],
  "meta": {
    "usage": {
      "credits_used": 84000
    }
  }
}
import requests
import json   # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "prompt": "Racoon eating ice-cream",
            "model": "imagen-4.0-ultra-generate-preview-06-06",
            "aspect_ratio": "16:9"
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'imagen-4.0-ultra-generate-preview-06-06',
      prompt: 'Racoon eating ice-cream',
      aspect_ratio: '16:9'
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  data: [
    {
      mime_type: 'image/png',
      url: 'https://cdn.aimlapi.com/generations/guepard/1756971509123-7ed4055c-1878-47c5-a060-7202392b78a2.png',
      prompt: "A curious raccoon is sitting upright on a weathered wooden picnic table, intensely focused on eating a melting ice cream cone. The raccoon holds the cone delicately in its paws, with sticky ice cream smeared around its mouth and on its fur. The ice cream is a vibrant strawberry pink color, dripping down the cone onto the table surface. Its mask-like facial markings are prominent, and its dark eyes are wide with concentration. The setting is a lush green park during golden hour, with soft, warm sunlight filtering through the background trees, creating a gentle bokeh effect. Empty picnic benches are visible in the soft-focus background. The wooden table is slightly worn, with visible grain and a few scattered leaves. The lighting is natural and warm, highlighting the raccoon's fur and the glistening ice cream."
    }
  ]
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "blackforestlabs/flux-2-lora-edit",
            "prompt": "Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.",
            "image_urls": [
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg"
            ],
            "guidance_scale": 19
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'blackforestlabs/flux-2-lora-edit',
      prompt: 'Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.',
      image_urls: [
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg"
            ],
      guidance_scale: 19
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/flamingo/files/b/0a847b4c/2-TzrE2bwvfldwD4O3aVi.png"
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 132300
    }
  }
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "flux/srpo/image-to-image",
            "prompt": "Add a bird to the foreground of the photo.",
            "image_url": "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
            "strength": 0.9
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux/srpo/image-to-image',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
      image_url: 'https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png',
      strength: 0.9,
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  "images": [
    {
      "url": "https://v3b.fal.media/files/b/koala/1TOtgew8As_QBlCyKy4Z-.jpg",
      "width": 1024,
      "height": 768,
      "content_type": "image/jpeg"
    }
  ],
  "timings": {
    "inference": 0.947831045370549
  },
  "seed": 484902001,
  "has_nsfw_concepts": [
    false
  ],
  "prompt": "Add a bird to the foreground of the photo.",
  "data": [
    {
      "url": "https://v3b.fal.media/files/b/koala/1TOtgew8As_QBlCyKy4Z-.jpg",
      "width": 1024,
      "height": 768,
      "content_type": "image/jpeg"
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 52500
    }
  }
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
            "model": "flux-pro/v1.1-ultra",
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux-pro/v1.1-ultra',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(data);
}

main()
{
  images: [
    {
      url: 'https://cdn.aimlapi.com/squirrel/files/koala/xt87Jiwy69wpF4jGEFKbZ_806ed881d147466d81af027c6779cbc5.jpg',
      width: 2752,
      height: 1536,
      content_type: 'image/jpeg'
    }
  ],
  timings: {},
  seed: 526588311,
  has_nsfw_concepts: [ false ],
  prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.'
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "flux/schnell",
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux/schnell',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
Generation: {'images': [{'url': 'https://cdn.aimlapi.com/eagle/files/lion/dSqd5BMP3pfaiKEnFXiiE.png', 'width': 1440, 'height': 512, 'content_type': 'image/png'}], 'timings': {'inference': 0.3458922009449452}, 'seed': 454423425, 'has_nsfw_concepts': [False], 'prompt': 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.'}
import requests
import json  # for getting a structured output with indentation

response = requests.post(
    "https://api.aimlapi.com/v1/images/generations",
    headers={
        # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
        "Authorization":"Bearer <YOUR_AIMLAPI_KEY>",
        "Content-Type":"application/json",
    },
    json={
        "model":"bytedance/uso",
        "prompt": "The T-Rex is wearing a business suit, sitting in a cozy small café, drinking from a mug. Blur the background slightly to create a bokeh effect.",
        "image_urls": [ 
             "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png"
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
  method: 'POST',
  headers: {
    // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
    'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'bytedance/uso',
    prompt: 'The T-Rex is wearing a business suit, sitting in a cozy small café, drinking from a mug. Blur the background slightly to create a bokeh effect.',
    image_urls: [
      'https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png'
    ],        
  }),
});

const data = await response.json();
console.log(JSON.stringify(data, null, 2));
{
  "images": [
    {
      "url": "https://cdn.aimlapi.com/eagle/files/penguin/sMMWnB7wyBK8o_XiAohle.png",
      "content_type": "image/png",
      "file_name": null,
      "file_size": null,
      "width": 1024,
      "height": 1024
    }
  ],
  "seed": 351168504,
  "has_nsfw_concepts": [
    false
  ],
  "prompt": "The T-Rex is wearing a business suit, sitting in a cozy small café, drinking from a mug. Blur the background slightly to create a bokeh effect.",
  "timings": {
    "inference": 10.547778039996047
  },
  "data": [
    {
      "url": "https://cdn.aimlapi.com/eagle/files/penguin/sMMWnB7wyBK8o_XiAohle.png",
      "content_type": "image/png",
      "file_name": null,
      "file_size": null,
      "width": 1024,
      "height": 1024
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 420000
    }
  }
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "reve/remix-edit-image",
            "prompt": "Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.",
            "image_urls": [
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg"
            ]
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'reve/remix-edit-image',
      prompt: 'Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.',
      image_urls: [
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg"
            ]
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/phoenix/1759284458418-4d0b832c-3f40-47e3-84bd-f56ca78c3b0e.png",
      "b64_json": null,
      "request_id": "rsid-17c1ade740057a36b9711c72bbf4d63f",
      "content_violation": false
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 210000
    }
  }
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "reve/edit-image",
            "prompt": "Make the dinosaur sit on a lounge chair with its back to the camera, looking toward the water. The setting sun has almost disappeared below the horizon.",
            "image_url": "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png"
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'reve/edit-image',
      prompt: 'Make the dinosaur sit on a lounge chair with its back to the camera, looking toward the water. The setting sun has almost disappeared below the horizon.',
      image_url: 'https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png'
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/phoenix/1759282497910-293a844d-2f8c-4513-85e8-c80dec720892.png",
      "b64_json": null,
      "request_id": "rsid-4af47c2ebb2e31f34dce88cb35873bab",
      "content_violation": false
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 210000
    }
  }
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "blackforestlabs/flux-2-pro-edit",
            "prompt": "Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.",
            "image_urls": [
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg"
            ],
            "guidance_scale": 19
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'blackforestlabs/flux-2-pro-edit',
      prompt: 'Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.',
      image_urls: [
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg"
            ],
      guidance_scale: 19
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/flamingo/files/b/0a847bef/yW2QPKFJueCjSc-o-JpXk.png"
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 189000
    }
  }
}
flux/schnell
flux/dev
flux/dev/image-to-image
flux/kontext-max/text-to-image
flux/kontext-max/image-to-image
flux/kontext-pro/text-to-image
flux/kontext-pro/image-to-image

3:2

1248×832

84 000

3:4

864×1184

84 000

4:3

1184×864

84 000

4:5

896×1152

84 000

5:4

1152×896

84 000

9:16

768×1344

84 000

16:9

1344×768

84 000

21:9

1536×672

84 000

1:1

1024×1024

84 000

2:3

832×1248

84 000

Image #1
"Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect."
Image #2

Quickstart guide

Try in Playground

Model Overview

A model built for photorealistic image generation and precise text rendering, suited for high-fidelity professional use.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate an image of the specified aspect ratio using a simple prompt.

Response

So we obtained the following 1408x768 image by running this code example:

In reality, raccoons shouldn’t be given ice cream or chocolate—it’s harmful to their metabolism. But in the AI world, raccoons party like there’s no tomorrow.
Try in Playground
Quickstart guide
"A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses."
"A highly detailed T-Rex relaxing on a sunny beach, lying on a wooden sun lounger and wearing stylish sunglasses. Its skin is covered in realistic, finely textured scales with natural color variations — rough and weathered like that of large reptiles. Sunlight reflects subtly off the individual scales. The background includes palm trees, gentle waves, and soft sand partially covering the T-Rex's feet. The scene is rendered with cinematic lighting and a natural color palette." "num_inference_steps": 40
"Racoon eating ice-cream"
"A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses. Vector illustration style. Top-down view, with visible palm trees, seagulls, and a strip of water." "num_inference_steps": 40
Try in Playground
Quickstart guide
In reality, raccoons shouldn’t be given ice cream or chocolate—it’s harmful to their metabolism. But in the AI world, raccoons party like there’s no tomorrow.
(original)
"Add a bird to the foreground of the photo."
Try in Playground
Quickstart guide
Try in Playground
Quickstart guide
"A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses."
"mode": "Super Focus V2" "strength": 0.6

Quickstart guide
(original)
"Add a bird to the foreground of the photo."
"Add a crown to the T-rex's head."
"Add a couple of silver wings"
"Remove the dinosaur. Place a book and a bouquet of wildflowers in blue and pink tones on the lounge chair. Let a light foamy surf gently wash the bottom of the chair. Don't change anything else."
"Make the dinosaur sit on a lounge chair with its back to the camera, looking toward the water. The setting sun has almost disappeared below the horizon."
"mode": "Strong" "strength": 0.9

flux/kontext-max/image-to-image

This documentation is valid for the following list of our models:

  • flux/kontext-max/image-to-image

Model Overview

An image-to-image model that modifies only what the prompt instructs, leaving the rest of the image untouched.

Model
Properties of Generated Images

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate a new image using the one from the as a reference — and make a simple change to it with a prompt.

Response
Reference Image
Generated Image
More generated images

Example #2: Combine two images

This time, we’ll pass two images to the model: our dinosaur and a solid blue mug. We'll ask the model to place the dinosaur onto the mug as a print.

Our input images
Response

flux/kontext-pro/image-to-image

This documentation is valid for the following list of our models:

  • flux/kontext-pro/image-to-image

import requests
import json

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "google/gemini-2.5-flash-image-edit",
            "image_urls": [
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg"
            ],
            "prompt": "Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.",
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
    const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
      method: 'POST',
      headers: {
        // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
        'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        model: 'google/gemini-2.5-flash-image-edit',
        image_urls: [
                'https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png',
                'https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg'
        ],
        prompt: 'Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.',
      }),
    });
}

main();
{
  "images": [
    {
      "url": "https://cdn.aimlapi.com/eagle/files/panda/9g3PokYLjWoygTVrRgfvG_output.png",
      "content_type": "image/png",
      "file_name": "output.png",
      "file_size": 2273159,
      "width": null,
      "height": null
    }
  ],
  "description": "Here is your T-Rex in a business suit, enjoying a drink in a cozy cafe! "
}
import requests
import json   # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "prompt": "Racoon eating ice-cream",
            "model": "google/imagen-4.0-ultra-generate-001",
            "aspect_ratio": "16:9"
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'google/imagen-4.0-ultra-generate-001',
      prompt: 'Racoon eating ice-cream',
      aspect_ratio: '16:9'
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  "data": [
    {
      "mime_type": "image/png",
      "url": "https://cdn.aimlapi.com/generations/guepard/1758237214798-b22381b0-cc4c-466c-92f4-c3b2531d7ebf.png",
      "prompt": "A curious raccoon sitting upright on a park bench, intently focused on licking a melting scoop of vanilla ice cream in a waffle cone. The raccoon has its small paws wrapped around the cone, and a tiny bit of ice cream is smeared on its nose and whiskers. The fur is ruffled and slightly damp from the treat. The park setting is sunny with dappled light filtering through the leaves of a large oak tree in the background. Autumn leaves are scattered on the ground near the bench. The ice cream is dripping slightly down the cone, and a small puddle is forming on the wooden bench. The image is captured at eye level with the raccoon."
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 126000
    }
  }
}
import requests
import json

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
            "model": "stable-diffusion-v35-large",
            "image_size": "landscape_16_9"
            "num_inference_steps": 40,
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'stable-diffusion-v35-large',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses. Realistic photo.',
      image_size: 'landscape_16_9',
      num_inference_steps: 40,
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  images: [
    {
      url: 'https://cdn.aimlapi.com/eagle/files/elephant/4vP0cAmlTNsadiYaMFE30.jpeg',
      width: 1024,
      height: 576,
      content_type: 'image/jpeg'
    }
  ],
  timings: { inference: 4.855678029009141 },
  seed: 6199662706750842000,
  has_nsfw_concepts: [ false ],
  prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.'
}
import requests
import json

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "google/gemini-2.5-flash-image",
            "prompt": "Racoon eating ice-cream"
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'google/gemini-2.5-flash-image',
      prompt: 'Racoon eating ice-cream',
      aspect_ratio: '16:9'
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  images: [
    {
      url: 'https://cdn.aimlapi.com/eagle/files/zebra/VVpZmbuvMBg3k7OqJ8UnP.jpeg',
      content_type: 'image/jpeg',
      file_name: 'output.jpeg',
      file_size: null
    }
  ],
  description: "Sounds adorable! Here's a racoon enjoying some ice cream: "
}
import requests
import json  # for getting a structured output with indentation

response = requests.post(
    "https://api.aimlapi.com/v1/images/generations",
    headers={
        # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
        "Authorization":"Bearer <YOUR_AIMLAPI_KEY>",
        "Content-Type":"application/json",
    },
    json={
        "model":"bytedance/seedream-v4-edit",
        "prompt": "Add a bird to the foreground of the photo.",
        "image_urls": [ 
             "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png"
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
  method: 'POST',
  headers: {
    // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
    'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'bytedance/seedream-v4-edit',
    prompt: 'Add a bird to the foreground of the photo.',
    image_urls: [
      'https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png'
    ],        
  }),
});

const data = await response.json();
console.log(JSON.stringify(data, null, 2));
{
  "images": [
    {
      "url": "https://v3b.fal.media/files/b/kangaroo/nHWHZmeMr-SL4R7uFtvq7_d54b8823cf784f67bcfa43993bdb2179.png",
      "content_type": "image/png",
      "file_name": "d54b8823cf784f67bcfa43993bdb2179.png",
      "file_size": 1033237,
      "width": null,
      "height": null
    }
  ],
  "seed": 623004765,
  "data": [
    {
      "url": "https://v3b.fal.media/files/b/kangaroo/nHWHZmeMr-SL4R7uFtvq7_d54b8823cf784f67bcfa43993bdb2179.png",
      "content_type": "image/png",
      "file_name": "d54b8823cf784f67bcfa43993bdb2179.png",
      "file_size": 1033237,
      "width": null,
      "height": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 63000
    }
  }
}
import requests
import json

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
            "model": "stable-diffusion-v3-medium",
            "image_size": "landscape_16_9"
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'stable-diffusion-v3-medium',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses. Realistic photo.',
      image_size: 'landscape_16_9'
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  images: [
    {
      url: 'https://cdn.aimlapi.com/squirrel/files/monkey/pAs554_StzWBkrLMgTH5a.png',
      width: 1024,
      height: 576,
      content_type: 'image/jpeg'
    }
  ],
  timings: { inference: 1.1477893170085736 },
  seed: 3544609846964942300,
  has_nsfw_concepts: [ false ],
  prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses. Realistic photo.',
  num_images: 1
}
import requests
import json

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
          "model": "topaz-labs/sharpen",
          "image_url": "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blurred-landscape.png",
          "mode": "Super Focus V2",
          "strength": 0.6,
          "output_format": "jpeg",
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
    const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
      method: 'POST',
      headers: {
        // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
        'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        model: 'topaz-labs/sharpen',
        image_url: 'https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blurred-landscape.png',
        mode: 'Super Focus V2',
        strength: 0.6,
        output_format: 'jpeg',
      }),
    });
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/komodo/output/6435616/5cff080e-5d24-4fc3-85f5-0e57621ead7d.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Checksum-Mode=ENABLED&X-Amz-Credential=ccc352dcd71a436e5fd697125a1be9f8%2F20251027%2Fauto%2Fs3%2Faws4_request&X-Amz-Date=20251027T202819Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&x-id=GetObject&X-Amz-Signature=d6d1d9c641c33bde33b14090d579d490d30f75e82283764705acd28b18765a70"
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 210000
    }
  }
}

Try in Playground

Model Overview

An image-to-image model that modifies only what the prompt instructs, leaving the rest of the image untouched.

Model
Properties of Generated Images

flux/kontext-pro/image-to-image

Format: JPEG, PNG Image size can't be set directly — only a preset aspect ratio can be chosen. Default aspect ratio and size: 16:9, 1184x880 (well, not quite 16:9)

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schema

Quick Example

Let's generate a new image using the one from the flux/dev Quick Example as a reference — and make a simple change to it with a prompt.

Response
Reference Image
Generated Image
More generated images

Example #2: Combine two images

This time, we’ll pass two images to the model: our dinosaur and a solid blue mug. We'll ask the model to place the dinosaur onto the mug as a print.

Our input images
Response
"Place this image with the t-rex on this mug from the second image as a print. Make it look fit and natural."

flux/kontext-max/image-to-image

Format: JPEG, PNG Image size can't be set directly — only a preset aspect ratio can be chosen. Default aspect ratio and size: 16:9, 1184x880 (well, not quite 16:9)

"Add a crown to the T-rex's head."
"Add a couple of silver wings"
"Remove the dinosaur. Place a book and a bouquet of wildflowers in blue and pink tones on the lounge chair. Let a light foamy surf gently wash the bottom of the chair. Don't change anything else."
"Make the dinosaur sit on a lounge chair with its back to the camera, looking toward the water. The setting sun has almost disappeared below the horizon."
Our chilling T-rex
Our blue mug
Try in Playground
Quickstart guide
flux/dev Quick Example
"Place this image with the t-rex on this mug from the second image as a print. Make it look fit and natural."

gpt-image-1

This documentation is valid for the following list of our models:

  • openai/gpt-image-1

Model Overview

A powerful multimodal model capable of generating new images, combining existing ones, and applying image masks — all guided by a text prompt.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schemas

Note that by default, the quality parameter is set to 'medium'. The output image will still look great, but for even more detailed results, consider setting this parameter to 'high'.

Generate image

Edit image

Unfortunately, this model only accepts local files specified by their file paths. It does not support image input via URLs or base64 encoding.

Quick Examples

Generate image

Let's generate an image of the specified size using a simple prompt.

Response

We obtained the following 1536x1024 image by running this code example (~ 26 s):

More images

Edit image: Combine images

Let's generate an image using two input images and a prompt that defines how they should be edited.

Our input images
Response

We obtained the following 1024x1024 image by running this code example (~ 34 s):

Edit image: Use an image mask

In this example, we’ll provide the model with our previously generated image of a T-rex on a beach, along with a same-sized mask where the area occupied by the dinosaur is transparent (alpha = 0). In the prompt, we’ll ask the model to remove the masked object from the image and see how well it handles the task.

Image & Mask
Response

We obtained the following 1024x1024 image by running this code example (~ 32 s).

post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

output_formatstring · enumOptional

The format of the generated image.

Default: jpegPossible values:
image_sizeany ofOptionalDefault: landscape_4_3
or
string · enumOptional

The size of the generated image.

Possible values:
num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
guidance_scalenumber · min: 1 · max: 20Optional

The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you.

negative_promptstringOptional

The description of elements to avoid in the generated image.

Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

image_sizeany ofOptionalDefault: landscape_4_3
or
string · enumOptional

The size of the generated image.

Possible values:
output_formatstring · enumOptional

The format of the generated image.

Default: pngPossible values:
enable_prompt_expansionbooleanOptional

If set to True, prompt will be upsampled with more details.

Default: true
num_inference_stepsinteger · min: 1 · max: 8Optional

The number of inference steps to perform.

seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
accelerationstring · enumOptional

The speed of the generation. The higher the speed, the faster the generation.

Default: regularPossible values:
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 800Required

The text prompt describing the content, style, or composition of the image to be generated.

imagestringRequired

The image to be edited. Enter the Base64 encoding of the picture or an accessible URL. Image URL: Make sure that the image URL is accessible. Base64-encoded content: The format must be in lowercase.

negative_promptstring · max: 500Optional

The description of elements to avoid in the generated image.

watermarkbooleanOptional

Add an invisible watermark to the generated images.

Default: false
import requests
import json  # for getting a structured output with indentation 

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "flux/kontext-pro/image-to-image",
            "image_url": "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",  # URL of the reference picture
            "prompt": "Add a bird to the foreground of the photo.",
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
  method: 'POST',
  headers: {
    // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
    'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'flux/kontext-pro/image-to-image',
    prompt: 'Add a bird to the foreground of the photo.',
    image_url: 'https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png',        
  }),
});

const data = await response.json();
console.log(JSON.stringify(data, null, 2));
{
  "images": [
    {
      "url": "https://cdn.aimlapi.com/squirrel/files/panda/qMuknweKekEYlj9-RdUNt_f0706e451d674554a4c03f2489cf7d5a.jpg",
      "content_type": "image/jpeg",
      "file_name": null,
      "file_size": null,
      "width": 1184,
      "height": 880
    }
  ],
  "timings": {},
  "seed": 3959063143,
  "has_nsfw_concepts": [
    false
  ],
  "prompt": "Add a bird to the foreground of the photo."
}
import requests
import json  # for getting a structured output with indentation

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "prompt": "Place this image with the t-rex on this mug from the second image as a print. Make it look fit and natural.",
            "model": "flux/kontext-pro/image-to-image",
            "image_url": [     # URLs of two reference pictures
                "https://zovi0.github.io/public_misc/flux-dev-t-rex.png", 
                "https://zovi0.github.io/public_misc/blue-mug.jpg"
            ]
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))


if __name__ == "__main__":
    main()
const main = async () => {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      Authorization: 'Bearer <YOUR_API_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux/kontext-pro/text-to-image',
      prompt: 'Place this image with the t-rex on this mug from the second image as a print. Make it look fit and natural.',
      image_url: [     // URLs of two reference pictures
        'https://zovi0.github.io/public_misc/flux-dev-t-rex.png', 
        'https://zovi0.github.io/public_misc/blue-mug.jpg'
      ],
    }),
  }).then((res) => res.json());

  console.log(response);
};

main();
{
  "images": [
    {
      "url": "https://cdn.aimlapi.com/squirrel/files/lion/rXRknU80d-8ywPnLBq4G8_59b65fe44d8046a38ab9e524a5a8b61c.jpg",
      "width": 1184,
      "height": 880,
      "content_type": "image/jpeg"
    }
  ],
  "timings": {},
  "seed": 1068148133,
  "has_nsfw_concepts": [
    false
  ],
  "prompt": "Place this image with the t-rex on this mug from the second image as a print. Make it look fit and natural."
}
import requests
import json  # for getting a structured output with indentation 

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "flux/kontext-max/image-to-image",
            "image_url": "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",  # URL of the reference picture
            "prompt": "Add a bird to the foreground of the photo.",
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
  method: 'POST',
  headers: {
    // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
    'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'flux/kontext-max/image-to-image',
    prompt: 'Add a bird to the foreground of the photo.',
    image_url: 'https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png',        
  }),
});

const data = await response.json();
console.log(JSON.stringify(data, null, 2));
{
  "images": [
    {
      "url": "https://cdn.aimlapi.com/squirrel/files/rabbit/4LZOccB3ChjGNDi3G8zTK_202357995b8642f5b7c73925cc388b3d.jpg",
      "content_type": "image/jpeg",
      "file_name": null,
      "file_size": null,
      "width": 1184,
      "height": 880
    }
  ],
  "timings": {},
  "seed": 1415518620,
  "has_nsfw_concepts": [
    false
  ],
  "prompt": "Add a bird to the foreground of the photo."
}
import requests
import json  # for getting a structured output with indentation

# URLs of two reference pictures
images = ["https://zovi0.github.io/public_misc/flux-dev-t-rex.png", "https://zovi0.github.io/public_misc/blue-mug.jpg"]

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "prompt": "Place this image with the t-rex on this mug from the second image as a print. Make it look fit and natural.",
            "model": "flux/kontext-max/image-to-image",
            "image_url": images 
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))


if __name__ == "__main__":
    main()
const main = async () => {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      Authorization: 'Bearer <YOUR_API_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux/kontext-max/text-to-image',
      prompt: 'Place this image with the t-rex on this mug from the second image as a print. Make it look fit and natural.',
      image_url: ['https://zovi0.github.io/public_misc/flux-dev-t-rex.png', 'https://zovi0.github.io/public_misc/blue-mug.jpg'],
    }),
  }).then((res) => res.json());

  console.log(response);
};

main();
{
  "images": [
    {
      "url": "https://cdn.aimlapi.com/squirrel/files/zebra/DIXc328YCO52TIo5WEhXM_560d09b975e34c1498ebba71bf0e4eb6.jpg",
      "width": 1184,
      "height": 880,
      "content_type": "image/jpeg"
    }
  ],
  "timings": {},
  "seed": 2103864242,
  "has_nsfw_concepts": [
    false
  ],
  "prompt": "Place this image with the t-rex on this mug from the second image as a print. Make it look fit and natural."
}
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

image_sizeany ofOptionalDefault: landscape_4_3
or
string · enumOptional

The size of the generated image.

Possible values:
output_formatstring · enumOptional

The format of the generated image.

Default: pngPossible values:
enable_prompt_expansionbooleanOptional

If set to True, prompt will be upsampled with more details.

Default: true
num_inference_stepsinteger · min: 1 · max: 8Optional

The number of inference steps to perform.

seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
accelerationstring · enumOptional

The speed of the generation. The higher the speed, the faster the generation.

Default: regularPossible values:
Responses
200Success
application/json
post
/v1/images/generations
200Success
Responses
200Success
application/json
post
/v1/images/generations
200Success
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'alibaba/z-image-turbo-lora',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      "model": "alibaba/qwen-image-edit",
      "prompt": "Add a crown to the T-rex's head.",
      "image": "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png"
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'alibaba/qwen-image',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'alibaba/z-image-turbo',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
t-rex.png
crown.png
Image
Mask
Try in Playground
Quickstart guide
"A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses. Realistic photo."
"A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses."
"Racoon eating ice-cream"
A true king of the monsters. On vacation.
Our dinosaur has disappeared into thin air!
"Add a crown to the T-rex's head."
"Add a couple of silver wings"
"Remove the dinosaur. Place a book and a bouquet of wildflowers in blue and pink tones on the lounge chair. Let a light foamy surf gently wash the bottom of the chair. Don't change anything else."
"Make the dinosaur sit on a lounge chair with its back to the camera, looking toward the water. The setting sun has almost disappeared below the horizon."
Our chilling T-rex
Our blue mug

Image Models

A description of image generation process using AIML API image models.

Overview

Our API features the capability to generate images. We support various models for image generation, including both open-source and proprietary options.

We support multiple image models. You can find the complete list along with API reference links at the end of the page.

How to Generate an Image

Select a model

First, decide which model you want to use. Models can be trained for specific tasks (e.g., realistic results), offer higher resolutions, or include features like negative prompts. You can read about our supported models and their features on our .

Imagine a prompt

Next, construct a prompt for the image. Depending on your needs, this prompt can include keywords that will shape the image: place, objects, quality, style, and other elements. This prompt is a crucial part of the image generation process and determines what will be displayed in the image.

Configure metaparameters

Then, configure the metaparameters for your generation:

  • Steps: The n parameter in the API controls the number of iterations the model will take to shape your image. Experiment with this parameter to achieve the best result for your prompt.

  • Size: The size parameter controls the resolution of the resulting image. All models have minimum and maximum resolutions, sometimes with different aspect ratios. Experiment with this parameter as well.

Quick Code Example

Here is an example of generation an image of a robot classroom using the flux-pro image model:

We obtained the following image by running that code example:

All Available Image Models

Model ID + API Reference link
Developer
Context
Model Card
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

image_sizeany ofOptionalDefault: landscape_4_3
or
string · enumOptional

The size of the generated image.

Possible values:
guidance_scalenumber · min: 1 · max: 20Optional

The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you.

num_inference_stepsinteger · min: 1 · max: 50Optional

The number of inference steps to perform.

enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
output_formatstring · enumOptional

The format of the generated image.

Default: jpegPossible values:
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

image_sizeany ofOptionalDefault: landscape_4_3
or
string · enumOptional

The size of the generated image.

Possible values:
num_inference_stepsinteger · min: 1 · max: 50Optional

The number of inference steps to perform.

Default: 28
guidance_scalenumber · min: 1 · max: 20Optional

The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you.

Default: 4.5
sync_modebooleanOptional

If set to true, the function will wait for the image to be generated and uploaded before returning the response. This will increase the latency of the function but it allows you to get the image directly in the response without going through the CDN.

Default: false
enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
output_formatstring · enumOptional

The format of the generated image.

Default: jpegPossible values:
accelerationstring · enumOptional

The speed of the generation. The higher the speed, the faster the generation.

Default: regularPossible values:
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
promptstringRequired

The text prompt describing the content, style, or composition of the image to be generated.

nnumber · min: 1 · max: 10Optional

The number of images to generate.

Default: 1
response_formatstring · enumOptional

The format in which the generated images are returned.

Default: urlPossible values:
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

guidance_scalenumber · min: 1 · max: 20Optional

The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you.

num_inference_stepsinteger · min: 1 · max: 50Optional

The number of inference steps to perform.

enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
image_urlstring · uriRequired

The URL of the reference image.

strengthnumberOptional

Determines how much the prompt influences the generated image.

Default: 0.95
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

image_sizeany ofOptionalDefault: landscape_4_3
or
string · enumOptional

The size of the generated image.

Possible values:
output_formatstring · enumOptional

The format of the generated image.

Default: pngPossible values:
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
safety_tolerancestring · enumOptional

The safety tolerance level for the generated image. 1 being the most strict and 5 being the most permissive.

Default: 2Possible values:
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 1000Required

The text prompt describing the content, style, or composition of the image to be generated.

nnumber · min: 1 · max: 10Optional

The number of images to generate.

Default: 1
sizestring · enumOptional

The size of the generated image.

Default: 1024x1024Possible values:
response_formatstring · enumOptional

The format in which the generated images are returned.

Default: urlPossible values:
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
image_sizeany ofOptional

The size of the generated image.

Default: square_hd
string · enumOptionalPossible values:
or
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

sync_modebooleanOptional

If set to true, the function will wait for the image to be generated and uploaded before returning the response. This will increase the latency of the function but it allows you to get the image directly in the response without going through the CDN.

Default: false
enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
post
Body
modelstring · enumRequiredPossible values:
promptstringRequired

The text prompt describing the content, style, or composition of the image to be generated.

image_urlsstring · uri[] · min: 1 · max: 14Optional

List of URLs or local Base64 encoded images to edit.

image_sizeany ofOptional

The size of the generated image.

or
string · enumOptionalPossible values:
response_formatstring · enumOptional

The format in which the generated images are returned.

Default: urlPossible values:
seedintegerOptional

The same seed and the same prompt given to the same version of the model will output the same image every time.

watermarkbooleanOptional

Add an invisible watermark to the generated images.

Default: false
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

image_urlsstring · uri[] · min: 1 · max: 3Required

List of URLs or local Base64 encoded images to edit.

image_sizeany ofOptionalDefault: landscape_4_3
or
string · enumOptional

The size of the generated image.

Possible values:
output_formatstring · enumOptional

The format of the generated image.

Default: pngPossible values:
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
safety_tolerancestring · enumOptional

The safety tolerance level for the generated image. 1 being the most strict and 5 being the most permissive.

Default: 2Possible values:
import requests
import json

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "prompt": "Add a crown",
            "model": "openai/gpt-image-1",
            "size": "1024x1024"
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'openai/gpt-image-1',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses. Realistic photo.',
      size: '1536x1024'
    }),
  });

  const data = await response.json();
  console.log(data);
}

main();
{
  "created": 1749730922,
  "background": "opaque",
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png"
    }
  ],
  "output_format": "png",
  "quality": "medium",
  "size": "1536x1024",
  "usage": {
    "input_tokens": 29,
    "input_tokens_details": {
      "image_tokens": 0,
      "text_tokens": 29
    },
    "output_tokens": 1568,
    "total_tokens": 1597
  }
}
from openai import OpenAI


def main():
    client = OpenAI(
        api_key="<YOUR_AIMLAPI_KEY>",
        base_url="https://api.aimlapi.com/v1",
    )

    result = client.images.edit(
        model="openai/gpt-image-1",
        image=[
            open("t-rex.png", "rb"),
            open("crown.png", "rb"),
        ],
        prompt="Put the crown on the T-rex's head"
    )

    print("Generation:", result)


if __name__ == "__main__":
    main()
import fs from 'fs';
import OpenAI, { toFile } from 'openai';


const main = async () => {
  const client = new OpenAI({
    baseURL: 'https://api.aimlapi.com/v1',
    apiKey: '<YOUR_API_KEY>',
  });

  const imageFiles = ['t-rex.png', 'crown.png'];

  const images = await Promise.all(
    imageFiles.map(
      async (file) =>
        await toFile(fs.createReadStream(file), null, {
          type: 'image/png',
        }),
    ),
  );

  const result = await client.images.edit({
    model: 'openai/gpt-image-1',
    image: images,
    prompt: "Put the crown on the T-rex's head",
  });

  console.log('Generation', result);
};

main();
Generation: ImagesResponse(created=1750278299, data=[Image(b64_json=None, revised_prompt=None, url='https://cdn.aimlapi.com/generations/hedgehog/1750278300281-023df523-e986-431c-bb61-5b9e43301cef.png')], usage=Usage(input_tokens=574, input_tokens_details=UsageInputTokensDetails(image_tokens=517, text_tokens=57), output_tokens=1056, total_tokens=1630), background='opaque', output_format='png', quality='medium', size='1024x1024')
from openai import OpenAI


def main():
    client = OpenAI(
        api_key="<YOUR_AIMLAPI_KEY>",
        base_url="https://api.aimlapi.com/v1",
    )

    result = client.images.edit(
        model="openai/gpt-image-1",
        image=open("t-rex.png", "rb"),
        mask=open('t-rex-alpha_mask.png', 'rb'),
        prompt="Remove this from the picture"
    )

    print("Generation:", result)


if __name__ == "__main__":
    main()
import fs from 'fs';
import OpenAI, { toFile } from 'openai';


const main = async () => {
  const client = new OpenAI({
    baseURL: 'https://api.aimlapi.com/v1',
    apiKey: '<YOUR_AIMLAPI_KEY>',
  });

  const image = await toFile(
    fs.createReadStream('t-rex.png'),
    null,
    {
      type: 'image/png',
    },
  );
  
  const mask = await toFile(
    fs.createReadStream('t-rex-alpha_mask.png'),
    null,
    {
      type: 'image/png',
    },
  );

  const result = await client.images.edit({
    model: 'openai/gpt-image-1',
    image: image,
    mask: mask,
    prompt: 'Remove this from the picture',
  });

  console.log('Generation', result);
};

main();
Generation: ImagesResponse(created=1750275775, data=[Image(b64_json=None, revised_prompt=None, url='https://cdn.aimlapi.com/generations/hedgehog/1750275776080-3fbcf9fc-b8ec-47f1-bb77-4a7e370a3a0c.png')], usage=Usage(input_tokens=360, input_tokens_details=UsageInputTokensDetails(image_tokens=323, text_tokens=37), output_tokens=1056, total_tokens=1416), background='opaque', output_format='png', quality='medium', size='1024x1024')
Responses
200Success
application/json
post
/v1/images/generations
200Success
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'bytedance/seedream-v4-text-to-image',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux-realism',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux/srpo',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'x-ai/grok-2-image',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      "model": "flux/dev/image-to-image",
      "prompt": "Add a crown to the T-rex's head.",
      "image_url": "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png"
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'blackforestlabs/flux-2-pro',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'dall-e-2',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}

Alibaba Cloud

ByteDance

ByteDance

ByteDance

ByteDance

ByteDance

ByteDance

Flux

Flux

Flux

Flux

Flux

Flux

-

Flux

Flux

Flux

Flux

Flux

Flux

Flux

Flux

Flux

Flux

Flux

Flux

Flux

Google

Google

Google

Google

Google

Google

Google

Google

Google

Google

OpenAI

OpenAI

OpenAI

Recraft AI

Reve

Reve

Reve

Stability AI

Stability AI

Tencent

Topaz Labs

Topaz Labs

xAI

alibaba/qwen-image

Alibaba Cloud

Qwen Image

alibaba/qwen-image-edit

Alibaba Cloud

Qwen Image Edit

alibaba/z-image-turbo

Alibaba Cloud

main website
(And AI needs your clothes, your boots and your motorcycle.)

Responses
200Success
application/json
post
/v1/images/generations
200Success
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

image_sizeany ofOptionalDefault: landscape_4_3
or
string · enumOptional

The size of the generated image.

Possible values:
safety_tolerancestring · enumOptional

The safety tolerance level for the generated image. 1 being the most strict and 5 being the most permissive.

Default: 2Possible values:
output_formatstring · enumOptional

The format of the generated image.

Default: jpegPossible values:
enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
image_urlsstring · uri[] · min: 1 · max: 3Required

An array of up to 3 image URLs. The first image is always treated as the primary input for image-to-image generation, while the remaining images (if provided) serve as visual style references for the output.

image_sizeany ofOptional

The size of the generated image.

Default: square_hd
string · enumOptionalPossible values:
or
negative_promptstringOptional

The description of elements to avoid in the generated image.

Default: ""
num_inference_stepsinteger · min: 1 · max: 50Optional

The number of inference steps to perform.

Default: 28
guidance_scalenumber · min: 1 · max: 20Optional

The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you.

Default: 4
keep_sizebooleanOptional
num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

sync_modebooleanOptional

If set to true, the function will wait for the image to be generated and uploaded before returning the response. This will increase the latency of the function but it allows you to get the image directly in the response without going through the CDN.

Default: false
enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
output_formatstring · enumOptional

The format of the generated image.

Default: pngPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

Responses
200Success
application/json
post
/v1/images/generations
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

image_urlsstring · uri[] · min: 1 · max: 3Required

List of URLs or local Base64 encoded images to edit.

image_sizeany ofOptionalDefault: landscape_4_3
or
string · enumOptional

The size of the generated image.

Possible values:
output_formatstring · enumOptional

The format of the generated image.

Default: pngPossible values:
enable_prompt_expansionbooleanOptional

If set to True, prompt will be upsampled with more details.

Default: true
guidance_scalenumber · max: 20Optional

The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you.

num_inference_stepsinteger · min: 4 · max: 50Optional

The number of inference steps to perform.

accelerationstring · enumOptional

The speed of the generation. The higher the speed, the faster the generation.

Default: regularPossible values:
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
Responses
200Success
application/json
post
/v1/images/generations
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

safety_tolerancestring · enumOptional

The safety tolerance level for the generated image. 1 being the most strict and 5 being the most permissive.

Default: 2Possible values:
output_formatstring · enumOptional

The format of the generated image.

Default: jpegPossible values:
enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
aspect_ratiostring · enumOptional

The aspect ratio of the generated image.

Default: 16:9Possible values:
rawboolean · enumOptional

Generate less processed, more natural-looking images.

Default: falsePossible values:
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 400Required

The text prompt describing the content, style, or composition of the image to be generated.

convert_base64_to_urlbooleanOptional

If True, the URL to the image will be returned; otherwise, the file will be provided in base64 format.

Default: true
num_imagesinteger · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · max: 4294967295Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

enhance_promptbooleanOptional

Optional parameter to use an LLM-based prompt rewriting feature for higher-quality images that better match the original prompt. Disabling it may affect image quality and prompt alignment.

Default: true
aspect_ratiostring · enumOptional

The aspect ratio of the generated image.

Default: 1:1Possible values:
person_generationstring · enumOptional

Allow generation of people.

Default: allow_adultPossible values:
safety_settingstring · enumOptional

Adds a filter level to safety filtering.

Default: block_medium_and_abovePossible values:
add_watermarkbooleanOptional

Add an invisible watermark to the generated images.

Default: false
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

image_sizeany ofOptionalDefault: landscape_4_3
or
string · enumOptional

The size of the generated image.

Possible values:
num_inference_stepsinteger · min: 1Optional

The number of inference steps to perform.

enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
post
Body
post
Body
modelstring · enumRequiredPossible values:
promptstringRequired

The text prompt describing the content, style, or composition of the image to be generated.

response_formatstring · enumOptional

The format in which the generated images are returned.

Default: urlPossible values:
sizestringOptional

Specifies the dimensions (width x height in pixels) of the generated image. Must be between [512x512, 2048x2048].

seedintegerOptional

The same seed and the same prompt given to the same version of the model will output the same image every time.

guidance_scalenumber · min: 1 · max: 10Optional

The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you.

watermarkbooleanOptional

Add an invisible watermark to the generated images.

Default: false
post
Body
modelstring · enumRequiredPossible values:
aspect_ratiostring · enumOptional

The aspect ratio of the generated image.

Default: 3:2Possible values:
promptstring · max: 2560Required

The text prompt describing the content, style, or composition of the image to be generated.

convert_base64_to_urlbooleanOptional

If True, the URL to the image will be returned; otherwise, the file will be provided in base64 format.

Default: true
Responses
200Success
application/json
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

image_sizeany ofOptionalDefault: square_hd
or
string · enumOptional

The size of the generated image.

Possible values:
stylestring · enumOptional

The style of the generated images.

Default: realistic_imagePossible values:
num_imagesnumber · enumOptional

The number of images to generate.

Default: 1Possible values:
post
Body
post
Body
modelstring · enumRequiredPossible values:
promptstringRequired

The text prompt describing the content, style, or composition of the image to be generated.

image_urlsstring · uri[]Required

List of URLs or local Base64 encoded images to edit.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
Responses
200Success
application/json
import requests

url = "https://api.aimlapi.com/v1/images/generations/"

payload = {
  "model": "flux/schnell",
  "prompt": """
Create a classroom of young robots. 
The chalkboard in the classroom has 'AI Is Your Friend' written on it.
"""
}

headers = {
  #put your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
  "Authorization": "Bearer <YOUR_AIMLAPI_KEY>", 
  "content-type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()

print("Generation:", response.json())
Z-Image Turbo
alibaba/z-image-turbo-lora
Z-Image Turbo LoRA
bytedance/seedream-3.0
Seedream 3.0
bytedance/seededit-3.0-i2i
Seedream 3.0
bytedance/seedream-v4-text-to-image
Seedream 4 Text-to-Image
bytedance/seedream-v4-edit
Seedream 4 Edit
bytedance/uso
USO
bytedance/seedream-4-5
Seedream 4.5
flux-pro
FLUX.1 [pro]
flux-pro/v1.1
FLUX 1.1 [pro]
flux-pro/v1.1-ultra
FLUX 1.1 [pro ultra]
flux-realism
FLUX Realism LoRA
flux/dev
FLUX.1 [dev]
flux/dev/image-to-image
flux/schnell
FLUX.1 [schnell]
flux/kontext-max/text-to-image
FLUX.1 Kontext [max]
flux/kontext-max/image-to-image
FLUX.1 Kontext [max]
flux/kontext-pro/text-to-image
Flux.1 Kontext [pro]
flux/kontext-pro/image-to-image
Flux.1 Kontext [pro]
flux/srpo
FLUX.1 SRPO Text-to-Image
flux/srpo/image-to-image
FLUX.1 SRPO Image-to-Image
blackforestlabs/flux-2
FLUX.2
blackforestlabs/flux-2-edit
FLUX.2 Edit
blackforestlabs/flux-2-lora
Flux 2 LoRA
blackforestlabs/flux-2-lora-edit
Flux 2 LoRA Edit
blackforestlabs/flux-2-pro
FLUX.2 [pro]
blackforestlabs/flux-2-pro-edit
FLUX.2 [pro] Edit
imagen-3.0-generate-002
Imagen 3
google/imagen4/preview
Imagen 4 Preview
imagen-4.0-ultra-generate-preview-06-06
Imagen 4 Ultra
google/gemini-2.5-flash-image
Gemini 2.5 Flash Image
google/gemini-2.5-flash-image-edit
Gemini 2.5 Flash Image Edit
google/gemini-3-pro-image-preview
Gemini 3 Pro Image (Nano Banana Pro)
google/gemini-3-pro-image-preview-edit
Gemini 3 Pro Image Edit (Nano Banana Pro)
google/imagen-4.0-generate-001
Imagen 4.0 Generate
google/imagen-4.0-fast-generate-001
Imagen 4.0 Fast Generate
google/imagen-4.0-ultra-generate-001
Imagen 4.0 Ultra Generate
dall-e-2
OpenAI DALL·E 2
dall-e-3
OpenAI DALL·E 3
openai/gpt-image-1
gpt-image-1
recraft-v3
Recraft v3
reve/create-image
Reve Create Image
reve/edit-image
Reve Edit Image
reve/remix-edit-image
Reve Remix Image
stable-diffusion-v3-medium
Stable Diffusion 3
stable-diffusion-v35-large
Stable Diffusion 3.5 Large
hunyuan/hunyuan-image-v3-text-to-image
HunyuanImage 3.0
topaz-labs/sharpen
Sharpen
topaz-labs/sharpen-gen
Sharpen Generative
x-ai/grok-2-image
Grok 2 Image
modelstring · enumRequiredPossible values:
modestring · enumRequiredPossible values:
image_urlstring · uriRequired

The URL of the reference image.

output_formatstring · enumOptional

The format of the generated image.

Default: jpegPossible values:
subject_detectionstring · enumOptional

Specifies which subjects to detect and process. Options: 'All' (detect all subjects), 'Foreground' (detect only foreground subjects), 'Background' (detect background subjects).

Default: AllPossible values:
face_enhancementbooleanOptional

Whether to enhance faces in the image. When true, the model applies face-specific improvements.

Default: true
face_enhancement_creativitynumber · max: 1Optional

Level of creativity for face enhancement (0-1). Higher values allow more creative, less conservative changes.

Default: 0
face_enhancement_strengthnumber · max: 1Optional

How sharp enhanced faces are relative to background (0-1). Lower values blend changes subtly; higher values make faces more pronounced.

Default: 0.8
strengthnumber · min: 0.01 · max: 1Optional

Defines the overall intensity of the sharpening effect. Increases details. Too much sharpening can create an unrealistic result.

minor_denoisenumber · min: 0.01 · max: 1Optional

Removes noisy pixels to increase clarity. Can slightly increase image sharpness.

Responses
200Success
application/json
post
/v1/images/generations
200Success
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
/v1/images/generations
200Success
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

negative_promptstringOptional

The description of elements to avoid in the generated image.

image_sizeany ofOptional

The size of the generated image.

Default: square_hd
string · enumOptionalPossible values:
or
num_inference_stepsinteger · min: 1 · max: 50Optional

The number of inference steps to perform.

Default: 28
guidance_scalenumber · min: 1 · max: 20Optional

The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you.

Default: 7.5
enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
sync_modebooleanOptional

If set to true, the function will wait for the image to be generated and uploaded before returning the response. This will increase the latency of the function but it allows you to get the image directly in the response without going through the CDN.

Default: false
output_formatstring · enumOptional

The format of the generated image.

Default: pngPossible values:
enable_prompt_expansionbooleanOptional

If set to True, prompt will be upsampled with more details.

Responses
200Success
application/json
post
/v1/images/generations
200Success
Responses
200Success
application/json
post
/v1/images/generations
200Success
modelstring · enumRequiredPossible values:
promptstring · max: 400Required

The text prompt describing the content, style, or composition of the image to be generated.

convert_base64_to_urlbooleanOptional

If True, the URL to the image will be returned; otherwise, the file will be provided in base64 format.

Default: true
num_imagesinteger · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · max: 4294967295Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

enhance_promptbooleanOptional

Optional parameter to use an LLM-based prompt rewriting feature for higher-quality images that better match the original prompt. Disabling it may affect image quality and prompt alignment.

Default: true
aspect_ratiostring · enumOptional

The aspect ratio of the generated image.

Default: 1:1Possible values:
person_generationstring · enumOptional

Allow generation of people.

Default: allow_adultPossible values:
safety_settingstring · enumOptional

Adds a filter level to safety filtering.

Default: block_medium_and_abovePossible values:
add_watermarkbooleanOptional

Add an invisible watermark to the generated images.

Default: false
Responses
200Success
application/json
post
/v1/images/generations
200Success
200Success
200Success
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      "model": "topaz-labs/sharpen",
      "mode": "Standard",
      "image_url": "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blurred-landscape.png"
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'bytedance/seedream-3.0',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'reve/create-image',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'hunyuan/hunyuan-image-v3-text-to-image',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'recraft-v3',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'imagen-3.0-generate-002',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      "model": "bytedance/seedream-4-5",
      "prompt": "Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.",
      "image_urls": [
        "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
        "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg"
      ]
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "credits_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      "model": "blackforestlabs/flux-2-pro-edit",
      "prompt": "Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.",
      "image_urls": [
        "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
        "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg"
      ]
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux-pro/v1.1',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux-pro/v1.1-ultra',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'imagen-4.0-ultra-generate-preview-06-06',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux/schnell',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      "model": "bytedance/uso",
      "prompt": "Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.",
      "image_urls": [
        "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
        "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg"
      ]
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      "model": "blackforestlabs/flux-2-lora-edit",
      "prompt": "Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.",
      "image_urls": [
        "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
        "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg"
      ]
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

image_sizeany ofOptionalDefault: landscape_4_3
or
string · enumOptional

The size of the generated image.

Possible values:
output_formatstring · enumOptional

The format of the generated image.

Default: pngPossible values:
enable_prompt_expansionbooleanOptional

If set to True, prompt will be upsampled with more details.

Default: true
num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

guidance_scalenumber · max: 20Optional

The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you.

num_inference_stepsinteger · min: 4 · max: 50Optional

The number of inference steps to perform.

accelerationstring · enumOptional

The speed of the generation. The higher the speed, the faster the generation.

Default: regularPossible values:
enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
imagestringRequired

The image to be edited. Enter the Base64 encoding of the picture or an accessible URL. Image URL: Make sure that the image URL is accessible. Base64-encoded content: The format must be in lowercase.

sizestring · enumOptional

The model checks the size of the input picture against its internal size table and picks the closest match as the output picture size.

Default: adaptivePossible values:
promptstringRequired

The text prompt describing the content, style, or composition of the image to be generated.

response_formatstring · enumOptional

The format in which the generated images are returned.

Default: urlPossible values:
seedintegerOptional

The same seed and the same prompt given to the same version of the model will output the same image every time.

guidance_scalenumber · min: 1 · max: 10Optional

The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you.

watermarkbooleanOptional

Add an invisible watermark to the generated images.

Default: false
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

image_sizeany ofOptionalDefault: landscape_4_3
or
string · enumOptional

The size of the generated image.

Possible values:
output_formatstring · enumOptional

The format of the generated image.

Default: pngPossible values:
enable_prompt_expansionbooleanOptional

If set to True, prompt will be upsampled with more details.

Default: true
num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

guidance_scalenumber · max: 20Optional

The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you.

num_inference_stepsinteger · min: 4 · max: 50Optional

The number of inference steps to perform.

accelerationstring · enumOptional

The speed of the generation. The higher the speed, the faster the generation.

Default: regularPossible values:
enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 400Required

The text prompt describing the content, style, or composition of the image to be generated.

convert_base64_to_urlbooleanOptional

If True, the URL to the image will be returned; otherwise, the file will be provided in base64 format.

Default: true
num_imagesinteger · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · max: 4294967295Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

enhance_promptbooleanOptional

Optional parameter to use an LLM-based prompt rewriting feature for higher-quality images that better match the original prompt. Disabling it may affect image quality and prompt alignment.

Default: true
aspect_ratiostring · enumOptional

The aspect ratio of the generated image.

Default: 1:1Possible values:
person_generationstring · enumOptional

Allow generation of people.

Default: allow_adultPossible values:
safety_settingstring · enumOptional

Adds a filter level to safety filtering.

Default: block_medium_and_abovePossible values:
add_watermarkbooleanOptional

Add an invisible watermark to the generated images.

Default: false
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

image_urlsstring · uri[] · min: 1 · max: 3Required

List of URLs or local Base64 encoded images to edit.

image_sizeany ofOptionalDefault: landscape_4_3
or
string · enumOptional

The size of the generated image.

Possible values:
output_formatstring · enumOptional

The format of the generated image.

Default: pngPossible values:
enable_prompt_expansionbooleanOptional

If set to True, prompt will be upsampled with more details.

Default: true
guidance_scalenumber · max: 20Optional

The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you.

num_inference_stepsinteger · min: 4 · max: 50Optional

The number of inference steps to perform.

accelerationstring · enumOptional

The speed of the generation. The higher the speed, the faster the generation.

Default: regularPossible values:
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
Responses
200Success
application/json
post
/v1/images/generations
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

image_sizeany ofOptionalDefault: landscape_4_3
or
string · enumOptional

The size of the generated image.

Possible values:
num_inference_stepsinteger · min: 1 · max: 50Optional

The number of inference steps to perform.

guidance_scalenumber · min: 1 · max: 20Optional

The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you.

safety_tolerancestring · enumOptional

The safety tolerance level for the generated image. 1 being the most strict and 5 being the most permissive.

Default: 2Possible values:
output_formatstring · enumOptional

The format of the generated image.

Default: jpegPossible values:
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
modestring · enumRequiredPossible values:
image_urlstring · uriRequired

The URL of the reference image.

output_formatstring · enumOptional

The format of the generated image.

Default: jpegPossible values:
subject_detectionstring · enumOptional

Specifies which subjects to detect and process. Options: 'All' (detect all subjects), 'Foreground' (detect only foreground subjects), 'Background' (detect background subjects).

Default: AllPossible values:
face_enhancementbooleanOptional

Whether to enhance faces in the image. When true, the model applies face-specific improvements.

Default: true
face_enhancement_creativitynumber · max: 1Optional

Level of creativity for face enhancement (0-1). Higher values allow more creative, less conservative changes.

Default: 0
face_enhancement_strengthnumber · max: 1Optional

How sharp enhanced faces are relative to background (0-1). Lower values blend changes subtly; higher values make faces more pronounced.

Default: 0.8
strengthnumber · max: 1Optional

Defines the overall intensity of the sharpening effect. Increases details. Too much sharpening can create an unrealistic result.

focus_boostnumber · min: 0.25 · max: 1Optional

Corrects images that are missing detail by downscaling your image then upscaling the results back to the original size. Use on very blurry images!

seedintegerOptional

Optional fixed seed for repeatable results.

Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

image_sizeany ofOptionalDefault: square_hd
or
string · enumOptional

The size of the generated image.

Possible values:
negative_promptstringOptional

The description of elements to avoid in the generated image.

guidance_scalenumber · min: 1 · max: 20Optional

The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you.

num_inference_stepsinteger · min: 1 · max: 50Optional

The number of inference steps to perform.

enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
output_formatstring · enumOptional

The format of the generated image.

Default: jpegPossible values:
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
image_urlsstring · uri[] · min: 1 · max: 10Required

List of URLs or local Base64 encoded images to edit.

image_sizeany ofOptional

The size of the generated image.

Default: square_hd
string · enumOptionalPossible values:
or
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

sync_modebooleanOptional

If set to true, the function will wait for the image to be generated and uploaded before returning the response. This will increase the latency of the function but it allows you to get the image directly in the response without going through the CDN.

Default: false
enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
Responses
200Success
application/json
post
/v1/images/generations
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

image_sizeany ofOptionalDefault: square_hd
or
string · enumOptional

The size of the generated image.

Possible values:
negative_promptstringOptional

The description of elements to avoid in the generated image.

prompt_expansionbooleanOptional

If set to True, prompt will be upsampled with more details.

guidance_scalenumber · min: 1 · max: 20Optional

The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you.

num_inference_stepsinteger · min: 1 · max: 50Optional

The number of inference steps to perform.

enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 400Required

The text prompt describing the content, style, or composition of the image to be generated.

convert_base64_to_urlbooleanOptional

If True, the URL to the image will be returned; otherwise, the file will be provided in base64 format.

Default: true
num_imagesinteger · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · max: 4294967295Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

enhance_promptbooleanOptional

Optional parameter to use an LLM-based prompt rewriting feature for higher-quality images that better match the original prompt. Disabling it may affect image quality and prompt alignment.

Default: true
aspect_ratiostring · enumOptional

The aspect ratio of the generated image.

Default: 1:1Possible values:
person_generationstring · enumOptional

Allow generation of people.

Default: allow_adultPossible values:
safety_settingstring · enumOptional

Adds a filter level to safety filtering.

Default: block_medium_and_abovePossible values:
add_watermarkbooleanOptional

Add an invisible watermark to the generated images.

Default: false
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

num_imagesnumber · min: 1 · max: 4Optional

Number of image variations to generate. Each image is a different attempt to combine the reference images (from the image_url parameter) according to the prompt.

Default: 1
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

guidance_scalenumber · min: 1 · max: 20Optional

The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you.

safety_tolerancestring · enumOptional

The safety tolerance level for the generated image. 1 being the most strict and 5 being the most permissive.

Default: 2Possible values:
output_formatstring · enumOptional

The format of the generated image.

Default: jpegPossible values:
aspect_ratiostring · enumOptional

The aspect ratio of the generated image.

Default: 16:9Possible values:
image_urlany ofRequired

One or more image URLs used as visual references. The model merges them into a single image following the prompt instructions.

string · uriOptional
or
string · uri[] · max: 4Optional
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

num_imagesnumber · min: 1 · max: 4Optional

Number of image variations to generate. Each image is a different attempt to combine the reference images (from the image_url parameter) according to the prompt.

Default: 1
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

guidance_scalenumber · min: 1 · max: 20Optional

The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you.

safety_tolerancestring · enumOptional

The safety tolerance level for the generated image. 1 being the most strict and 5 being the most permissive.

Default: 2Possible values:
output_formatstring · enumOptional

The format of the generated image.

Default: jpegPossible values:
aspect_ratiostring · enumOptional

The aspect ratio of the generated image.

Default: 16:9Possible values:
image_urlany ofRequired

One or more image URLs used as visual references. The model merges them into a single image following the prompt instructions.

string · uriOptional
or
string · uri[] · max: 4Optional
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

guidance_scalenumber · min: 1 · max: 20Optional

The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you.

safety_tolerancestring · enumOptional

The safety tolerance level for the generated image. 1 being the most strict and 5 being the most permissive.

Default: 2Possible values:
output_formatstring · enumOptional

The format of the generated image.

Default: jpegPossible values:
aspect_ratiostring · enumOptional

The aspect ratio of the generated image.

Default: 16:9Possible values:
post
Body
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

nnumber · enumOptional

The number of images to generate.

Default: 1Possible values:
qualitystring · enumOptional

The quality of the image that will be generated.

Default: standardPossible values:
sizestring · enumOptional

The size of the generated image.

Default: 1024x1024Possible values:
stylestring · enumOptional

The style of the generated images.

Default: vividPossible values:
response_formatstring · enumOptional

The format in which the generated images are returned.

Default: urlPossible values:
post
Body
post
Body
modelstring · enumRequiredPossible values:
promptstringRequired

The text prompt describing the content, style, or composition of the image to be generated.

aspect_ratiostring · enumOptional

The aspect ratio of the generated image.

Default: 1:1Possible values:
resolutionstring · enumOptional

The size of the generated image.

Default: 1KPossible values:
num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

image_sizeany ofOptionalDefault: landscape_4_3
or
string · enumOptional

The size of the generated image.

Possible values:
guidance_scalenumber · min: 1 · max: 20Optional

The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you.

num_inference_stepsinteger · min: 1 · max: 50Optional

The number of inference steps to perform.

enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
post
Body
post
Body
modelstring · enumRequiredPossible values:
promptstringRequired

The text prompt describing the content, style, or composition of the image to be generated.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
Responses
200Success
application/json
Responses
200Success
application/json
post
/v1/images/generations
200Success
modelstring · enumRequiredPossible values:
promptstring · max: 400Required

The text prompt describing the content, style, or composition of the image to be generated.

convert_base64_to_urlbooleanOptional

If True, the URL to the image will be returned; otherwise, the file will be provided in base64 format.

Default: true
num_imagesinteger · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · max: 4294967295Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

enhance_promptbooleanOptional

Optional parameter to use an LLM-based prompt rewriting feature for higher-quality images that better match the original prompt. Disabling it may affect image quality and prompt alignment.

Default: true
aspect_ratiostring · enumOptional

The aspect ratio of the generated image.

Default: 1:1Possible values:
person_generationstring · enumOptional

Allow generation of people.

Default: allow_adultPossible values:
safety_settingstring · enumOptional

Adds a filter level to safety filtering.

Default: block_medium_and_abovePossible values:
add_watermarkbooleanOptional

Add an invisible watermark to the generated images.

Default: false
Responses
200Success
application/json
post
/v1/images/generations
200Success
Responses
200Success
application/json
post
/v1/images/generations
200Success
modelstring · enumRequiredPossible values:
promptstring · max: 400Required

The text prompt describing the content, style, or composition of the image to be generated.

convert_base64_to_urlbooleanOptional

If True, the URL to the image will be returned; otherwise, the file will be provided in base64 format.

Default: true
num_imagesinteger · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · max: 4294967295Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

enhance_promptbooleanOptional

Optional parameter to use an LLM-based prompt rewriting feature for higher-quality images that better match the original prompt. Disabling it may affect image quality and prompt alignment.

Default: true
aspect_ratiostring · enumOptional

The aspect ratio of the generated image.

Default: 1:1Possible values:
person_generationstring · enumOptional

Allow generation of people.

Default: allow_adultPossible values:
safety_settingstring · enumOptional

Adds a filter level to safety filtering.

Default: block_medium_and_abovePossible values:
add_watermarkbooleanOptional

Add an invisible watermark to the generated images.

Default: false
Responses
200Success
application/json
post
/v1/images/generations
200Success
Responses
200Success
application/json
post
/v1/images/generations
200Success
Responses
200Success
application/json
post
/v1/images/generations
200Success
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

num_inference_stepsinteger · min: 1 · max: 50Optional

The number of inference steps to perform.

Default: 40
guidance_scalenumber · min: 1 · max: 20Optional

The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you.

Default: 4.5
sync_modebooleanOptional

If set to true, the function will wait for the image to be generated and uploaded before returning the response. This will increase the latency of the function but it allows you to get the image directly in the response without going through the CDN.

Default: false
enable_safety_checkerbooleanOptional

If set to True, the safety checker will be enabled.

Default: true
output_formatstring · enumOptional

The format of the generated image.

Default: jpegPossible values:
accelerationstring · enumOptional

The speed of the generation. The higher the speed, the faster the generation.

Default: regularPossible values:
image_urlstring · uriRequired

The URL of the reference image.

strengthnumber · max: 1Optional

Determines how much the prompt influences the generated image.

Default: 0.95
Responses
200Success
application/json
post
/v1/images/generations
200Success
post
/v1/images/generations
200Success
200Success
200Success
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux/kontext-pro/text-to-image',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'google/imagen-4.0-generate-001',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'dall-e-3',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'google/imagen4/preview',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'google/nano-banana-pro',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "credits_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux/dev',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      "model": "flux/srpo/image-to-image",
      "prompt": "Add a crown to the T-rex's head.",
      "image_url": "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png"
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'google/gemini-2.5-flash-image',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      "model": "google/gemini-2.5-flash-image-edit",
      "prompt": "Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.",
      "image_urls": [
        "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
        "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg"
      ]
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'blackforestlabs/flux-2',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      "model": "bytedance/seededit-3.0-i2i",
      "prompt": "Add a crown to the T-rex's head.",
      "image": "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png"
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'blackforestlabs/flux-2-lora',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'google/imagen-4.0-fast-generate-001',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux-pro',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      "model": "topaz-labs/sharpen-gen",
      "mode": "Super Focus",
      "image_url": "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blurred-landscape.png"
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'stable-diffusion-v35-large',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'stable-diffusion-v3-medium',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'google/imagen-4.0-ultra-generate-001',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      "model": "flux/kontext-max/image-to-image",
      "prompt": "Add a crown to the T-rex's head.",
      "image_url": "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png"
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      "model": "flux/kontext-pro/image-to-image",
      "prompt": "Add a crown to the T-rex's head.",
      "image_url": "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png"
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      "model": "blackforestlabs/flux-2-edit",
      "prompt": "Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.",
      "image_urls": [
        "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
        "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg"
      ]
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      "model": "bytedance/seedream-v4-edit",
      "prompt": "Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.",
      "image_urls": [
        "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
        "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg"
      ]
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();

Nano Banana Pro Edit (Gemini 3 Pro Image Edit)

This documentation is valid for the following list of our models:

  • google/nano-banana-pro-edit

  • google/gemini-3-pro-image-preview-edit

Both IDs listed above refer to the same model; we support them for backward compatibility.

Model Overview

Google’s smartest image-to-image model as of the November 2025 preview release. The model takes multiple images as input, with the prompt defining how they are used or combined.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our .

API Schema

Quick Example

Let's generate an image of the specified size using two input images and a prompt that defines how they should be edited.

Response
Reference Images
Generated Image

Here’s an example of the output using alternative resolution and aspect_ratio parameters:

post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 32000Required

The text prompt describing the content, style, or composition of the image to be generated.

backgroundstring · enumOptional

Allows to set transparency for the background of the generated image(s). When auto is used, the model will automatically determine the best background for the image. If transparent, the output format needs to support transparency, so it should be set to either png (default value) or webp.

Default: autoPossible values:
moderationstring · enumOptional

Control the content-moderation level for images.

Default: autoPossible values:
nnumber · enumOptional

The number of images to generate.

Default: 1Possible values:
output_compressioninteger · max: 100Optional

The compression level (0-100%) for the generated images.

Default: 100
output_formatstring · enumOptional

The format of the generated image.

Default: pngPossible values:
qualitystring · enumOptional

The quality of the image that will be generated.

Default: mediumPossible values:
sizestring · enumOptional

The size of the generated image.

Default: 1024x1024Possible values:
response_formatstring · enumOptional

The format in which the generated images are returned.

Default: urlPossible values:
Responses
200Success
application/json
post
/v1/images/generations
200Success
Image #1
"Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect."
Image #2

Quickstart guide
"aspect_ratio": "16:9", "resolution": "2K"
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'openai/gpt-image-1',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
import requests
import json

def main():
    response = requests.post(
        "https://api.aimlapi.com/v1/images/generations",
        headers={
            # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
            "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
            "Content-Type": "application/json",
        },
        json={
            "model": "google/nano-banana-pro-edit",
            "image_urls": [
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
                "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg"
            ],
            "prompt": "Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.",
            "aspect_ratio": "16:9",
            "resolution": "1K"
        }
    )

    data = response.json()
    print(json.dumps(data, indent=2, ensure_ascii=False))

if __name__ == "__main__":
    main()
async function main() {
    const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
      method: 'POST',
      headers: {
        // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
        'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        model: 'google/nano-banana-pro-edit',
        image_urls: [
                'https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png',
                'https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg'
        ],
        prompt: 'Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.',
        aspect_ratio: '1:1',
        resolution: '1K'
      }),
    });
}

main();
{
  "description": "",
  "data": [
    {
      "url": "https://cdn.aimlapi.com/flamingo/files/b/koala/qnutcal6jcrPr43jMp_Xg.png",
      "content_type": "image/png",
      "width": null,
      "height": null,
      "file_name": "qnutcal6jcrPr43jMp_Xg.png"
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 315000
    }
  }
}
post
Authorizations
AuthorizationstringRequired

Bearer key

Body
modelundefined · enumRequiredPossible values:
image_urlstring · uriRequired

The URL of the reference image.

promptstring · max: 2560Required

The text prompt describing the content, style, or composition of the image to be generated.

convert_base64_to_urlbooleanOptional

If True, the URL to the image will be returned; otherwise, the file will be provided in base64 format.

Default: true
output_formatstring · enumOptional

The format of the generated image.

Default: jsonPossible values:
Responses
201

Successfully generated image

application/json
post
/v1/images/generations
201

Successfully generated image

async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'reve/edit-image',
      prompt: "Add a crown to the T-rex's head.",
      image_url: 'https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "text",
      "b64_json": "text"
    }
  ]
}
post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 4000Required

The text prompt describing the content, style, or composition of the image to be generated.

num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
seedinteger · min: 1Optional

The same seed and the same prompt given to the same version of the model will output the same image every time.

guidance_scalenumber · min: 1 · max: 20Optional

The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you.

safety_tolerancestring · enumOptional

The safety tolerance level for the generated image. 1 being the most strict and 5 being the most permissive.

Default: 2Possible values:
output_formatstring · enumOptional

The format of the generated image.

Default: jpegPossible values:
aspect_ratiostring · enumOptional

The aspect ratio of the generated image.

Default: 16:9Possible values:
Responses
200Success
application/json
post
/v1/images/generations
200Success
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'flux/kontext-max/text-to-image',
      prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "tokens_used": 120000
    }
  }
}
post
Body
modelstring · enumRequiredPossible values:
promptstringRequired

The text prompt describing the content, style, or composition of the image to be generated.

image_urlsstring · uri[]Required

List of URLs or local Base64 encoded images to edit. Supports up to 14 images.

aspect_ratiostring · enumOptional

The aspect ratio of the generated image.

Default: 1:1Possible values:
resolutionstring · enumOptional

The size of the generated image.

Default: 1KPossible values:
num_imagesnumber · min: 1 · max: 4Optional

The number of images to generate.

Default: 1
Responses
200Success
application/json
post
/v1/images/generations
200Success
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "credits_used": 120000
    }
  }
}
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      "model": "google/nano-banana-pro-edit",
      "prompt": "Combine the images so the T-Rex is wearing a business suit, sitting in a cozy small café, drinking from the mug. Blur the background slightly to create a bokeh effect.",
      "image_urls": [
        "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png",
        "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/blue-mug.jpg"
      ]
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
post
Authorizations
AuthorizationstringRequired

Bearer key

Body
modelundefined · enumRequiredPossible values:
image_urlsstring · uri[] · min: 1 · max: 4Required

List of URLs or local Base64 encoded images to edit.

aspect_ratiostring · enumOptional

The aspect ratio of the generated image.

Default: 3:2Possible values:
promptstring · max: 2560Required

The text prompt describing the content, style, or composition of the image to be generated.

convert_base64_to_urlbooleanOptional

If True, the URL to the image will be returned; otherwise, the file will be provided in base64 format.

Default: true
output_formatstring · enumOptional

The format of the generated image.

Default: jsonPossible values:
Responses
201

Successfully generated image

application/json
post
/v1/images/generations
201

Successfully generated image

async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'reve/remix-edit-image',
      prompt: "Add a crown to the T-rex's head.",
      image_urls: ['https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/t-rex.png'],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
{
  "data": [
    {
      "url": "text",
      "b64_json": "text"
    }
  ]
}
post
Authorizations
AuthorizationstringRequired

Bearer key

Body
modelstring · enumRequiredPossible values:
promptstring · max: 32000Required

The text prompt describing the content, style, or composition of the image to be generated.

imagestring · binaryRequired

The image(s) to edit. Must be a supported image file or an array of images. Each image should be a png, webp, or jpg file less than 50MB. You can provide up to 16 images.

maskstring · binaryOptional

An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where image should be edited. If there are multiple images provided, the mask will be applied on the first image. Must be a valid PNG file, less than 4MB, and have the same dimensions as image.

backgroundstring · enumOptional

Allows to set transparency for the background of the generated image(s). When auto is used, the model will automatically determine the best background for the image. If transparent, the output format needs to support transparency, so it should be set to either png (default value) or webp.

Default: autoPossible values:
nnumber · min: 1 · max: 10Optional

The number of images to generate.

Default: 1
output_compressioninteger · max: 100Optional

The compression level (0-100%) for the generated images.

Default: 100
output_formatstring · enumOptional

The format of the generated image.

Default: pngPossible values:
qualitystring · enumOptional

The quality of the image that will be generated.

Default: mediumPossible values:
sizestring · enumOptional

The size of the generated image.

Default: 1024x1024Possible values:
response_formatstring · enumOptional

The format in which the generated images are returned.

Default: urlPossible values:
Responses
201

Successfully edited image

application/json
post
/v1/images/edits
201

Successfully edited image

POST /v1/images/edits HTTP/1.1
Host: api.aimlapi.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 214

{
  "model": "openai/gpt-image-1",
  "prompt": "text",
  "image": "binary",
  "mask": "binary",
  "background": "auto",
  "n": 1,
  "output_compression": 100,
  "output_format": "png",
  "quality": "medium",
  "size": "1024x1024",
  "response_format": "url"
}
{
  "data": [
    {
      "url": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png",
      "b64_json": null
    }
  ],
  "meta": {
    "usage": {
      "credits_used": 120000
    }
  }
}