Vision & Images

Using GPT Image Models

Generate images with GPT image models through the OpenAI-compatible /v1/images/generations endpoint.

Updated
Reading time
1 min

On this page

Python Example

import requests
import json

url = "https://api.apertis.ai/v1/images/generations"

payload = json.dumps({
   "model": "gpt-image-2",
   "prompt": "A cute baby sea otter",
   "n": 1,
   "size": "1024x1024"
})
api_key = "APERTIS_API_KEY"
headers = {
   'Authorization': f'Bearer {api_key}',
   'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Parameters

  • model: The model to use, e.g. gpt-image-2. See Models for the current image models
  • size: The size of the image: 1024x1024, 1536x1024, 1024x1536 or auto
  • APERTIS_API_KEY: Your API key