ReqLLM.Providers.GoogleVertex.Gemini (ReqLLM v1.12.0)

View Source

Gemini model family support for Google Vertex AI.

Handles Gemini models (gemini-2.5-flash, gemini-2.5-pro, etc.) on Google Vertex AI.

This module acts as a thin adapter between Vertex AI's GCP infrastructure and Google's native Gemini format. It delegates to the native Google provider for all format conversion, with one critical difference: Vertex AI Gemini API is stricter and requires sanitizing function call IDs.

Critical Quirks

Vertex AI Gemini has stricter validation than the direct Google API:

  1. Rejects the "id" field in functionCall parts - we strip these IDs

Features

  • Extended thinking/reasoning via google_thinking_budget
  • Context caching (90% discount on cached tokens!)
  • Google Search grounding via google_grounding: %{enable: true}
  • All standard Gemini options (safety settings, etc.)

Summary

Functions

Decodes Server-Sent Events for streaming responses.

Extracts usage information from Gemini response.

Formats a ReqLLM context into Gemini request format for Vertex AI.

Parses a Gemini response from Vertex AI into ReqLLM format.

Functions

decode_stream_event(event, model)

Decodes Server-Sent Events for streaming responses.

Gemini uses the same SSE format as the native Google provider.

extract_usage(body, model)

Extracts usage information from Gemini response.

Gemini responses include usageMetadata with token counts including cached tokens.

format_request(model_id, context, opts)

Formats a ReqLLM context into Gemini request format for Vertex AI.

Delegates to the native Google provider's encoding logic, then applies shared tool call ID compatibility policy.

parse_response(body, model, opts)

Parses a Gemini response from Vertex AI into ReqLLM format.

Delegates to the native Google provider's response parsing logic.