Image Generation
Learn how to generate images using TurboAPI.
Image Generation
TurboAPI provides unified access to leading image generation models including DALL-E 3, Midjourney, and Stable Diffusion.
Generate Images
import { TurboAPI } from '@turboapi/sdk';
const client = new TurboAPI({
apiKey: process.env.TURBOAPI_API_KEY,
});
// Generate an image
const image = await client.images.generate({
model: 'dall-e-3',
prompt: 'A beautiful sunset over mountains with golden light',
size: '1024x1024',
quality: 'standard',
n: 1,
});
console.log(image.url);
Image to Image
Transform existing images:
const result = await client.images.edit({
model: 'stable-diffusion-xl',
image: imageBuffer,
prompt: 'Turn this into a painting style',
strength: 0.7,
});
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model to use (dall-e-3, midjourney, stable-diffusion-xl) |
prompt | string | Yes | Description of the image |
size | string | No | Image size (1024x1024, 1792x1024, etc.) |
quality | string | No | Quality (standard, hd) |
n | number | No | Number of images (1-4) |
Response
{
"data": [
{
"url": "https://...",
"revised_prompt": "...",
"b64_json": "..."
}
],
"meta": {
"request_id": "req_123",
"processing_time_ms": 4520
}
}
Best Practices
- Be specific in your prompt
- Mention style (photorealistic, oil painting, anime)
- Specify lighting (golden hour, neon, natural)
- Include composition details (portrait, landscape, close-up)
Tip: Start with simple prompts and iterate based on results.