API reference
Image generation
OpenAI-compatible image generation with gpt-image-2.
POST https://api.routerplex.com/v1/images/generations
OpenAI-compatible image generation. Images are returned base64-encoded and billed by token (prompt text in, image tokens out).
python
from openai import OpenAIimport base64client = OpenAI(base_url="https://api.routerplex.com/v1", api_key="sk-...")result = client.images.generate(model="gpt-image-2",prompt="A lighthouse on a cliff at dusk, watercolor",size="1024x1024",quality="medium", # low | medium | high)with open("lighthouse.png", "wb") as f:f.write(base64.b64decode(result.data[0].b64_json))
- Sizes:
1024x1024,1536x1024,1024x1536. - Higher quality uses more output tokens.
- Try it without code in the playground.