gpt-image-1-5

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

  • openai/gpt-image-1-5

Model Overview

A powerful image generation and editing model that supports text-to-image, image-to-image, and inpainting with masks and reference inputs — all guided by a text prompt.

How to Make a Call

Step-by-Step Instructions

1️ Setup You Can’t Skip

▪️ Create an Account: Visit the AI/ML API website and create an account (if you don’t have one yet). ▪️ Generate an API Key: After logging in, navigate to your account dashboard and generate your API key. Ensure the key is enabled on the UI.

2️ Copy the code example

At the bottom of this page, you'll find a code example that shows how to structure the request. Choose the code snippet in your preferred programming language and copy it into your development environment.

3️ Modify the code example

▪️ Replace <YOUR_AIMLAPI_KEY> with your actual AI/ML API key. ▪️ Adjust the input field used by this model (for example, prompt, input text, instructions, media source, or other model-specific input) to match your request.

4️ (Optional) Adjust other optional parameters if needed

Only the required parameters shown in the example are needed to run the request, but you can include optional parameters to fine-tune behavior. Below, you can find the corresponding API schema, which lists all available parameters and usage notes.

5️ Run your modified code

Run your modified code inside your development environment. Response time depends on many factors, but for simple requests it rarely exceeds a few seconds.

API Schema

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

Code Example

Response

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

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

Last updated

Was this helpful?