Gemini 3.8 Flash Video Agent Serverless API

Find any moment in long videos or YouTube with timestamps.

API Format: Google Gemini

This model uses Google Gemini request/response format.

POST /v2/gemini-3.8-flash-video-agent · submit + poll
 1# pip install "segmind>=1.1.0"
 2# export SEGMIND_API_KEY="YOUR_API_KEY"
 3import segmind
 4
 5payload = {
 6    "messages": {
 7        "system_instruction": {
 8            "parts": {
 9                "text": "You are a helpful assistant."
10            }
11        },
12        "contents": [
13            {
14                "role": "user",
15                "parts": [
16                    {
17                        "text": "Summarise this video in three sentences."
18                    },
19                    {
20                        "fileData": {
21                            "fileUri": "https://example.com/clip.mp4",
22                            "mimeType": "video/mp4"
23                        }
24                    }
25                ]
26            }
27        ]
28    },
29    "effort": "high"
30}
31
32# Async chat (v2): submit to the queue, block until COMPLETED.
33reply = segmind.chat("gemini-3.8-flash-video-agent", **payload)
34print(reply.text)
35
36# --- Or get a handle (track request_id, control the poll cadence) ---
37job = segmind.submit_chat("gemini-3.8-flash-video-agent", **payload)
38print(job.request_id)                         # available immediately
39reply = job.wait(timeout=600)
40print(reply.text)

API Endpoint

POST https://api.segmind.com/v1/gemini-3.8-flash-video-agent

Parameters

messagesrequired
object[]

Object containing contents array with role and parts.

Array items:
rolerequired
string

Role of the message sender

Allowed values :
"user""model"
contentrequired
array

Array of parts (text or inlineData)

messages.system_instructionoptional
object

System instruction with parts containing text to guide model behavior.

partsoptional
object
textrequired
string

System instruction text

effortoptional
string

How hard the model reasons while it searches the video; medium or high. Use high for long videos or precise moments. Reasoning is billed as output tokens.

Default: "high"
Allowed values :
"medium""high"

Response Format

{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "text": "I can see a beautiful sunset over the ocean with vibrant orange and pink hues in the sky."
          }
        ],
        "role": "model"
      },
      "finishReason": "STOP",
      "index": 0,
      "safetyRatings": []
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 56,
    "candidatesTokenCount": 31,
    "totalTokenCount": 87
  }
}

Video Input

Send a file as a URL and the API fetches it for the model: files up to 14MB are inlined, larger ones (up to 2GB) go through the Gemini Files API, and a YouTube link is passed straight through. Two ways to attach:

  • Inside messages: a fileData part with fileUri and mimeType (shown in the examples above), or a base64 inlineData part.
  • Beside a flat prompt: files (a list of URLs, any mix), video, each taking a URL, a data URI, or a list of them.

Media is billed as input tokens by length: roughly 100 tokens per second of video, 32 per second of audio, and 258 per PDF page. An unsupported file type is refused with a 400 before anything is fetched.

Asynchronous requests (v2)

Use Async for video, long-running (>~60s), or high-concurrency workloads; Sync is simplest for fast image & LLM calls. Async submits a request and you poll it to completion.

  1. 1
    POST /v2/gemini-3.8-flash-video-agent

    Submit — returns request_id, status_url, response_url

  2. 2
    GET /v2/requests/{id}/status

    Poll — until COMPLETED or FAILED

  3. 3
    GET /v2/requests/{id}

    Result — final response body

Status states

QUEUED— Accepted, waiting for a worker
PROCESSING— Running on a worker
COMPLETED— Done — result body is ready
FAILED— Errored (incl. content/RAI blocks)
  • A FAILED request is served as HTTP 422 — the body still carries the error detail.
  • An unknown or expired request_id returns HTTP 404.
  • Results are retained for 1 hour, then expire.
  • Content / RAI blocks surface as FAILED, not a separate state.
  • Track completion by polling the status endpoint.

Common Error Codes

The API returns standard HTTP status codes. Detailed error messages are provided in the response body.

400

Bad Request

Invalid message format or parameters

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Model or endpoint not found

406

Insufficient Credits

Not enough credits to process request

429

Rate Limited

Too many requests

500

Server Error

Internal server error

502

Bad Gateway

Service temporarily unavailable

504

Timeout

Request timed out