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/generationsRequest 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
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | ✅ | Image model ID |
prompt | string | ✅ | Text description of the image |
n | integer | ❌ | Number of images to generate (default: 1) |
size | string | ❌ | Image dimensions (e.g., 1024x1024) |
quality | string | ❌ | Quality level: standard or hd |
response_format | string | ❌ | url 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
| Model | Sizes | Notes |
|---|---|---|
openai/dall-e-3 | 1024x1024, 1792x1024, 1024x1792 | High quality, prompt revision |
openai/gpt-image-1 | Multiple | GPT-powered image generation |
flux/flux-1-pro | Multiple | Flux professional quality |
INFO
Image generation pricing varies by model, size, and quality. Check the Console for current rates.
