Gemini Generate

Generate images from text prompts using Google's Gemini 2.0 Flash model.

POST
/api/v1/models/gemini/generate

Generate an image from a text prompt

Model
Gemini 2.0 Flash
Cost
5 credits/image
Avg. Time
3-5 seconds

Request Body

NameTypeDescription
promptrequiredstringText description of the image to generate
aspectRatiostringDefault: 1:1Output 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

NameTypeDescription
imageUrlstringPublic URL of the generated image
mimeTypestringImage MIME type (image/png)
creditsChargednumberCredits deducted (always 5)
durationMsnumberGeneration 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:

RatioOrientationBest For
1:1SquareSocial media posts, profile pictures
16:9LandscapeYouTube thumbnails, presentations
9:16PortraitInstagram/TikTok stories, mobile wallpapers
4:3LandscapeTraditional photos
3:4PortraitPortrait photos
21:9Ultra-wideCinematic, banners