Appearance
GPT Image 2
gpt-image-2 supports text-to-image generation and image editing with OpenAI-compatible size and quality controls.
API surface
| Operation | Endpoint | Mode |
|---|---|---|
| Image generation | POST /v1/images/generations | Sync |
| Image generation task | POST /v1/async/images/generations | Async |
| Image editing | POST /v1/images/edits | Sync |
| Image editing task | POST /v1/async/images/edits | Async |
Pricing
Credits per image are determined by output size tier and quality. quality=auto is billed at the same rate as high, and size=auto defaults to the 1K tier.
| Size tier | Long edge | low | medium | high / auto |
|---|---|---|---|---|
| 1K | <= 1536px | 1 | 4 | 14 |
| 2K | <= 2048px | 2 | 17 | 67 |
| 4K | <= 3840px | 4 | 34 | 133 |
The displayed costCredits for a request equals the matrix value times n.
Request fields
Send the common fields at the top level. Put the model-specific controls listed below inside providerOptions.
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | gpt-image-2. Case-sensitive model ID. |
prompt | string | Yes | Describe the subject, composition, style, and requested edits. Pixapi keeps the first 2,000 characters; provide a non-empty prompt for both generation and editing. |
n | integer | No | Default 1; only integer 1 is supported. |
size | string | No | Use pixel dimensions WIDTHxHEIGHT, for example 1024x1024. Default auto. Custom dimensions: multiples of 16, longest edge ≤ 3840, aspect ratio ≤ 3:1, total pixels 655,360–8,294,400. |
image | string / string[] | For edits | Public HTTP(S) image URL or URL array; required on /images/edits. Up to 14 URLs; Base64 input is not supported. |
quality | string | No | auto (default), low, medium, or high. Higher quality can take longer. |
providerOptions | object | No | Model-specific options; see the table below. |
providerOptions
All fields in this table are nested inside providerOptions, not alongside model.
| Field | Type | Description |
|---|---|---|
output_format | string | Output image format: png (default, keeps transparency), jpeg (smaller files, no alpha), or webp (supports transparency). |
background | string | Background mode: auto (default), opaque, or transparent. transparent can only be combined with output_format: "png" or output_format: "webp"; JPEG does not support an alpha channel. |
moderation | string | Content moderation strictness: auto (default) or low (more permissive). |
output_compression | integer | Output compression level 0–100; applies only to jpeg and webp output. |
mask_url | string | Public PNG mask URL for inpainting. Requires image; dimensions must match the first image. Transparent pixels mark the area to edit. Use a PNG with an alpha channel, under 4 MB. |
nsfw_check | boolean | Optional prompt/image moderation; default false. |
Input rules
Pixapi accepts one output and up to 14 reference images. Output pixels are selected with size.
Example
bash
curl https://api.pixapi.ai/v1/images/generations \
-H "Authorization: Bearer $PIXAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "A polished product photo of a ceramic coffee cup",
"n": 1,
"size": "1024x1024",
"quality": "high"
}'py
import os
import requests
response = requests.post(
"https://api.pixapi.ai/v1/images/generations",
headers={
"Authorization": f"Bearer {os.environ['PIXAPI_KEY']}",
"Content-Type": "application/json",
},
json={
"model": "gpt-image-2",
"prompt": "A polished product photo of a ceramic coffee cup",
"n": 1,
"size": "1024x1024",
"quality": "high"
},
)
response.raise_for_status()
print(response.json())js
const response = await fetch('https://api.pixapi.ai/v1/images/generations', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.PIXAPI_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"model": "gpt-image-2",
"prompt": "A polished product photo of a ceramic coffee cup",
"n": 1,
"size": "1024x1024",
"quality": "high"
}),
});
if (!response.ok) {
throw new Error(await response.text());
}
console.log(await response.json());go
package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{
"model": "gpt-image-2",
"prompt": "A polished product photo of a ceramic coffee cup",
"n": 1,
"size": "1024x1024",
"quality": "high"
}`)
req, err := http.NewRequest(
"POST",
"https://api.pixapi.ai/v1/images/generations",
bytes.NewBuffer(body),
)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("PIXAPI_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
result, _ := io.ReadAll(resp.Body)
fmt.Println(string(result))
}For the custom size limits, see GPT Image.
