Gemini Generate
Generate images from text prompts using Google's Gemini 2.0 Flash model.
POST
/api/v1/models/gemini/generateGenerate an image from a text prompt
Model
Gemini 2.0 Flash
Cost
5 credits/image
Avg. Time
3-5 seconds
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
"text">-purple-600">curl "text-blue-600">-X POST https://vydra.app/api/v1/models/gemini/generate \
"text-blue-600">-H "Authorization: Bearer YOUR_API_KEY" \
"text-blue-600">-H "Content">-Type: application/json" \
"text-blue-600">-d '{
"prompt": "A cozy cabin in the mountains during winter, snow falling gently, warm light from windows, photorealistic",
"aspectRatio": "16:9"
}'Response
200 OKjson
{
"imageUrl": "https://pub-xxx.r2.dev/generated/gemini/org_123/1706234400000.png",
"mimeType": "image/png",
"creditsCharged": 5,
"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 5) |
durationMs | number | Generation time in milliseconds |
Error Responses
Missing Prompt (400)
{
"error": "Missing required field: prompt (string)"
}Insufficient Credits (402)
{
"error": "Insufficient credits",
"creditsRequired": 5,
"creditsRemaining": 2
}Generation Failed (500)
{
"error": "Failed to generate image",
"message": "Content policy violation"
}Auto-Refund
If generation fails after credits are deducted, they are automatically refunded.
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 |