Gemini

Parameter reference for the Gemini model class, covering Google AI Studio and Vertex AI configuration.

The Gemini model provides access to Google's Gemini models.

Parameters

ParameterTypeDefaultDescription
idstr"gemini-3.7-flash"The id of the Gemini model to use
namestr"Gemini"The name of the model
providerstr"Google"The provider of the model
function_declarationsOptional[List[Any]]NoneDeclared but currently unused. Pass functions through the Agent's tools list.
generation_configOptional[Any]NoneInitial configuration; overlapping individual fields override its values, including with None.
safety_settingsOptional[List[Any]]NoneSafety settings to filter content
generative_model_kwargsOptional[Dict[str, Any]]NoneMerged into the initial configuration before individual fields override overlapping keys.
searchboolFalseAdd the Google Search tool so the model can search the web
groundingboolFalseLegacy Google Search retrieval configuration; prefer search=True for current supported models.
grounding_dynamic_thresholdOptional[float]NoneLegacy dynamic retrieval threshold; support depends on the provider model.
url_contextboolFalseAdd the URL context tool so the model can read URLs from the prompt
vertexai_searchboolFalseEnable retrieval from a Vertex AI Search datastore
vertexai_search_datastoreOptional[str]NoneResource name of the Vertex AI Search datastore. Required when vertexai_search is True
parallel_searchboolFalseEnable Parallel web search; requires explicit vertexai=True and cannot combine with search or grounding.
parallel_api_keyOptional[str]NoneAPI key for Parallel web search
parallel_configOptional[Dict[str, Any]]NoneCustom configuration for Parallel search, passed as custom_configs (e.g. domain filtering)
file_search_store_namesOptional[List[str]]NoneGemini File Search store names to search
file_search_metadata_filterOptional[str]NoneMetadata filter applied to File Search results
temperatureOptional[float]NoneControls randomness in the model's output
top_pOptional[float]NoneControls diversity via nucleus sampling
top_kOptional[int]NoneControls diversity via top-k sampling
max_output_tokensOptional[int]NoneMaximum number of tokens to generate
stop_sequencesOptional[List[str]]NoneSequences where the model stops generating further tokens
logprobsOptional[bool]NoneWhether to return log probabilities of the output tokens
presence_penaltyOptional[float]NonePenalizes new tokens based on whether they appear in the text so far
frequency_penaltyOptional[float]NonePenalizes new tokens based on their frequency in the text so far
seedOptional[int]NoneRandom seed for deterministic sampling
response_modalitiesOptional[List[str]]NoneOutput modalities to request: "TEXT", "IMAGE", and/or "AUDIO"
speech_configOptional[Dict[str, Any]]NoneSpeech generation configuration for audio output
cached_contentOptional[Any]NoneCached content identifier for context caching
thinking_budgetOptional[int]NoneThinking token budget for Gemini 2.5 models
include_thoughtsOptional[bool]NoneInclude thought summaries in the response
thinking_levelOptional[str]NoneModel-dependent thinking level. Gemini 3.7 Flash accepts "low", "medium", or "high"
request_paramsOptional[Dict[str, Any]]NoneAdditional parameters to include in the request
timeoutOptional[float]NoneRequest timeout in seconds
collect_metrics_on_completionboolTrueCollect token metrics only on the final streaming chunk. Gemini reports cumulative counts per chunk
credentialsOptional[Credentials]NoneGoogle Cloud credentials for Vertex AI
api_keyOptional[str]NoneThe API key for Google AI (defaults to GOOGLE_API_KEY env var)
vertexaiboolFalseUse the Vertex AI API. Also enabled when the GOOGLE_GENAI_USE_VERTEXAI env var is "true"
project_idOptional[str]NoneGoogle Cloud project ID for Vertex AI. Falls back to the GOOGLE_CLOUD_PROJECT env var
locationOptional[str]NoneGoogle Cloud location for Vertex AI. Falls back to the GOOGLE_CLOUD_LOCATION env var
client_paramsOptional[Dict[str, Any]]NoneAdditional parameters for client configuration
clientOptional[GeminiClient]NoneA pre-configured instance of the Gemini client
model_typeModelTypeModelType.MODELFunctional role of this model (e.g. MODEL, OUTPUT_MODEL, PARSER_MODEL). Set by the agent during initialization
supports_native_structured_outputsboolTrueTrue if the model supports structured outputs natively
supports_json_schema_outputsboolFalseTrue if the model requires a JSON schema for structured outputs
system_promptOptional[str]NoneSystem prompt from the model added to the Agent
instructionsOptional[List[str]]NoneInstructions from the model added to the Agent
tool_message_rolestr"tool"Role used for tool messages
assistant_message_rolestr"assistant"Role used for assistant messages
cache_responseboolFalseCache model responses to avoid redundant API calls during development
cache_ttlOptional[int]NoneTime-to-live for cached model responses, in seconds. If None, cache never expires
cache_dirOptional[str]NoneDirectory for cached model responses. If None, uses the default cache location
retriesint0Number of retries to attempt before raising a ModelProviderError
delay_between_retriesint1Delay between retries, in seconds
exponential_backoffboolFalseIf True, the delay between retries is doubled each time
retry_with_guidanceboolTrueRetry the model invocation with a guidance message for known errors avoidable with extra instructions
retry_with_guidance_limitint1Number of times to retry the model invocation with guidance

For sampling settings, use individual fields such as temperature=0.25. A temperature supplied only inside generation_config or generative_model_kwargs is overwritten by the top-level default None and omitted. To replace the final configuration explicitly, pass request_params={"config": GenerateContentConfig(...)} using google.genai.types.GenerateContentConfig; that replacement must include any tools or other configuration you need.