Skip to content

Image generation

The public catalog includes GPT Image and Gemini image entries. Generation, editing, sizes and other options depend on the route and key permissions. Image understanding in a text model does not necessarily mean image generation.

POST https://wudiapi.com/v1/images/generations

Terminal window
curl https://wudiapi.com/v1/images/generations \
-H "Authorization: Bearer $WUDI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-image-2","prompt":"A blue ceramic cup on a white background, product photography, soft light.","n":1}'

Start with minimal fields. Add size, quality, transparent backgrounds or output-format options only after confirming support. Generation requests incur charges; avoid repeated generation through automatic retries.

The data array may contain a url or b64_json. Do not assume one format. URLs may be temporary, so save results promptly. Decode Base64 before writing an image file:

import base64
from pathlib import Path
def save_first_image(payload):
item = payload["data"][0]
if item.get("b64_json"):
Path("result.png").write_bytes(base64.b64decode(item["b64_json"]))
else:
print("Save the returned image URL:", item.get("url"))

Images can take longer than a short chat response. After a timeout, check whether the request completed before sending another one. Start with one image. Use images you have permission to upload and exclude unnecessary personal information or credentials.

Continue with GPT Image, Nano Banana or image editing.