Image Generation & Editing
Vanix AI exposes OpenAI-compatible image generation and editing endpoints (/v1/images/generations and /v1/images/edits) alongside provider-specific multimodal image models.
POST
https://api.vanix.io/v1/images/generationsText-to-Image Generation
bash
curl https://api.vanix.io/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $VANIX_API_KEY" \
-d '{
"model": "gpt-image-1",
"prompt": "Minimalist studio photograph of matte black wireless headphones on slate stone, soft directional rim light",
"size": "1024x1024",
"quality": "high",
"n": 1
}'python
import base64, os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["VANIX_API_KEY"],
base_url="https://api.vanix.io/v1",
)
result = client.images.generate(
model="gpt-image-1",
prompt="Minimalist studio photograph of matte black wireless headphones on slate stone",
size="1024x1024",
quality="high",
)
image_b64 = result.data[0].b64_json
if image_b64:
with open("output.png", "wb") as f:
f.write(base64.b64decode(image_b64))
else:
print("Image URL:", result.data[0].url)Image Editing (Inpainting & Reference Edits)
POST
https://api.vanix.io/v1/images/editsUpload a source image (multipart/form-data) with an optional transparent PNG mask to edit specific regions:
bash
curl https://api.vanix.io/v1/images/edits \
-H "Authorization: Bearer $VANIX_API_KEY" \
-F "model=gpt-image-1" \
-F "image=@product.png" \
-F "prompt=Place the product on a warm oak countertop with morning sunlight" \
-F "size=1024x1024"Response Formats & Storage Best Practices
| Field | Behavior | Recommendation |
|---|---|---|
data[0].b64_json | Inline Base64 PNG/WebP payload (default for gpt-image-1). | Decode and persist immediately to your own object storage (S3/R2). |
data[0].url | Temporary signed upstream URL (expires after minutes/hours). | Download and mirror to permanent storage—never hotlink directly in production UIs. |
n | Number of variations per request (1–4 depending on model). | Billing scales linearly with n, resolution, and quality. |