---
agent:
  instructions: "Search the site by keyword or question. The search API returns Markdown."
  endpoint: "https://platform.invideo.io/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Gemini media

> Generate images, speech and video with the Google GenAI SDK: generateContent, predict and predictLongRunning through the Gemini endpoints.

The [Gemini endpoints](/docs/chat/gemini) also run media models.

Base URL:

```text
https://platform-api.invideo.io
```

```python
from google import genai
from google.genai import types
import os, base64

client = genai.Client(api_key=os.environ["INVIDEO_API_KEY"], http_options={"base_url": "https://platform-api.invideo.io", "api_version": "v1beta"})

response = client.models.generate_content(
    model="gemini-2.5-flash-image",
    contents="A red fox in fresh snow",
    config=types.GenerateContentConfig(response_modalities=["IMAGE"], image_config=types.ImageConfig(aspect_ratio="16:9")),
)
image = response.candidates[0].content.parts[0].inline_data.data
```

- `generateContent` and `streamGenerateContent` run image and speech models and answer `inlineData` parts.
- `predict` runs image models in Imagen's shape (`predictions[].bytesBase64Encoded`).
- `predictLongRunning` runs video models (Veo); read the operation with `GET /v1beta/models/{model}/operations/{id}` until `done`. The video is `response.generateVideoResponse.generatedSamples[0].video.uri`.
- `candidateCount` and `sampleCount` must be 1.
