Images API
POST /v1/images/generations
The Images API generates images from text prompts using models like DALL-E, gpt-image-1, and gpt-image-1.5.
HTTP Request
curl https://api.apertis.ai/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <APERTIS_API_KEY>" \
-d '{
"model": "gpt-image-1",
"prompt": "A cute baby sea otter",
"n": 1,
"size": "1024x1024"
}'
Authentication
| Header | Format | Example |
|---|---|---|
Authorization | Bearer token | Authorization: Bearer sk-your-api-key |
Parameters
Required Parameters
| Parameter | Type | Description |
|---|---|---|
prompt | string | A text description of the desired image(s). See prompt limits below |
Prompt Length Limits
| Model | Max Prompt Length |
|---|---|
dall-e-2 | 1000 characters |
dall-e-3 | 4000 characters |
gpt-image-1 | 32000 characters |
gpt-image-1.5 | 32000 characters |
Optional Parameters
| Parameter | Type | Description |
|---|---|---|
model | string | The model to use for image generation. Default: dall-e-2 |
n | integer | Number of images to generate (1-10). Default: 1 |
size | string | Size of the generated images (see Size Options below) |
quality | string | Quality of the image: standard, hd. Default: standard |
response_format | string | Format of the response: url, b64_json. Default: url |
style | string | Style of the image: vivid, natural. Default: vivid |
user | string | A unique identifier for the end-user |
gpt-image-1 and gpt-image-1.5 Specific Parameters
| Parameter | Type | Description |
|---|---|---|
background | string | Background type: transparent, opaque, auto. Default: auto |
moderation | string | Moderation level: low, auto. Default: auto |
output_format | string | Output format: png, jpeg, webp. Default: png |
output_compression | integer | Compression level (0-100%) for jpeg/webp output formats. Default: 100 |
Note: GPT image models always return base64-encoded images (
b64_json). Theresponse_formatparameter withurloption is not supported for these models.
Size Options
| Model | Supported Sizes |
|---|---|
dall-e-2 | 256x256, 512x512, 1024x1024 |
dall-e-3 | 1024x1024, 1792x1024, 1024x1792 |
gpt-image-1 | 1024x1024, 1536x1024, 1024x1536, auto |
gpt-image-1.5 | 1024x1024, 1536x1024, 1024x1536, auto |
Example Usage
Python
from openai import OpenAI
client = OpenAI(
api_key="sk-your-api-key",
base_url="https://api.apertis.ai/v1"
)
response = client.images.generate(
model="gpt-image-1",
prompt="A white siamese cat",
n=1,
size="1024x1024"
)
print(response.data[0].url)
JavaScript
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'sk-your-api-key',
baseURL: 'https://api.apertis.ai/v1'
});
const response = await client.images.generate({
model: 'gpt-image-1',
prompt: 'A white siamese cat',
n: 1,
size: '1024x1024'
});
console.log(response.data[0].url);
With Transparent Background (gpt-image-1)
response = client.images.generate(
model="gpt-image-1",
prompt="A logo of a blue bird on transparent background",
n=1,
size="1024x1024",
background="transparent"
)