RelayRouterRelayRouter
HomeModelsPricingDocsGet API Key

Docs / Image Generation

Image Generation

Generate images from text prompts through the OpenAI-compatible POST /v1/images/generations endpoint. The request returns image URLs directly; no polling required.

#Models

Use any image model ID from your key's model list, for example gpt-image-1. Call GET /v1/models or browse the Models page for the exact IDs available to you.

#API usage

cURL

terminalbash
curl https://relayrouter.io/v1/images/generations \
  -H "Authorization: Bearer $RELAYROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-1",
    "prompt": "A serene Japanese garden with cherry blossoms, watercolor style",
    "n": 1
  }'

Python

image.pypython
import requests, os

response = requests.post(
    "https://relayrouter.io/v1/images/generations",
    headers={
        "Authorization": f"Bearer {os.environ['RELAYROUTER_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "model": "gpt-image-1",
        "prompt": "A serene Japanese garden with cherry blossoms, watercolor style",
        "n": 1,
    },
)
data = response.json()
print(data["data"][0]["url"])

OpenAI SDK

image.tstypescript
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.RELAYROUTER_API_KEY,
  baseURL: "https://relayrouter.io/v1",
});

const res = await client.images.generate({
  model: "gpt-image-1",
  prompt: "A futuristic city at dusk, cinematic lighting",
  n: 1,
});
console.log(res.data[0].url);

#Response

response.jsonjson
{
  "data": [
    { "url": "https://..." }
  ]
}

#Request parameters

ParameterTypeDescription
modelstringImage model ID
promptstringText description of the image to generate
nintegerNumber of images to generate. Default: 1
sizestringOptional output size, model-dependent (e.g. "1024x1024")

#Tips for better results

  • Be specific: describe style, composition, lighting and mood in your prompt
  • Name a style: keywords like "photorealistic", "watercolor", "anime" steer the output strongly
  • Iterate: small prompt changes can shift results a lot; generate, adjust, repeat