GPT Image 2
GPT Image 2 costs $0.22 per image on LLM API. It generates and edits images.
Pricing
Lowest price among 2 providers, after discounts.
| Image | $0.22/ image | per image |
|---|---|---|
| Input | $5 | per 1M tokens |
| Output | $30 | per 1M tokens |
| Cache read | $1.25 | per 1M tokens |
Providers
Prices after each provider’s discount; the lowest in bold.
Specifications
- ModesGenerate, Edit
- Output formatsPNG, JPEG, WebP
- Input imagesUp to 16, 50 MB each
- Sizes18 sizes
- 1024×1024
- 1536×1024
- 1024×1536
- 2048×2048
- 2048×1152
- 3840×2160
- 2160×3840
- 1312×800
- 2560×1440
- 1440×480
- 3840×1648
- 1536×864
- 2880×960
- 1920×640
- 3360×1120
- 864×1536
- 800×1312
- 1248×832
Call GPT Image 2
POST /v1/images/generationsSet LLMAPI_KEY to your LLM API key.Generate docs
import base64
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.llmapi.ai/v1",
api_key=os.environ["LLMAPI_KEY"],
)
result = client.images.generate(
model="gpt-image-2",
prompt="A lighthouse at dawn, watercolor",
)
with open(f"image.{result.output_format}", "wb") as f:
f.write(base64.b64decode(result.data[0].b64_json))import fs from "node:fs";
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.llmapi.ai/v1",
apiKey: process.env.LLMAPI_KEY,
});
const result = await client.images.generate({
model: "gpt-image-2",
prompt: "A lighthouse at dawn, watercolor",
});
fs.writeFileSync(`image.${result.output_format}`, Buffer.from(result.data![0].b64_json!, "base64"));curl https://api.llmapi.ai/v1/images/generations \
-H "Authorization: Bearer $LLMAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "A lighthouse at dawn, watercolor"
}'POST /v1/images/editsSet LLMAPI_KEY to your LLM API key.Edit docs
import base64
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.llmapi.ai/v1",
api_key=os.environ["LLMAPI_KEY"],
)
result = client.images.edit(
model="gpt-image-2",
image=open("photo.png", "rb"),
prompt="Replace the sky with a sunset",
)
with open(f"edited.{result.output_format}", "wb") as f:
f.write(base64.b64decode(result.data[0].b64_json))import fs from "node:fs";
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.llmapi.ai/v1",
apiKey: process.env.LLMAPI_KEY,
});
const result = await client.images.edit({
model: "gpt-image-2",
image: fs.createReadStream("photo.png"),
prompt: "Replace the sky with a sunset",
});
fs.writeFileSync(`edited.${result.output_format}`, Buffer.from(result.data![0].b64_json!, "base64"));curl https://api.llmapi.ai/v1/images/edits \
-H "Authorization: Bearer $LLMAPI_KEY" \
-F model="gpt-image-2" \
-F image="@photo.png" \
-F prompt="Replace the sky with a sunset"More from OpenAI
All OpenAI image models
GPT Image 2.5 Sunburstgpt-image-2.5-sunburst$0.22per image
GPT Image 2.5 Flaregpt-image-2.5-flare$0.22per image
Prices synced .