Endpoint
YOUR_GEMINI_MODEL with an available model ID; do not add another models/ prefix.
Authentication
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
SetVIVI_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: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
Streaming
Use streamGenerateContent with the alt=sse query parameter: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.