API credit fields and examples use integer ledger units: 50 units = 1 customer credit. Divide API amounts by 50 for display. See current customer pricing; historical examples are not price quotes.
Gemini Generate
Generate images from text prompts using Google's Gemini 2.0 Flash model.
/api/v1/models/gemini/generateGenerate an image from a text prompt
Request Body
| Name | Type | Description |
|---|---|---|
promptrequired | string | Text description of the image to generate |
aspectRatio | stringDefault: 1:1 | Output aspect ratio (1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9) |
Example Request
curl -X POST https://vydra.ai/api/v1/models/gemini/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A cozy cabin in the mountains during winter, snow falling gently, warm light from windows, photorealistic",
"aspectRatio": "16:9"
}'Response
{
"imageUrl": "https://pub-xxx.r2.dev/generated/gemini/org_123/1706234400000.png",
"mimeType": "image/png",
"creditsCharged": 20,
"durationMs": 3420
}Response Fields
| Name | Type | Description |
|---|---|---|
imageUrl | string | Public URL of the generated image |
mimeType | string | Image MIME type (image/png) |
creditsCharged | number | Credits deducted (always 20) |
durationMs | number | Generation time in milliseconds |
Error Responses
Missing Prompt (400)
{
"error": "Missing required field: prompt (string)"
}Insufficient Credits (402)
{
"error": "Insufficient credits",
"creditsRequired": 20,
"creditsRemaining": 2
}Generation Failed (500)
{
"error": "Failed to generate image",
"message": "Content policy violation"
}Auto-Refund
Prompt Tips
Be Specific
Instead of "a car", try "a red 1965 Ford Mustang convertible parked on a coastal highway at sunset".
Include Style Keywords
Add style modifiers like "photorealistic", "oil painting", "anime style", "3D render", etc.
Describe Lighting and Mood
"Golden hour lighting", "dramatic shadows", "soft diffused light", "neon glow" can dramatically change results.
Specify Camera Details
For photorealistic images, try "shot on Canon 5D", "35mm lens", "shallow depth of field", "bokeh background".
Aspect Ratios
Choose the right aspect ratio for your use case:
| Ratio | Orientation | Best For |
|---|---|---|
1:1 | Square | Social media posts, profile pictures |
16:9 | Landscape | YouTube thumbnails, presentations |
9:16 | Portrait | Instagram/TikTok stories, mobile wallpapers |
4:3 | Landscape | Traditional photos |
3:4 | Portrait | Portrait photos |
21:9 | Ultra-wide | Cinematic, banners |