Skip to main content
POST
Chat Completions Gemini
Product: Visual Intelligence — Video Model APIs (atomic) Use case: Call a Video Language Model (Gemini / Nova / Qwen) directly with your own prompt. Full control over model selection, prompt, and parameters. For ready-made tasks (no prompt needed), see Video Task APIs. Host: https://mavi-backend.memories.ai/serve/api/v2 Auth: Authorization: sk-mavi-... (no Bearer prefix)
This endpoint allows you to generate chat completions with text, video, and image inputs using Gemini VLM model.
Endpoint: POST https://mavi-backend.memories.ai/serve/api/v2/vu/chat/completionsVideo Understanding (VLM) endpoints use the /vu path prefix. Image Understanding (ILM) endpoints use /iu instead.

Supported Models

All models require the gemini: prefix when used in the model parameter (e.g., gemini:gemini-2.5-flash).

Premium Models

Flash Models (High Performance)

Lite Models (Cost-Effective)

When using these models, remember to include the gemini: prefix in your API calls:
  • ✅ Correct: "model": "gemini:gemini-2.5-flash"
  • ❌ Incorrect: "model": "gemini-2.5-flash"

Request Body

Code Example

Response

Returns the chat completion response with structured output.

Response Parameters

Error Responses

Upstream errors are returned with HTTP 200 — not a 4xx/5xx. Check status and look for a top-level error object before parsing choices.
Callers should always verify status == "completed" (or that choices is non-empty) before reading choices[0].text.

Gemini structured-output quirks

Two real behaviours to handle when you use extra_body.metadata.response_mime_type = "application/json":
  1. Gemini frequently wraps its JSON output in ```json ... ``` markdown code fences. Strip them before json.loads.
  2. On long videos with a strict schema, Gemini occasionally loops — emitting the same set of entries repeatedly until it hits max_tokens and the JSON is left unclosed. Tolerate this by closing the array at the last complete } and deduplicating client-side.
See examples/agent/02_restaurant_service_quality.py (extract_json and _dedup_events) for a worked example.

Authorizations

Authorization
string
header
required

Body

application/json
model
string
required

The model to use (e.g., gemini:gemini-2.5-flash)

Example:

"gemini:gemini-2.5-flash"

messages
object[]
required

Array of message objects

temperature
number
default:0.7

Controls randomness: 0.0-2.0, higher = more random

Required range: 0 <= x <= 2
max_tokens
integer
default:1000

Maximum number of tokens to generate

top_p
number
default:1

Nucleus sampling: 0.0-1.0

Required range: 0 <= x <= 1
frequency_penalty
number
default:0

Reduces repetition of frequent tokens: -2.0 to 2.0

Required range: -2 <= x <= 2
presence_penalty
number
default:0

Increases likelihood of new topics: -2.0 to 2.0

Required range: -2 <= x <= 2
n
integer
default:1

Number of completions to generate

stream
boolean
default:false

Whether to stream the response

stop

Stop sequences

extra_body
object

Response

200 - application/json

Chat completion response

id
string
required

Unique identifier for the completion

Example:

"resp_5810813e-99b9-427a-8736-23cf34573627"

object
string
required

Object type, always 'completion'

Example:

"completion"

model
string
required

The model used for the completion

Example:

"gemini:gemini-2.5-flash"

created_at
integer
required

Unix timestamp of when the completion was created

Example:

1767093284

status
string
required

Status of the completion

Example:

"completed"

choices
object[]
required
usage
object
required
meta
object
required