Skip to content

Image Generation

Generate images using AI models like DALL-E 3, GPT Image, and Flux through a single API endpoint.

Endpoint

POST https://toprouter.cc/images/generations

Request Format

json
{
  "model": "openai/dall-e-3",
  "prompt": "A serene mountain landscape at sunset with a crystal clear lake",
  "n": 1,
  "size": "1024x1024",
  "quality": "hd"
}

Parameters

ParameterTypeRequiredDescription
modelstringImage model ID
promptstringText description of the image
nintegerNumber of images to generate (default: 1)
sizestringImage dimensions (e.g., 1024x1024)
qualitystringQuality level: standard or hd
response_formatstringurl or b64_json

Response Format

json
{
  "created": 1717500000,
  "data": [
    {
      "url": "https://example.com/generated-image.png",
      "revised_prompt": "A serene mountain landscape..."
    }
  ]
}

Code Examples

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-your-toprouter-key",
    base_url="https://toprouter.cc"
)

response = client.images.generate(
    model="openai/dall-e-3",
    prompt="A futuristic city skyline at night, cyberpunk style",
    size="1024x1024",
    quality="hd",
    n=1
)

print(response.data[0].url)
typescript
import OpenAI from 'openai';

const openai = new OpenAI({
  apiKey: 'sk-your-toprouter-key',
  baseURL: 'https://toprouter.cc'
});

const response = await openai.images.generate({
  model: 'openai/dall-e-3',
  prompt: 'A futuristic city skyline at night, cyberpunk style',
  size: '1024x1024',
  quality: 'hd',
  n: 1
});

console.log(response.data[0].url);
bash
curl https://toprouter.cc/images/generations \
  -H "Authorization: Bearer sk-your-toprouter-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/dall-e-3",
    "prompt": "A futuristic city skyline at night, cyberpunk style",
    "size": "1024x1024",
    "quality": "hd",
    "n": 1
  }'

Available Models

ModelSizesNotes
openai/dall-e-31024x1024, 1792x1024, 1024x1792High quality, prompt revision
openai/gpt-image-1MultipleGPT-powered image generation
flux/flux-1-proMultipleFlux professional quality

INFO

Image generation pricing varies by model, size, and quality. Check the Console for current rates.

Unified AI API Gateway — Access 200+ models through one endpoint.