Generate an image by providing a model and a text prompt.
Python
Node.js
cURL
import osfrom openai import OpenAIclient = OpenAI( base_url="https://api.routeway.ai/v1", api_key=os.getenv("ROUTEWAY_API_KEY"),)response = client.images.generate( model="gpt-image-1", prompt="A watercolor painting of a mountain lake at dawn",)print(response.data[0].url)
import OpenAI from "openai";const client = new OpenAI({ baseURL: "https://api.routeway.ai/v1", apiKey: process.env.ROUTEWAY_API_KEY,});const response = await client.images.generate({ model: "gpt-image-1", prompt: "A watercolor painting of a mountain lake at dawn",});console.log(response.data[0].url);
curl -X POST https://api.routeway.ai/v1/images/generations \ -H "Authorization: Bearer $ROUTEWAY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-image-1", "prompt": "A watercolor painting of a mountain lake at dawn" }'
Set n to generate multiple images in a single request.
Python
Node.js
cURL
response = client.images.generate( model="gpt-image-1", prompt="A minimalist logo for a coffee shop", n=4, size="1024x1024",)for i, image in enumerate(response.data): print(f"Image {i + 1}: {image.url}")
const response = await client.images.generate({ model: "gpt-image-1", prompt: "A minimalist logo for a coffee shop", n: 4, size: "1024x1024",});response.data.forEach((image, i) => { console.log(`Image ${i + 1}: ${image.url}`);});
curl -X POST https://api.routeway.ai/v1/images/generations \ -H "Authorization: Bearer $ROUTEWAY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-image-1", "prompt": "A minimalist logo for a coffee shop", "n": 4, "size": "1024x1024" }'
import base64response = client.images.generate( model="gpt-image-1", prompt="A detailed sketch of a cat wearing a top hat", response_format="b64_json",)image_data = base64.b64decode(response.data[0].b64_json)with open("output.png", "wb") as f: f.write(image_data)print("Image saved to output.png")
import fs from "fs";const response = await client.images.generate({ model: "gpt-image-1", prompt: "A detailed sketch of a cat wearing a top hat", response_format: "b64_json",});const imageBuffer = Buffer.from(response.data[0].b64_json, "base64");fs.writeFileSync("output.png", imageBuffer);console.log("Image saved to output.png");
curl -X POST https://api.routeway.ai/v1/images/generations \ -H "Authorization: Bearer $ROUTEWAY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-image-1", "prompt": "A detailed sketch of a cat wearing a top hat", "response_format": "b64_json" }' | jq -r '.data[0].b64_json' | base64 -d > output.png
Instead of “a dog”, try “a golden retriever sitting in a sunlit meadow, photorealistic, soft bokeh background”. More detail gives the model stronger guidance.
Specify a style
Include style cues like “watercolor”, “3D render”, “pixel art”, “oil painting”, or “studio photography” to steer the aesthetic.
Describe composition
Mention framing details such as “close-up”, “bird’s-eye view”, “centered”, or “rule of thirds” for more intentional compositions.