GPT-Image-2 API
GPT-Image-2 API: Text-to-Image and Image Editing Guide
gw-link serves the OpenAI-compatible image endpoints: POST /v1/images/generations creates images from a prompt and POST /v1/images/edits edits or restyles a reference image, with model set to gpt-image-2. Good for product shots, tutorial graphics and batch content.
Text-to-image
/v1/images/generations turns a prompt into product shots, tutorial art or marketing visuals, returned as base64 image data.
Image edits
/v1/images/edits takes a reference image (multipart/form-data) for restyling, redraws or local edits.
Automation-ready
Standard OpenAI image API, so the openai SDK works in scripts, pipelines and backend jobs.
How to call the image API
- Create a key in the gw-link console on a group with image generation enabled.
- Call /v1/images/generations or /v1/images/edits with model set to gpt-image-2.
- Decode the returned b64_json and save it as an image file.
- Wire it into your publishing or review pipeline.
Configuration examples
curl text-to-image
curl https://gw-link.com/v1/images/generations \
-H "Authorization: Bearer sk-your-gw-link-key" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-image-2","prompt":"an orange cat napping on a keyboard, product photography","size":"1024x1024"}'Python, save the image
import base64
from openai import OpenAI
client = OpenAI(base_url="https://gw-link.com/v1", api_key="sk-your-gw-link-key")
img = client.images.generate(
model="gpt-image-2",
prompt="minimal diagram of an API gateway architecture",
size="1024x1024",
)
with open("out.png", "wb") as f:
f.write(base64.b64decode(img.data[0].b64_json))FAQ
Can GPT-Image-2 be called in batch?
Yes. It is the standard OpenAI image API, suited to scripts and backend workflows.
Do I get a URL or image data?
GPT-Image models return base64 image data (data[0].b64_json); decode it and save as PNG.
I get a permission error — why?
Make sure your key's group has image generation enabled and that /v1/models lists gpt-image-2.
Last updated: