Skip to main content

Endpoint

The model ID belongs in the URL. Replace YOUR_GEMINI_MODEL with an available model ID; do not add another models/ prefix.

Authentication

Use your ViVi-API key.

Request parameters

Gemini uses contents and parts, and its assistant role is model. Do not send an OpenAI messages body to this endpoint.

Request examples

Set VIVI_API_KEY to your ViVi-API key in your shell environment. See Quickstart to create a key. Install requests with python -m pip install requests. cURL uses Bash syntax.

Response

Illustrative response:
Read all text parts from candidates[].content.parts, not just the first part. Inspect finishReason for completion or blocking; common values include STOP and MAX_TOKENS. If there are no candidates, check promptFeedback. Usage is reported in usageMetadata; fields vary by model.

System instructions and multi-turn conversations

For ordinary text conversations, include history in order. Preserve complete content blocks when using tools, thought signatures, or multimodal features. Saving only displayed text may omit required data.

Streaming

Use streamGenerateContent with the alt=sse query parameter:
Parse the JSON in each SSE data event. Read candidates[].content.parts rather than OpenAI delta fields. Do not rely on an OpenAI-style [DONE] marker.

Integration notes

  • Use /v1beta/models/..., not /v1/v1beta/....
  • Keep the model in the URL and generation settings in the JSON body.
  • Images, files, and tool use depend on model and channel support.
  • Read the HTTP status and error body; see troubleshooting.
Protocol reference: Google Gemini generateContent. Availability and optional features depend on ViVi-API support.