Submodules¶
genai.client module¶
- class genai.client.AsyncClient(api_client)¶
Bases:
objectClient for making asynchronous (non-blocking) requests.
- async aclose()¶
Closes the async client explicitly.
However, it doesn’t close the sync client, which can be closed using the Client.close() method or using the context manager.
Usage: .. code-block:: python
from google.genai import Client
- async_client = Client(
enterprise=True, project=’my-project-id’, location=’us-central1’
).aio response_1 = await async_client.models.generate_content(
model=’gemini-flash-latest’, contents=’Hello World’,
) response_2 = await async_client.models.generate_content(
model=’gemini-flash-latest’, contents=’Hello World’,
) # Close the client to release resources. await async_client.aclose()
- Return type:
None
- property agents: AsyncGeminiNextGenAgents¶
- property auth_tokens: AsyncTokens¶
- property batches: AsyncBatches¶
- property caches: AsyncCaches¶
- property chats: AsyncChats¶
- property credentials: AsyncGeminiNextGenCredentials¶
Credentials resource.
- property environments: AsyncGeminiNextGenEnvironments¶
Environments resource.
- property file_search_stores: AsyncFileSearchStores¶
- property files: AsyncFiles¶
- property interactions: AsyncGeminiNextGenInteractions¶
- property models: AsyncModels¶
- property operations: AsyncOperations¶
- property triggers: AsyncGeminiNextGenTriggers¶
- property tunings: AsyncTunings¶
- property voices: AsyncGeminiNextGenVoices¶
Voices resource.
- property webhooks: AsyncGeminiNextGenWebhooks¶
- class genai.client.Client(*, enterprise=None, vertexai=None, api_key=None, credentials=None, project=None, location=None, debug_config=None, http_options=None)¶
Bases:
objectClient for making synchronous requests.
Use this client to make a request to the Gemini Developer API or Gemini Enterprise Agent Platform (previously Vertex AI API) and then wait for the response.
To initialize the client, provide the required arguments either directly or by using environment variables. Gemini API users and Vertex AI users in api_key=”your-api-key” or by defining GOOGLE_API_KEY=”your-api-key” as an environment variable
Gemini Enterprise Agent Platform API users can provide inputs argument as enterprise=True, project=”your-project-id”, location=”us-central1” or by defining GOOGLE_GENAI_USE_ENTERPRISE=true, GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION environment variables.
- enterprise¶
Indicates whether the client should use the Gemini Enterprise Agent Platform endpoints (previously Vertex AI API). Defaults to False (uses Gemini Developer API endpoints). When enterprise and vertexai are both set, and they have conflicting values, a ValueError will be raised.
- Type:
bool
- vertexai¶
Legacy flag for enterprise.
- Type:
bool
- credentials¶
The credentials to use for authentication when calling the Gemini Enterprise Agent Platform APIs. Credentials can be obtained from environment variables and default credentials. For more information, see Set up Application Default Credentials. Applies to the Vertex AI API only.
- project¶
The Google Cloud project ID to use for quota. Can be obtained from environment variables (for example,
GOOGLE_CLOUD_PROJECT). Applies to the Vertex AI API only. Find your Google Cloud project ID.
- location¶
The location to send API requests to (for example,
us-central1). Can be obtained from environment variables. Applies to the Vertex AI API only.
- debug_config¶
Config settings that control network behavior of the client. This is typically used when running test code.
- http_options¶
Http options to use for the client. These options will be applied to all requests made by the client. Example usage: client = genai.Client(http_options=types.HttpOptions(api_version=’v1’)).
Usage for the Gemini Developer API:
from google import genai client = genai.Client(api_key='my-api-key')
Usage for the Gemini Enterprise Agent Platform API:
from google import genai client = genai.Client( enterprise=True, project='my-project-id', location='us-central1' )
Initializes the client.
- Parameters:
enterprise (bool) – Indicates whether the client should use the Gemini Enterprise Agent Platform endpoints (previously Vertex AI API). Defaults to False (uses Gemini Developer API endpoints). When enterprise and vertexai are both set, and they have conflicting values, a ValueError will be raised.
vertexai (bool) – Legacy flag for enterprise.
api_key (str) –
The API key to use for authentication. Applies to the Gemini Developer API only.
credentials (google.auth.credentials.Credentials) –
The credentials to use for authentication when calling the Vertex AI APIs. Credentials can be obtained from environment variables and default credentials. For more information, see Set up Application Default Credentials. Applies to the Vertex AI API only.
project (str) –
The Google Cloud project ID to use for quota. Can be obtained from environment variables (for example,
GOOGLE_CLOUD_PROJECT). Applies to the Vertex AI API only.location (str) –
The location to send API requests to (for example,
us-central1). Can be obtained from environment variables. Applies to the Vertex AI API only.debug_config (DebugConfig) – Config settings that control network behavior of the client. This is typically used when running test code.
http_options (Union[HttpOptions, HttpOptionsDict]) – Http options to use for the client.
- property agents: GeminiNextGenAgents¶
- property aio: AsyncClient¶
- property batches: Batches¶
- property caches: Caches¶
- property chats: Chats¶
- close()¶
Closes the synchronous client explicitly.
However, it doesn’t close the async client, which can be closed using the Client.aio.aclose() method or using the async context manager.
Usage: .. code-block:: python
from google.genai import Client
- client = Client(
enterprise=True, project=’my-project-id’, location=’us-central1’
) response_1 = client.models.generate_content(
model=’gemini-flash-latest’, contents=’Hello World’,
) response_2 = client.models.generate_content(
model=’gemini-flash-latest’, contents=’Hello World’,
) # Close the client to release resources. client.close()
- Return type:
None
- property credentials: GeminiNextGenCredentials¶
- property environments: GeminiNextGenEnvironments¶
- property file_search_stores: FileSearchStores¶
- property files: Files¶
- property interactions: GeminiNextGenInteractions¶
- property operations: Operations¶
- property triggers: GeminiNextGenTriggers¶
- property vertexai: bool¶
Returns whether the client is using the Vertex AI API.
- property voices: GeminiNextGenVoices¶
- property webhooks: GeminiNextGenWebhooks¶
- class genai.client.DebugConfig(**data)¶
Bases:
BaseModelConfiguration options that change client network behavior when testing.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- client_mode: str | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- replay_id: str | None¶
- replays_directory: str | None¶
GAOS Client Resources¶
The following resource classes are returned by the client properties
client.interactions, client.agents, client.webhooks,
client.triggers, and client.environments.
- class genai._gaos.google_genai.GeminiNextGenInteractions(api_client)¶
Bases:
InteractionsPublic interactions resource backed by the NextGen client.
Subclasses the generated resource so newly generated methods (and the raw/streaming response wrappers) are exposed automatically. Only the methods that need legacy input/output normalization are overridden.
Each override sits inside if not TYPE_CHECKING: so static type checkers see the inherited generated signature (full overload sets) rather than the runtime stub here.
- cancel(id, *, api_version=None, extra_headers=None, extra_query=None, timeout=None)¶
Cancels an interaction by id. This only applies to background interactions that are still running.
- Parameters:
id (
str) – Required. The name of the interaction to cancel.api_version (
Optional[str]) – API version for request routing.extra_headers (
Optional[Mapping[str,str]]) – Additional headers to set or replace on requests.extra_query (
Optional[Mapping[str,Any]]) – Additional query parameters to append to requests.timeout (
Union[float,Timeout,None]) – Override the default request timeout configuration for this method in seconds
- Return type:
Interaction
- create(*, request=None, api_version=None, extra_headers=None, extra_query=None, extra_body=None, timeout=None, **body)¶
Creates a new interaction.
- Parameters:
api_version (
Optional[str]) – API version for request routing.background – Input only. Whether to run the model interaction in the background.
cached_content – The name of the cached content used as context to serve the prediction. Note: only used in explicit caching, where users can have control over caching (e.g. what content to cache) and enjoy guaranteed cost savings. Format: cachedContents/{cachedContent}
environment – The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID.
generation_config – Configuration parameters for model interactions.
input – The input for the interaction.
labels –
The labels with user-defined metadata for the request.
Label keys and values can be no longer than 63 characters (Unicode codepoints) and can only contain lowercase letters, numeric characters, underscores, and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter.
model – The model that will complete your prompt.nnSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details.
previous_interaction_id – The ID of the previous interaction, if any.
response_format – Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field.
response_mime_type – The mime type of the response. This is required if response_format is set.
response_modalities – The requested modalities of the response (TEXT, IMAGE, AUDIO).
safety_settings – Safety settings for the interaction.
service_tier
store – Input only. Whether to store the response and request for later retrieval.
stream – Input only. Whether the interaction will be streamed.
system_instruction – System instruction for the interaction.
tools – A list of tool declarations the model may call during interaction.
webhook_config – Message for configuring webhook events for a request.
agent – The agent to interact with.
agent_config – Configuration parameters for the agent interaction.
extra_headers (
Optional[Mapping[str,str]]) – Additional headers to set or replace on requests.extra_query (
Optional[Mapping[str,Any]]) – Additional query parameters to append to requests.extra_body (
Optional[Mapping[str,Any]]) – Additional JSON object fields to merge into request bodies.timeout (
Union[float,Timeout,None]) – Override the default request timeout configuration for this method in seconds
- Return type:
Union[Interaction,Stream[Union[ErrorEvent,InteractionCompletedEvent,InteractionCreatedEvent,InteractionStatusUpdate,StepDelta,StepStart,StepStop,UnknownInteractionSSEEvent]]]
- delete(id, *, api_version=None, extra_headers=None, extra_query=None, timeout=None)¶
Deletes the interaction by id.
- Parameters:
id (
str) – Required. The name of the interaction to delete.api_version (
Optional[str]) – API version for request routing.extra_headers (
Optional[Mapping[str,str]]) – Additional headers to set or replace on requests.extra_query (
Optional[Mapping[str,Any]]) – Additional query parameters to append to requests.timeout (
Union[float,Timeout,None]) – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- get(id, *, api_version=None, include_input=None, last_event_id=None, stream=False, extra_headers=None, extra_query=None, timeout=None)¶
Retrieves the full details of a single interaction based on its Interaction.id.
- Parameters:
id (
str) – Required. The name of the interaction to retrieve.api_version (
Optional[str]) – API version for request routing.include_input (
Any) – If true, includes the input in the response.last_event_id (
Any) – If set, resumes the interaction stream from the chunk after the event marked by the event id. Can only be used if stream is true.stream (
Any) – If true, streams the interaction events as Server-Sent Events.extra_headers (
Optional[Mapping[str,str]]) – Additional headers to set or replace on requests.extra_query (
Optional[Mapping[str,Any]]) – Additional query parameters to append to requests.timeout (
Union[float,Timeout,None]) – Override the default request timeout configuration for this method in seconds
- Return type:
Union[Interaction,Stream[Union[ErrorEvent,InteractionCompletedEvent,InteractionCreatedEvent,InteractionStatusUpdate,StepDelta,StepStart,StepStop,UnknownInteractionSSEEvent]]]
- property with_raw_response¶
- property with_streaming_response¶
- class genai._gaos.google_genai.AsyncGeminiNextGenInteractions(api_client)¶
Bases:
AsyncInteractionsAsync public interactions resource backed by the NextGen client.
- async cancel(id, *, api_version=None, extra_headers=None, extra_query=None, timeout=None)¶
Cancels an interaction by id. This only applies to background interactions that are still running.
- Parameters:
id (
str) – Required. The name of the interaction to cancel.api_version (
Optional[str]) – API version for request routing.extra_headers (
Optional[Mapping[str,str]]) – Additional headers to set or replace on requests.extra_query (
Optional[Mapping[str,Any]]) – Additional query parameters to append to requests.timeout (
Union[float,Timeout,None]) – Override the default request timeout configuration for this method in seconds
- Return type:
Interaction
- async create(*, request=None, api_version=None, extra_headers=None, extra_query=None, extra_body=None, timeout=None, **body)¶
Creates a new interaction.
- Parameters:
api_version (
Optional[str]) – API version for request routing.background – Input only. Whether to run the model interaction in the background.
cached_content – The name of the cached content used as context to serve the prediction. Note: only used in explicit caching, where users can have control over caching (e.g. what content to cache) and enjoy guaranteed cost savings. Format: cachedContents/{cachedContent}
environment – The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID.
generation_config – Configuration parameters for model interactions.
input – The input for the interaction.
labels –
The labels with user-defined metadata for the request.
Label keys and values can be no longer than 63 characters (Unicode codepoints) and can only contain lowercase letters, numeric characters, underscores, and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter.
model – The model that will complete your prompt.nnSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details.
previous_interaction_id – The ID of the previous interaction, if any.
response_format – Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field.
response_mime_type – The mime type of the response. This is required if response_format is set.
response_modalities – The requested modalities of the response (TEXT, IMAGE, AUDIO).
safety_settings – Safety settings for the interaction.
service_tier
store – Input only. Whether to store the response and request for later retrieval.
stream – Input only. Whether the interaction will be streamed.
system_instruction – System instruction for the interaction.
tools – A list of tool declarations the model may call during interaction.
webhook_config – Message for configuring webhook events for a request.
agent – The agent to interact with.
agent_config – Configuration parameters for the agent interaction.
extra_headers (
Optional[Mapping[str,str]]) – Additional headers to set or replace on requests.extra_query (
Optional[Mapping[str,Any]]) – Additional query parameters to append to requests.extra_body (
Optional[Mapping[str,Any]]) – Additional JSON object fields to merge into request bodies.timeout (
Union[float,Timeout,None]) – Override the default request timeout configuration for this method in seconds
- Return type:
Union[Interaction,AsyncStream[Union[ErrorEvent,InteractionCompletedEvent,InteractionCreatedEvent,InteractionStatusUpdate,StepDelta,StepStart,StepStop,UnknownInteractionSSEEvent]]]
- async delete(id, *, api_version=None, extra_headers=None, extra_query=None, timeout=None)¶
Deletes the interaction by id.
- Parameters:
id (
str) – Required. The name of the interaction to delete.api_version (
Optional[str]) – API version for request routing.extra_headers (
Optional[Mapping[str,str]]) – Additional headers to set or replace on requests.extra_query (
Optional[Mapping[str,Any]]) – Additional query parameters to append to requests.timeout (
Union[float,Timeout,None]) – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- async get(id, *, api_version=None, include_input=None, last_event_id=None, stream=False, extra_headers=None, extra_query=None, timeout=None)¶
Retrieves the full details of a single interaction based on its Interaction.id.
- Parameters:
id (
str) – Required. The name of the interaction to retrieve.api_version (
Optional[str]) – API version for request routing.include_input (
Any) – If true, includes the input in the response.last_event_id (
Any) – If set, resumes the interaction stream from the chunk after the event marked by the event id. Can only be used if stream is true.stream (
Any) – If true, streams the interaction events as Server-Sent Events.extra_headers (
Optional[Mapping[str,str]]) – Additional headers to set or replace on requests.extra_query (
Optional[Mapping[str,Any]]) – Additional query parameters to append to requests.timeout (
Union[float,Timeout,None]) – Override the default request timeout configuration for this method in seconds
- Return type:
Union[Interaction,AsyncStream[Union[ErrorEvent,InteractionCompletedEvent,InteractionCreatedEvent,InteractionStatusUpdate,StepDelta,StepStart,StepStop,UnknownInteractionSSEEvent]]]
- property with_raw_response¶
- property with_streaming_response¶
- class genai._gaos.google_genai.GeminiNextGenAgents(api_client)¶
Bases:
AgentsPublic agents resource backed by the NextGen client.
Subclasses the generated resource so every public method is wrapped in wrap_sdk_call, translating per-operation GenAiError raises into the status-code APIError hierarchy exposed at the google.genai._interactions import surface.
- create(*args, **kwargs)¶
Creates a new Agent (Typed version for SDK).
- Parameters:
api_version – API version for request routing.
agent_config – Configuration parameters for the agent.
base_agent – The base agent to extend.
base_environment – The environment configuration for the agent.
description – Agent description for developers to quickly read and understand.
id – The unique identifier for the agent.
system_instruction – System instruction for the agent.
tools – The tools available to the agent.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
extra_body – Additional JSON object fields to merge into request bodies.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- delete(*args, **kwargs)¶
Deletes an Agent.
- Parameters:
id – Required. The name of the agent to delete.
api_version – API version for request routing.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- get(*args, **kwargs)¶
Gets a specific Agent.
- Parameters:
id – Required. The name of the agent to retrieve.
api_version – API version for request routing.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- list(*args, **kwargs)¶
Lists all Agents.
- Parameters:
api_version – API version for request routing.
page_size
page_token
parent – Required. The parent resource to list agents from. Format: projects/{project}/locations/{location}
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- property with_raw_response¶
- property with_streaming_response¶
- class genai._gaos.google_genai.AsyncGeminiNextGenAgents(api_client)¶
Bases:
AsyncAgentsAsync public agents resource backed by the NextGen client.
- async create(*args, **kwargs)¶
Creates a new Agent (Typed version for SDK).
- Parameters:
api_version – API version for request routing.
agent_config – Configuration parameters for the agent.
base_agent – The base agent to extend.
base_environment – The environment configuration for the agent.
description – Agent description for developers to quickly read and understand.
id – The unique identifier for the agent.
system_instruction – System instruction for the agent.
tools – The tools available to the agent.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
extra_body – Additional JSON object fields to merge into request bodies.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- async delete(*args, **kwargs)¶
Deletes an Agent.
- Parameters:
id – Required. The name of the agent to delete.
api_version – API version for request routing.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- async get(*args, **kwargs)¶
Gets a specific Agent.
- Parameters:
id – Required. The name of the agent to retrieve.
api_version – API version for request routing.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- async list(*args, **kwargs)¶
Lists all Agents.
- Parameters:
api_version – API version for request routing.
page_size
page_token
parent – Required. The parent resource to list agents from. Format: projects/{project}/locations/{location}
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- property with_raw_response¶
- property with_streaming_response¶
- class genai._gaos.google_genai.GeminiNextGenWebhooks(api_client)¶
Bases:
WebhooksPublic webhooks resource backed by the NextGen client.
Subclasses the generated resource so every public method is wrapped in wrap_sdk_call, translating per-operation GenAiError raises into the status-code APIError hierarchy exposed at the google.genai._interactions import surface.
- create(*args, **kwargs)¶
Creates a new Webhook.
- Parameters:
subscribed_events – Required. The events that the webhook is subscribed to. Available events: - batch.succeeded - batch.expired - batch.failed - interaction.requires_action - interaction.completed - interaction.failed - video.generated
uri – Required. The URI to which webhook events will be sent.
api_version – API version for request routing.
name – Optional. The user-provided name of the webhook.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
extra_body – Additional JSON object fields to merge into request bodies.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- delete(*args, **kwargs)¶
Deletes a Webhook.
- Parameters:
id – Required. The ID of the webhook to delete.
api_version – API version for request routing.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- get(*args, **kwargs)¶
Gets a specific Webhook.
- Parameters:
id – Required. The ID of the webhook to retrieve.
api_version – API version for request routing.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- list(*args, **kwargs)¶
Lists all Webhooks.
- Parameters:
api_version – API version for request routing.
page_size – Optional. The maximum number of webhooks to return. The service may return fewer than this value. If unspecified, at most 50 webhooks will be returned. The maximum value is 1000.
page_token – Optional. A page token, received from a previous ListWebhooks call. Provide this to retrieve the subsequent page.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- ping(*args, **kwargs)¶
Sends a ping event to a Webhook.
- Parameters:
id – Required. The ID of the webhook to ping.
body – Required. The request body.
api_version – API version for request routing.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
extra_body – Additional JSON object fields to merge into request bodies.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- rotate_signing_secret(*args, **kwargs)¶
Generates a new signing secret for a Webhook.
- Parameters:
id – Required. The ID of the webhook for which to generate a signing secret.
api_version – API version for request routing.
revocation_behavior – Optional. The revocation behavior for previous signing secrets.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
extra_body – Additional JSON object fields to merge into request bodies.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- update(*args, **kwargs)¶
Updates an existing Webhook.
- Parameters:
id – Required. The ID of the webhook to update.
api_version – API version for request routing.
update_mask – Optional list of fields to update.
name – Optional. The user-provided name of the webhook.
state – Optional. The state of the webhook.
subscribed_events – Optional. The events that the webhook is subscribed to. Available events: - batch.succeeded - batch.expired - batch.failed - interaction.requires_action - interaction.completed - interaction.failed - video.generated
uri – Optional. The URI to which webhook events will be sent.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
extra_body – Additional JSON object fields to merge into request bodies.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- property with_raw_response¶
- property with_streaming_response¶
- class genai._gaos.google_genai.AsyncGeminiNextGenWebhooks(api_client)¶
Bases:
AsyncWebhooksAsync public webhooks resource backed by the NextGen client.
- async create(*args, **kwargs)¶
Creates a new Webhook.
- Parameters:
subscribed_events – Required. The events that the webhook is subscribed to. Available events: - batch.succeeded - batch.expired - batch.failed - interaction.requires_action - interaction.completed - interaction.failed - video.generated
uri – Required. The URI to which webhook events will be sent.
api_version – API version for request routing.
name – Optional. The user-provided name of the webhook.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
extra_body – Additional JSON object fields to merge into request bodies.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- async delete(*args, **kwargs)¶
Deletes a Webhook.
- Parameters:
id – Required. The ID of the webhook to delete.
api_version – API version for request routing.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- async get(*args, **kwargs)¶
Gets a specific Webhook.
- Parameters:
id – Required. The ID of the webhook to retrieve.
api_version – API version for request routing.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- async list(*args, **kwargs)¶
Lists all Webhooks.
- Parameters:
api_version – API version for request routing.
page_size – Optional. The maximum number of webhooks to return. The service may return fewer than this value. If unspecified, at most 50 webhooks will be returned. The maximum value is 1000.
page_token – Optional. A page token, received from a previous ListWebhooks call. Provide this to retrieve the subsequent page.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- async ping(*args, **kwargs)¶
Sends a ping event to a Webhook.
- Parameters:
id – Required. The ID of the webhook to ping.
body – Required. The request body.
api_version – API version for request routing.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
extra_body – Additional JSON object fields to merge into request bodies.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- async rotate_signing_secret(*args, **kwargs)¶
Generates a new signing secret for a Webhook.
- Parameters:
id – Required. The ID of the webhook for which to generate a signing secret.
api_version – API version for request routing.
revocation_behavior – Optional. The revocation behavior for previous signing secrets.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
extra_body – Additional JSON object fields to merge into request bodies.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- async update(*args, **kwargs)¶
Updates an existing Webhook.
- Parameters:
id – Required. The ID of the webhook to update.
api_version – API version for request routing.
update_mask – Optional list of fields to update.
name – Optional. The user-provided name of the webhook.
state – Optional. The state of the webhook.
subscribed_events – Optional. The events that the webhook is subscribed to. Available events: - batch.succeeded - batch.expired - batch.failed - interaction.requires_action - interaction.completed - interaction.failed - video.generated
uri – Optional. The URI to which webhook events will be sent.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
extra_body – Additional JSON object fields to merge into request bodies.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- property with_raw_response¶
- property with_streaming_response¶
- class genai._gaos.google_genai.GeminiNextGenTriggers(api_client)¶
Bases:
TriggersPublic triggers resource backed by the NextGen client.
Subclasses the generated resource so every public method is wrapped in wrap_sdk_call, translating per-operation GenAiError raises into the status-code APIError hierarchy exposed at the google.genai._interactions import surface.
- create(*args, **kwargs)¶
Creates a new trigger that will invoke the specified agent on the given cron schedule.
- Parameters:
interaction – Interaction for generating the completion using agents.
schedule – Required. The cron schedule on which the trigger should run. Standard cron format.
time_zone – Required. Time zone in which the schedule should be interpreted.
api_version – API version for request routing.
display_name – Optional. The display name of the trigger.
environment_id – Optional. The environment ID for the trigger execution.
execution_timeout_seconds – Optional. The execution timeout for the triggered interaction.
max_consecutive_failures – Optional. The maximum number of consecutive failures allowed before the trigger is automatically paused (status becomes ERROR).
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
extra_body – Additional JSON object fields to merge into request bodies.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- delete(*args, **kwargs)¶
Deletes a trigger.
- Parameters:
id – Required. Resource name of the trigger.
api_version – API version for request routing.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- get(*args, **kwargs)¶
Gets details of a single trigger.
- Parameters:
id – Required. Resource name of the trigger.
api_version – API version for request routing.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- list(*args, **kwargs)¶
Lists triggers for a project.
- Parameters:
api_version – API version for request routing.
filter – Optional. Filter expression (e.g., by state).
page_size – Optional. The maximum number of triggers to return per page.
page_token – Optional. A page token from a previous ListTriggers call.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- list_executions(*args, **kwargs)¶
Lists executions for a trigger.
- Parameters:
trigger_id – Required. The trigger ID to list executions from.
api_version – API version for request routing.
page_size – The maximum number of executions to return per page.
page_token – A page token from a previous ListTriggerExecutions call.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- run(*args, **kwargs)¶
Runs a trigger immediately.
- Parameters:
trigger_id – Required. Resource name of the trigger.
api_version – API version for request routing.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- update(*args, **kwargs)¶
Updates a trigger.
- Parameters:
id – Required. Resource name of the trigger.
api_version – API version for request routing.
display_name – Optional. The display name of the trigger.
status – Optional. The status of the trigger.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
extra_body – Additional JSON object fields to merge into request bodies.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- property with_raw_response¶
- property with_streaming_response¶
- class genai._gaos.google_genai.AsyncGeminiNextGenTriggers(api_client)¶
Bases:
AsyncTriggersAsync public triggers resource backed by the NextGen client.
- async create(*args, **kwargs)¶
Creates a new trigger that will invoke the specified agent on the given cron schedule.
- Parameters:
interaction – Interaction for generating the completion using agents.
schedule – Required. The cron schedule on which the trigger should run. Standard cron format.
time_zone – Required. Time zone in which the schedule should be interpreted.
api_version – API version for request routing.
display_name – Optional. The display name of the trigger.
environment_id – Optional. The environment ID for the trigger execution.
execution_timeout_seconds – Optional. The execution timeout for the triggered interaction.
max_consecutive_failures – Optional. The maximum number of consecutive failures allowed before the trigger is automatically paused (status becomes ERROR).
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
extra_body – Additional JSON object fields to merge into request bodies.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- async delete(*args, **kwargs)¶
Deletes a trigger.
- Parameters:
id – Required. Resource name of the trigger.
api_version – API version for request routing.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- async get(*args, **kwargs)¶
Gets details of a single trigger.
- Parameters:
id – Required. Resource name of the trigger.
api_version – API version for request routing.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- async list(*args, **kwargs)¶
Lists triggers for a project.
- Parameters:
api_version – API version for request routing.
filter – Optional. Filter expression (e.g., by state).
page_size – Optional. The maximum number of triggers to return per page.
page_token – Optional. A page token from a previous ListTriggers call.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- async list_executions(*args, **kwargs)¶
Lists executions for a trigger.
- Parameters:
trigger_id – Required. The trigger ID to list executions from.
api_version – API version for request routing.
page_size – The maximum number of executions to return per page.
page_token – A page token from a previous ListTriggerExecutions call.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- async run(*args, **kwargs)¶
Runs a trigger immediately.
- Parameters:
trigger_id – Required. Resource name of the trigger.
api_version – API version for request routing.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- async update(*args, **kwargs)¶
Updates a trigger.
- Parameters:
id – Required. Resource name of the trigger.
api_version – API version for request routing.
display_name – Optional. The display name of the trigger.
status – Optional. The status of the trigger.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
extra_body – Additional JSON object fields to merge into request bodies.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- property with_raw_response¶
- property with_streaming_response¶
- class genai._gaos.google_genai.GeminiNextGenEnvironments(api_client)¶
Bases:
EnvironmentsPublic environments resource backed by the NextGen client.
- create(*args, **kwargs)¶
- Return type:
Any
- create_environment(*args, **kwargs)¶
Creates an environment.
- Parameters:
api_version – API version for request routing.
from_environment – Optional. The source environment to copy/fork from. Format: environments/{environment_id} or {environment_id}. When specified, sources and env must be empty.
network – Network configuration for the environment.
sources – Sources to be mounted into the environment.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
extra_body – Additional JSON object fields to merge into request bodies.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- delete(*args, **kwargs)¶
- Return type:
Any
- delete_environment(*args, **kwargs)¶
Deletes an environment.
- Parameters:
id – Required. Resource ID segment making up resource name. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
api_version – API version for request routing.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- files: GeminiNextGenEnvironmentFiles¶
- get(*args, **kwargs)¶
- Return type:
Any
- get_environment(*args, **kwargs)¶
Gets an environment.
- Parameters:
id – Required. Resource ID segment making up resource name. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
api_version – API version for request routing.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- list(*args, **kwargs)¶
- Return type:
Any
- list_environments(*args, **kwargs)¶
Lists environments.
- Parameters:
api_version – API version for request routing.
page_size – Optional. Maximum number of environments to return. If unspecified, defaults to 50. Maximum is 1000.
page_token – Optional. Pagination token.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- property with_raw_response¶
- property with_streaming_response¶
- class genai._gaos.google_genai.AsyncGeminiNextGenEnvironments(api_client)¶
Bases:
AsyncEnvironmentsAsync public environments resource backed by the NextGen client.
- async create(*args, **kwargs)¶
- Return type:
Any
- async create_environment(*args, **kwargs)¶
Creates an environment.
- Parameters:
api_version – API version for request routing.
from_environment – Optional. The source environment to copy/fork from. Format: environments/{environment_id} or {environment_id}. When specified, sources and env must be empty.
network – Network configuration for the environment.
sources – Sources to be mounted into the environment.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
extra_body – Additional JSON object fields to merge into request bodies.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- async delete(*args, **kwargs)¶
- Return type:
Any
- async delete_environment(*args, **kwargs)¶
Deletes an environment.
- Parameters:
id – Required. Resource ID segment making up resource name. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
api_version – API version for request routing.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- files: AsyncGeminiNextGenEnvironmentFiles¶
- async get(*args, **kwargs)¶
- Return type:
Any
- async get_environment(*args, **kwargs)¶
Gets an environment.
- Parameters:
id – Required. Resource ID segment making up resource name. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
api_version – API version for request routing.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- async list(*args, **kwargs)¶
- Return type:
Any
- async list_environments(*args, **kwargs)¶
Lists environments.
- Parameters:
api_version – API version for request routing.
page_size – Optional. Maximum number of environments to return. If unspecified, defaults to 50. Maximum is 1000.
page_token – Optional. Pagination token.
extra_headers – Additional headers to set or replace on requests.
extra_query – Additional query parameters to append to requests.
timeout – Override the default request timeout configuration for this method in seconds
- Return type:
Any
- property with_raw_response¶
- property with_streaming_response¶
genai.live module¶
[Preview] Live API client.
- class genai.live.AsyncLive(api_client)¶
Bases:
BaseModule[Preview] AsyncLive.
- connect(*, model, config=None)¶
[Preview] Connect to the live server.
Note: the live API is currently in preview.
Usage:
client = genai.Client(api_key=API_KEY) config = {} async with client.aio.live.connect(model='...', config=config) as session: await session.send_client_content( turns=types.Content( role='user', parts=[types.Part(text='hello!')] ), turn_complete=True ) async for message in session.receive(): print(message)
- Return type:
AsyncIterator[AsyncSession]- Parameters:
model – The model to use for the live session.
config – The configuration for the live session.
**kwargs – additional keyword arguments.
- Yields:
An AsyncSession object.
- property music: AsyncLiveMusic¶
- class genai.live.AsyncSession(api_client, websocket, session_id=None, setup_complete=None)¶
Bases:
object[Preview] AsyncSession.
- async close()¶
- Return type:
None
- async receive()¶
Receive model responses from the server.
The method will yield the model responses from the server. The returned responses will represent a complete model turn. When the returned message is function call, user must call send with the function response to continue the turn.
- Return type:
AsyncIterator[LiveServerMessage]- Yields:
The model responses from the server.
Example usage:
client = genai.Client(api_key=API_KEY) async with client.aio.live.connect(model='...') as session: await session.send(input='Hello world!', end_of_turn=True) async for message in session.receive(): print(message)
- async send(*, input=None, end_of_turn=False)¶
[Deprecated] Send input to the model.
> Warning: This method is deprecated and will be removed in a future version (not before Q3 2025). Please use one of the more specific methods: send_client_content, send_realtime_input, or send_tool_response instead.
The method will send the input request to the server.
- Return type:
None- Parameters:
input – The input request to the model.
end_of_turn – Whether the input is the last message in a turn.
Example usage:
client = genai.Client(api_key=API_KEY) async with client.aio.live.connect(model='...') as session: await session.send(input='Hello world!', end_of_turn=True) async for message in session.receive(): print(message)
- async send_client_content(*, turns=None, turn_complete=True)¶
Send non-realtime, turn based content to the model.
There are two ways to send messages to the live API: send_client_content and send_realtime_input.
send_client_content messages are added to the model context in order. Having a conversation using send_client_content messages is roughly equivalent to using the Chat.send_message_stream method, except that the state of the chat history is stored on the API server.
Because of send_client_content’s order guarantee, the model cannot respond as quickly to send_client_content messages as to send_realtime_input messages. This makes the biggest difference when sending objects that have significant preprocessing time (typically images).
The send_client_content message sends a list of Content objects, which has more options than the media:Blob sent by send_realtime_input.
The main use-cases for send_client_content over send_realtime_input are:
Prefilling a conversation context (including sending anything that can’t be represented as a realtime message), before starting a realtime conversation.
Conducting a non-realtime conversation, similar to client.chat, using the live api.
- Caution: Interleaving send_client_content and send_realtime_input
in the same conversation is not recommended and can lead to unexpected results.
- Parameters:
turns – A Content object or list of Content objects (or equivalent dicts).
turn_complete – if true (the default) the model will reply immediately. If false, the model will wait for you to send additional client_content, and will not return until you send turn_complete=True.
Example:
import google.genai from google.genai import types import os if os.environ.get('GOOGLE_GENAI_USE_ENTERPRISE'): MODEL_NAME = 'gemini-2.0-flash-live-preview-04-09' else: MODEL_NAME = 'gemini-live-2.5-flash-preview'; client = genai.Client() async with client.aio.live.connect( model=MODEL_NAME, config={"response_modalities": ["TEXT"]} ) as session: await session.send_client_content( turns=types.Content( role='user', parts=[types.Part(text="Hello world!")])) async for msg in session.receive(): if msg.text: print(msg.text)
- Return type:
None
- async send_realtime_input(*, media=None, audio=None, audio_stream_end=None, video=None, text=None, activity_start=None, activity_end=None)¶
Send realtime input to the model, only send one argument per call.
Use send_realtime_input for realtime audio chunks and video frames(images).
With send_realtime_input the api will respond to audio automatically based on voice activity detection (VAD).
send_realtime_input is optimized for responsivness at the expense of deterministic ordering. Audio and video tokens are added to the context when they become available.
- Return type:
None- Parameters:
media – A Blob-like object, the realtime media to send.
Example:
from pathlib import Path from google import genai from google.genai import types import PIL.Image import os if os.environ.get('GOOGLE_GENAI_USE_ENTERPRISE'): MODEL_NAME = 'gemini-2.0-flash-live-preview-04-09' else: MODEL_NAME = 'gemini-live-2.5-flash-preview'; client = genai.Client() async with client.aio.live.connect( model=MODEL_NAME, config={"response_modalities": ["TEXT"]}, ) as session: await session.send_realtime_input( media=PIL.Image.open('image.jpg')) audio_bytes = Path('audio.pcm').read_bytes() await session.send_realtime_input( media=types.Blob(data=audio_bytes, mime_type='audio/pcm;rate=16000')) async for msg in session.receive(): if msg.text is not None: print(f'{msg.text}')
- async send_tool_response(*, function_responses)¶
Send a tool response to the session.
Use send_tool_response to reply to LiveServerToolCall messages from the server.
To set the available tools, use the config.tools argument when you connect to the session (client.live.connect).
- Return type:
None- Parameters:
function_responses – A FunctionResponse-like object or list of FunctionResponse-like objects.
Example:
from google import genai from google.genai import types import os if os.environ.get('GOOGLE_GENAI_USE_ENTERPRISE'): MODEL_NAME = 'gemini-2.0-flash-live-preview-04-09' else: MODEL_NAME = 'gemini-live-2.5-flash-preview'; client = genai.Client() tools = [{'function_declarations': [{'name': 'turn_on_the_lights'}]}] config = { "tools": tools, "response_modalities": ['TEXT'] } async with client.aio.live.connect( model='models/gemini-live-2.5-flash-preview', config=config ) as session: prompt = "Turn on the lights please" await session.send_client_content( turns={"parts": [{'text': prompt}]} ) async for chunk in session.receive(): if chunk.server_content: if chunk.text is not None: print(chunk.text) elif chunk.tool_call: print(chunk.tool_call) print('_'*80) function_response=types.FunctionResponse( name='turn_on_the_lights', response={'result': 'ok'}, id=chunk.tool_call.function_calls[0].id, ) print(function_response) await session.send_tool_response( function_responses=function_response ) print('_'*80)
- async start_stream(*, stream, mime_type)¶
[Deprecated] Start a live session from a data stream.
> Warning: This method is deprecated and will be removed in a future version (not before Q2 2025). Please use one of the more specific methods: send_client_content, send_realtime_input, or send_tool_response instead.
The interaction terminates when the input stream is complete. This method will start two async tasks. One task will be used to send the input stream to the model and the other task will be used to receive the responses from the model.
- Return type:
AsyncIterator[LiveServerMessage]- Parameters:
stream – An iterator that yields the model response.
mime_type – The MIME type of the data in the stream.
- Yields:
The audio bytes received from the model and server response messages.
Example usage:
client = genai.Client(api_key=API_KEY) config = {'response_modalities': ['AUDIO']} async def audio_stream(): stream = read_audio() for data in stream: yield data async with client.aio.live.connect(model='...', config=config) as session: for audio in session.start_stream(stream = audio_stream(), mime_type = 'audio/pcm'): play_audio_chunk(audio.data)
genai.models module¶
- class genai.models.AsyncModels(api_client_)¶
Bases:
BaseModule- async compute_tokens(*, model, contents, config=None)¶
Given a list of contents, returns a corresponding TokensInfo containing the
list of tokens and list of token ids.
- Return type:
- Parameters:
model (str) – The model to use.
contents (list[shared.Content]) – The content to compute tokens for.
Usage:
response = await client.aio.models.compute_tokens( model='gemini-flash-latest', contents='What is your name?', ) print(response) # tokens_info=[TokensInfo(role='user', token_ids=['1841', ...], # tokens=[b'What', b' is', b' your', b' name', b'?'])]
- async count_tokens(*, model, contents, config=None)¶
Counts the number of tokens in the given content.
Multimodal input is supported for Gemini models.
- Return type:
- Parameters:
model (str) – The model to use for counting tokens.
contents (list[types.Content]) – The content to count tokens for.
config (CountTokensConfig) – The configuration for counting tokens.
Usage:
response = await client.aio.models.count_tokens( model='gemini-flash-latest', contents='What is your name?', ) print(response) # total_tokens=5 cached_content_token_count=None
- async delete(*, model, config=None)¶
- Return type:
- edit_image(*, model, prompt, reference_images, config=None)¶
Edits an image based on a text description and configuration.
- Return type:
- Parameters:
model (str) – The model to use.
prompt (str) – A text description of the edit to apply to the image. reference_images (list[Union[RawReferenceImage, MaskReferenceImage, ControlReferenceImage, StyleReferenceImage, SubjectReferenceImage]): The reference images for editing.
config (EditImageConfig) – Configuration for editing.
Usage:
from google.genai.types import RawReferenceImage, MaskReferenceImage raw_ref_image = RawReferenceImage( reference_id=1, reference_image=types.Image.from_file(location=IMAGE_FILE_PATH), ) mask_ref_image = MaskReferenceImage( reference_id=2, config=types.MaskReferenceConfig( mask_mode='MASK_MODE_FOREGROUND', mask_dilation=0.06, ), ) response = await client.aio.models.edit_image( model='imagen-3.0-capability-001', prompt='man with dog', reference_images=[raw_ref_image, mask_ref_image], config=types.EditImageConfig( edit_mode= "EDIT_MODE_INPAINT_INSERTION", number_of_images= 1, include_rai_reason= True, ) ) response.generated_images[0].image.show() # Shows a man with a dog instead of a cat.
- async embed_content(*, model, contents, config=None)¶
Calculates embeddings for the given contents.
- Return type:
- Parameters:
model (str) – The model to use.
contents (list[Content]) – The contents to embed.
config (EmbedContentConfig) – Optional configuration for embeddings.
Usage:
embeddings = await client.aio.models.embed_content( model= 'text-embedding-004', contents=[ 'What is your name?', 'What is your favorite color?', ], config={ 'output_dimensionality': 64 }, ) multimodal_embeddings = await client.aio.models.embed_content( model='gemini-embedding-2-preview', contents=[ types.Part.from_uri( file_uri='gs://generativeai-downloads/images/scones.jpg', mime_type='image/jpeg', ), ], config={ 'output_dimensionality': 64 }, )
- async generate_content(*, model, contents, config=None)¶
Makes an API request to generate content using a model.
Some models support multimodal input and output.
Automatic continuation is enabled by default. When the model stops with finish_reason == FinishReason.CONTINUATION and returns a continuation_token on the first candidate, the SDK automatically sends follow-up requests with the continuation_token until finish_reason is no longer CONTINUATION, and returns the merged response. Set config=types.GenerateContentConfig(automatic_continuation=False) to disable this behavior.
Built-in MCP support is an experimental feature.
Usage:
from google.genai import types from google import genai client = genai.Client( vertexai=True, project='my-project-id', location='us-central1' ) response = await client.aio.models.generate_content( model='gemini-flash-latest', contents='User input: I like bagels. Answer:', config=types.GenerateContentConfig( system_instruction= [ 'You are a helpful language translator.', 'Your mission is to translate text in English to French.' ] ), ) print(response.text) # J'aime les bagels.
- Return type:
- async generate_content_stream(*, model, contents, config=None)¶
Makes an API request to generate content using a model and yields the model’s response in chunks.
For the model parameter, supported formats for Gemini Enterprise Agent Platform API include: - The Gemini model ID, for example: ‘gemini-flash-latest’ - The full resource name starts with ‘projects/’, for example:
‘projects/my-project-id/locations/us-central1/publishers/google/models/gemini-flash-latest’
The partial resource name with ‘publishers/’, for example: ‘publishers/google/models/gemini-flash-latest’ or
/ separated publisher and model name, for example: ‘google/gemini-flash-latest’
For the model parameter, supported formats for Gemini API include: - The Gemini model ID, for example: ‘gemini-flash-latest’ - The model name starts with ‘models/’, for example:
‘models/gemini-flash-latest’
For tuned models, the model name starts with ‘tunedModels/’, for example: ‘tunedModels/1234567890123456789’
Some models support multimodal input and output.
Automatic continuation is enabled by default. When a stream hop ends with finish_reason == FinishReason.CONTINUATION and includes a continuation_token on the first candidate, the SDK automatically clears the intermediate CONTINUATION finish_reason, starts follow-up stream requests with the continuation_token, and yields chunks until finish_reason is no longer CONTINUATION. Set config=types.GenerateContentConfig(automatic_continuation=False) to disable this behavior.
Built-in MCP support is an experimental feature.
Usage:
from google.genai import types from google import genai client = genai.Client( vertexai=True, project='my-project-id', location='us-central1' ) async for chunk in await client.aio.models.generate_content_stream( model='gemini-flash-latest', contents='''What is a good name for a flower shop that specializes in selling bouquets of dried flowers?''' ): print(chunk.text) # **Elegant & Classic:** # * The Dried Bloom # * Everlasting Florals # * Timeless Petals async for chunk in await client.aio.models.generate_content_stream( model='gemini-flash-latest', contents=[ types.Part.from_text('What is shown in this image?'), types.Part.from_uri('gs://generativeai-downloads/images/scones.jpg', 'image/jpeg') ] ): print(chunk.text) # The image shows a flat lay arrangement of freshly baked blueberry # scones.
- Return type:
AsyncIterator[GenerateContentResponse]
- generate_images(*, model, prompt, config=None)¶
Generates images based on a text description and configuration.
- Return type:
- Parameters:
model (str) – The model to use.
prompt (str) – A text description of the images to generate.
config (GenerateImagesConfig) – Configuration for generation.
Usage:
response = await client.aio.models.generate_images( model='imagen-3.0-generate-002', prompt='Man with a dog', config=types.GenerateImagesConfig( number_of_images= 1, include_rai_reason= True, ) ) response.generated_images[0].image.show() # Shows a man with a dog.
- async generate_videos(*, model, prompt=None, image=None, video=None, source=None, config=None)¶
Generates videos based on an input (text, image, or video) and configuration.
The following use cases are supported: 1. Text to video generation. 2a. Image to video generation (additional text prompt is optional). 2b. Image to video generation with frame interpolation (specify last_frame in config). 3. Video extension (additional text prompt is optional)
- Return type:
- Parameters:
model – The model to use.
prompt – The text prompt for generating the videos. Optional for image to video and video extension use cases. This argument is deprecated, please use source instead.
image – The input image for generating the videos. Optional if prompt is provided. This argument is deprecated, please use source instead.
video – The input video for video extension use cases. Optional if prompt or image is provided. This argument is deprecated, please use source instead.
source – The input source for generating the videos (prompt, image, and/or video)
config – Configuration for generation.
Usage:
``` operation = client.models.generate_videos(
model=”veo-2.0-generate-001”, source=types.GenerateVideosSource(
prompt=”A neon hologram of a cat driving at top speed”,
),
) while not operation.done:
time.sleep(10) operation = client.operations.get(operation)
- async list(*, config=None)¶
Makes an API request to list the available models.
If query_base is set to True in the config or not set (default), the API will return all available base models. If set to False, it will return all tuned models.
- Return type:
AsyncPager[Model]- Parameters:
config (ListModelsConfigOrDict) – Configuration for retrieving models.
Usage:
response = await client.aio.models.list(config={'page_size': 5}) print(response.page) # [Model(name='projects/./locations/./models/123', display_name='my_model' response = await client.aio.models.list( config={'page_size': 5, 'query_base': True} ) print(response.page) # [Model(name='publishers/google/models/gemini-flash-latest' ...
- async recontext_image(*, model, source, config=None)¶
Recontextualizes an image.
There is one type of recontextualization currently supported: 1) Virtual Try-On: Generate images of persons modeling fashion products.
- Return type:
- Parameters:
model (str) – The model to use.
source (RecontextImageSource) – An object containing the source inputs (prompt, person_image, product_images) for image recontext. prompt is behind an allowlist. person_image is required. product_images is required. Only one product image is supported currently.
config (RecontextImageConfig) – Configuration for recontextualization.
Usage:
``` virtual_try_on_response = await client.aio.models.recontext_image(
model=”virtual-try-on-001”, source=types.RecontextImageSource(
person_image=types.Image.from_file(location=IMAGE1_FILE_PATH), product_images=[types.ProductImage(product_image=
types.Image.from_file(location=IMAGE2_FILE_PATH)
)],
), config=types.RecontextImageConfig(
number_of_images=1,
),
) image = virtual_try_on_response.generated_images[0].image ```
- async segment_image(*, model, source, config=None)¶
Segments an image, creating a mask of a specified area.
- Return type:
- Parameters:
model (str) – The model to use.
source (SegmentImageSource) – An object containing the source inputs (prompt, image, scribble_image) for image segmentation. The prompt is required for prompt mode and semantic mode, disallowed for other modes. scribble_image is required for the interactive mode, disallowed for other modes.
config (SegmentImageConfig) – Configuration for segmentation.
Usage:
- async upscale_image(*, model, image, upscale_factor, config=None)¶
Makes an API request to upscale a provided image.
- Return type:
- Parameters:
model (str) – The model to use.
image (Image) – The input image for upscaling.
upscale_factor (str) – The factor to upscale the image (x2 or x4).
config (UpscaleImageConfig) – Configuration for upscaling.
Usage:
from google.genai.types import Image IMAGE_FILE_PATH="my-image.png" response = await client.aio.models.upscale_image( model='imagen-3.0-generate-001', image=types.Image.from_file(location=IMAGE_FILE_PATH), upscale_factor='x2', ) response.generated_images[0].image.show() # Opens my-image.png which is upscaled by a factor of 2.
- class genai.models.Models(api_client_)¶
Bases:
BaseModule- compute_tokens(*, model, contents, config=None)¶
Given a list of contents, returns a corresponding TokensInfo containing the
list of tokens and list of token ids.
This method is not supported by the Gemini Developer API.
- Return type:
- Parameters:
model (str) – The model to use.
contents (list[shared.Content]) – The content to compute tokens for.
Usage:
response = client.models.compute_tokens( model='gemini-flash-latest', contents='What is your name?', ) print(response) # tokens_info=[TokensInfo(role='user', token_ids=['1841', ...], # tokens=[b'What', b' is', b' your', b' name', b'?'])]
- count_tokens(*, model, contents, config=None)¶
Counts the number of tokens in the given content.
Multimodal input is supported for Gemini models.
- Return type:
- Parameters:
model (str) – The model to use for counting tokens.
contents (list[types.Content]) – The content to count tokens for.
config (CountTokensConfig) – The configuration for counting tokens.
Usage:
response = client.models.count_tokens( model='gemini-flash-latest', contents='What is your name?', ) print(response) # total_tokens=5 cached_content_token_count=None
- delete(*, model, config=None)¶
- Return type:
- edit_image(*, model, prompt, reference_images, config=None)¶
Edits an image based on a text description and configuration.
- Return type:
- Parameters:
model (str) – The model to use.
prompt (str) – A text description of the edit to apply to the image. reference_images (list[Union[RawReferenceImage, MaskReferenceImage, ControlReferenceImage, StyleReferenceImage, SubjectReferenceImage]): The reference images for editing.
config (EditImageConfig) – Configuration for editing.
Usage:
from google.genai.types import RawReferenceImage, MaskReferenceImage raw_ref_image = RawReferenceImage( reference_id=1, reference_image=types.Image.from_file(location=IMAGE_FILE_PATH), ) mask_ref_image = MaskReferenceImage( reference_id=2, config=types.MaskReferenceConfig( mask_mode='MASK_MODE_FOREGROUND', mask_dilation=0.06, ), ) response = client.models.edit_image( model='imagen-3.0-capability-001', prompt='Man with dog', reference_images=[raw_ref_image, mask_ref_image], config=types.EditImageConfig( edit_mode= "EDIT_MODE_INPAINT_INSERTION", number_of_images= 1, include_rai_reason= True, ) ) response.generated_images[0].image.show() # Shows a man with a dog instead of a cat.
- embed_content(*, model, contents, config=None)¶
Calculates embeddings for the given contents.
- Return type:
- Parameters:
model (str) – The model to use.
contents (list[Content]) – The contents to embed.
config (EmbedContentConfig) – Optional configuration for embeddings.
Usage:
embeddings = client.models.embed_content( model= 'text-embedding-004', contents=[ 'What is your name?', 'What is your favorite color?', ], config={ 'output_dimensionality': 64 }, ) multimodal_embeddings = client.models.embed_content( model='gemini-embedding-2-preview', contents=[ types.Part.from_uri( file_uri='gs://generativeai-downloads/images/scones.jpg', mime_type='image/jpeg', ), ], config={ 'output_dimensionality': 64 }, )
- generate_content(*, model, contents, config=None)¶
Makes an API request to generate content using a model.
For the model parameter, supported formats for Gemini Enterprise Agent Platform API include: - The Gemini model ID, for example: ‘gemini-flash-latest’ - The full resource name starts with ‘projects/’, for example:
‘projects/my-project-id/locations/us-central1/publishers/google/models/gemini-flash-latest’
The partial resource name with ‘publishers/’, for example: ‘publishers/google/models/gemini-flash-latest’ or
/ separated publisher and model name, for example: ‘google/gemini-flash-latest’
For the model parameter, supported formats for Gemini API include: - The Gemini model ID, for example: ‘gemini-flash-latest’ - The model name starts with ‘models/’, for example:
‘models/gemini-flash-latest’
For tuned models, the model name starts with ‘tunedModels/’, for example: ‘tunedModels/1234567890123456789’
Some models support multimodal input and output.
Automatic continuation is enabled by default. When the model stops with finish_reason == FinishReason.CONTINUATION and returns a continuation_token on the first candidate, the SDK automatically sends follow-up requests with the continuation_token until finish_reason is no longer CONTINUATION, and returns the merged response. Set config=types.GenerateContentConfig(automatic_continuation=False) to disable this behavior.
Built-in MCP support is an experimental feature.
Usage:
from google.genai import types from google import genai client = genai.Client( vertexai=True, project='my-project-id', location='us-central1' ) response = client.models.generate_content( model='gemini-flash-latest', contents='''What is a good name for a flower shop that specializes in selling bouquets of dried flowers?''' ) print(response.text) # **Elegant & Classic:** # * The Dried Bloom # * Everlasting Florals # * Timeless Petals response = client.models.generate_content( model='gemini-flash-latest', contents=[ types.Part.from_text(text='What is shown in this image?'), types.Part.from_uri(file_uri='gs://generativeai-downloads/images/scones.jpg', mime_type='image/jpeg') ] ) print(response.text) # The image shows a flat lay arrangement of freshly baked blueberry # scones.
- Return type:
- generate_content_stream(*, model, contents, config=None)¶
Makes an API request to generate content using a model and yields the model’s response in chunks.
For the model parameter, supported formats for Gemini Enterprise Agent Platform API include: - The Gemini model ID, for example: ‘gemini-flash-latest’ - The full resource name starts with ‘projects/’, for example:
‘projects/my-project-id/locations/us-central1/publishers/google/models/gemini-flash-latest’
The partial resource name with ‘publishers/’, for example: ‘publishers/google/models/gemini-flash-latest’ or
/ separated publisher and model name, for example: ‘google/gemini-flash-latest’
For the model parameter, supported formats for Gemini API include: - The Gemini model ID, for example: ‘gemini-flash-latest’ - The model name starts with ‘models/’, for example:
‘models/gemini-flash-latest’
For tuned models, the model name starts with ‘tunedModels/’, for example: ‘tunedModels/1234567890123456789’
Some models support multimodal input and output.
Automatic continuation is enabled by default. When a stream hop ends with finish_reason == FinishReason.CONTINUATION and includes a continuation_token on the first candidate, the SDK automatically clears the intermediate CONTINUATION finish_reason, starts follow-up stream requests with the continuation_token, and yields chunks until finish_reason is no longer CONTINUATION. Set config=types.GenerateContentConfig(automatic_continuation=False) to disable this behavior.
Built-in MCP support is an experimental feature.
Usage:
from google.genai import types from google import genai client = genai.Client( vertexai=True, project='my-project-id', location='us-central1' ) for chunk in client.models.generate_content_stream( model='gemini-flash-latest', contents='''What is a good name for a flower shop that specializes in selling bouquets of dried flowers?''' ): print(chunk.text) # **Elegant & Classic:** # * The Dried Bloom # * Everlasting Florals # * Timeless Petals for chunk in client.models.generate_content_stream( model='gemini-flash-latest', contents=[ types.Part.from_text('What is shown in this image?'), types.Part.from_uri('gs://generativeai-downloads/images/scones.jpg', 'image/jpeg') ] ): print(chunk.text) # The image shows a flat lay arrangement of freshly baked blueberry # scones.
- Return type:
Iterator[GenerateContentResponse]
- generate_images(*, model, prompt, config=None)¶
Generates images based on a text description and configuration.
- Return type:
- Parameters:
model (str) – The model to use.
prompt (str) – A text description of the images to generate.
config (GenerateImagesConfig) – Configuration for generation.
Usage:
response = client.models.generate_images( model='imagen-3.0-generate-002', prompt='Man with a dog', config=types.GenerateImagesConfig( number_of_images= 1, include_rai_reason= True, ) ) response.generated_images[0].image.show() # Shows a man with a dog.
- generate_videos(*, model, prompt=None, image=None, video=None, source=None, config=None)¶
Generates videos based on an input (text, image, or video) and configuration.
The following use cases are supported: 1. Text to video generation. 2a. Image to video generation (additional text prompt is optional). 2b. Image to video generation with frame interpolation (specify last_frame in config). 3. Video extension (additional text prompt is optional)
- Return type:
- Parameters:
model – The model to use.
prompt – The text prompt for generating the videos. Optional for image to video and video extension use cases. This argument is deprecated, please use source instead.
image – The input image for generating the videos. Optional if prompt is provided. This argument is deprecated, please use source instead.
video – The input video for video extension use cases. Optional if prompt or image is provided. This argument is deprecated, please use source instead.
source – The input source for generating the videos (prompt, image, and/or video)
config – Configuration for generation.
Usage:
``` operation = client.models.generate_videos(
model=”veo-2.0-generate-001”, source=types.GenerateVideosSource(
prompt=”A neon hologram of a cat driving at top speed”,
),
) while not operation.done:
time.sleep(10) operation = client.operations.get(operation)
- list(*, config=None)¶
Makes an API request to list the available models.
If query_base is set to True in the config or not set (default), the API will return all available base models. If set to False, it will return all tuned models.
- Return type:
Pager[Model]- Parameters:
config (ListModelsConfigOrDict) – Configuration for retrieving models.
Usage:
response=client.models.list(config={'page_size': 5}) print(response.page) # [Model(name='projects/./locations/./models/123', display_name='my_model' response=client.models.list(config={'page_size': 5, 'query_base': True}) print(response.page) # [Model(name='publishers/google/models/gemini-flash-latest' ...
- recontext_image(*, model, source, config=None)¶
Recontextualizes an image.
There is one type of recontextualization currently supported: 1) Virtual Try-On: Generate images of persons modeling fashion products.
- Return type:
- Parameters:
model (str) – The model to use.
source (RecontextImageSource) – An object containing the source inputs (prompt, person_image, product_images) for image recontext. prompt is behind an allowlist. person_image is required. product_images is required. Only one product image is supported currently.
config (RecontextImageConfig) – Configuration for recontextualization.
Usage:
``` virtual_try_on_response = client.models.recontext_image(
model=”virtual-try-on-001”, source=types.RecontextImageSource(
person_image=types.Image.from_file(location=IMAGE1_FILE_PATH), product_images=[types.ProductImage(product_image=
types.Image.from_file(location=IMAGE2_FILE_PATH)
)],
), config=types.RecontextImageConfig(
number_of_images=1,
),
) image = virtual_try_on_response.generated_images[0].image ```
- segment_image(*, model, source, config=None)¶
Segments an image, creating a mask of a specified area.
- Return type:
- Parameters:
model (str) – The model to use.
source (SegmentImageSource) – An object containing the source inputs (prompt, image, scribble_image) for image segmentation. The prompt is required for prompt mode and semantic mode, disallowed for other modes. scribble_image is required for the interactive mode, disallowed for other modes.
config (SegmentImageConfig) – Configuration for segmentation.
Usage:
- upscale_image(*, model, image, upscale_factor, config=None)¶
Makes an API request to upscale a provided image.
- Return type:
- Parameters:
model (str) – The model to use.
image (Image) – The input image for upscaling.
upscale_factor (str) – The factor to upscale the image (x2 or x4).
config (UpscaleImageConfig) – Configuration for upscaling.
Usage:
from google.genai.types import Image IMAGE_FILE_PATH="my-image.png" response=client.models.upscale_image( model='imagen-3.0-generate-001', image=types.Image.from_file(location=IMAGE_FILE_PATH), upscale_factor='x2', ) response.generated_images[0].image.show() # Opens my-image.png which is upscaled by a factor of 2.
genai.tokens module¶
[Experimental] Auth Tokens API client.
- class genai.tokens.AsyncTokens(api_client_)¶
Bases:
BaseModule[Experimental] Async Auth Tokens API client.
This class provides asynchronous methods for creating auth tokens.
- create(*, config=None)¶
Creates an auth token asynchronously. Support in v1alpha only.
- Return type:
- Parameters:
config (CreateAuthTokenConfig) – Optional configuration for the request.
Usage:
client = genai.Client( api_key=API_KEY, http_options=types.HttpOptions(api_version='v1alpha'), ) auth_token = await client.aio.tokens.create( config=types.CreateAuthTokenConfig( uses=10, live_constrained_parameters=types.LiveEphemeralParameters( model='gemini-live-2.5-flash-preview', config=types.LiveConnectConfig( system_instruction='You are an LLM called Gemini.' ), ), ) )
- class genai.tokens.Tokens(api_client_)¶
Bases:
BaseModule[Experimental] Auth Tokens API client.
This class provides methods for creating auth tokens.
- create(*, config=None)¶
[Experimental] Creates an auth token.
- Return type:
- Parameters:
config (CreateAuthTokenConfig) – Optional configuration for the request.
The CreateAuthTokenConfig’s live_constrained_parameters attrubite Can be used to lock the parameters of the live session so they can’t be changed client side. This behavior has two basic modes depending on whether lock_additional_fields is set:
If you do not pass lock_additional_fields the entire live_constrained_parameters is locked and can’t be changed by the token’s user.
If you set lock_additional_fields, then the non-null fields of live_constrained_parameters are locked, and any additional fields specified in lock_additional_fields.
Usage:
# Case 1: If LiveEphemeralParameters is unset, unlock LiveConnectConfig # when using the token in Live API sessions. Each session connection can # use a different configuration. config = types.CreateAuthTokenConfig( uses=10, expire_time='2025-05-01T00:00:00Z', ) auth_token = client.auth_tokens.create(config=config)
# Case 2: If LiveEphemeralParameters is set, lock all fields in # LiveConnectConfig when using the token in Live API sessions. For # example, changing `output_audio_transcription` in the Live API # connection will be ignored by the API. auth_token = client.auth_tokens.create( config=types.CreateAuthTokenConfig( uses=10, live_constrained_parameters=types.LiveEphemeralParameters( model='gemini-live-2.5-flash-preview', config=types.LiveConnectConfig( system_instruction='You are an LLM called Gemini.' ), ), ) )
# Case 3: If LiveEphemeralParameters is set and lockAdditionalFields is # empty, lock LiveConnectConfig with set fields (e.g. # system_instruction in this example) when using the token in Live API # sessions. auth_token = client.auth_tokens.create( config=types.CreateAuthTokenConfig( uses=10, live_constrained_parameters=types.LiveEphemeralParameters( config=types.LiveConnectConfig( system_instruction='You are an LLM called Gemini.' ), ), lock_additional_fields=[], ) )
# Case 4: If LiveEphemeralParameters is set and lockAdditionalFields is # set, lock LiveConnectConfig with set and additional fields (e.g. # system_instruction, temperature in this example) when using the token # in Live API sessions. auth_token = client.auth_tokens.create( config=types.CreateAuthTokenConfig( uses=10, live_constrained_parameters=types.LiveEphemeralParameters( model='gemini-live-2.5-flash-preview', config=types.LiveConnectConfig( system_instruction='You are an LLM called Gemini.' ), ), lock_additional_fields=['temperature'], ) )
genai.tunings module¶
- class genai.tunings.AsyncTunings(api_client_)¶
Bases:
BaseModule- async cancel(*, name, config=None)¶
Cancels a tuning job asynchronously.
- Return type:
- Parameters:
name (str) – A TuningJob resource name.
- async list(*, config=None)¶
Lists TuningJob objects asynchronously.
- Return type:
AsyncPager[TuningJob]- Parameters:
config – The configuration for the list request.
- Returns:
A Pager object that contains one page of tuning jobs. When iterating over the pager, it automatically fetches the next page if there are more.
Usage:
- async validate_reward(*, parent, sample_response, example, single_reward_config=None, composite_reward_config=None, config=None)¶
Validates a reinforcement tuning reward configuration.
Allows users to validate a reinforcement tuning reward configuration against a sample response and example before creating a reinforcement tuning job, so that they can iterate on the reward configuration without having to create a tuning job each time.
- Return type:
- Parameters:
parent – The resource name of the Location to validate the reward in, e.g. projects/{project}/locations/{location}.
sample_response – The sample response for validating the reward configuration.
example – The example to validate the reward configuration.
single_reward_config – Single reward function configuration for reinforcement tuning. Mutually exclusive with composite_reward_config.
composite_reward_config – Composite reward function configuration for reinforcement tuning. Mutually exclusive with single_reward_config.
config – Optional parameters for the request.
- Returns:
A ValidateRewardResponse with the computed reward(s).
- class genai.tunings.Tunings(api_client_)¶
Bases:
BaseModule- cancel(*, name, config=None)¶
Cancels a tuning job.
- Return type:
- Parameters:
name (str) – TuningJob resource name.
- list(*, config=None)¶
Lists TuningJob objects.
- Return type:
Pager[TuningJob]- Parameters:
config – The configuration for the list request.
- Returns:
A Pager object that contains one page of tuning jobs. When iterating over the pager, it automatically fetches the next page if there are more.
Usage:
- validate_reward(*, parent, sample_response, example, single_reward_config=None, composite_reward_config=None, config=None)¶
Validates a reinforcement tuning reward configuration.
Allows users to validate a reinforcement tuning reward configuration against a sample response and example before creating a reinforcement tuning job, so that they can iterate on the reward configuration without having to create a tuning job each time.
- Return type:
- Parameters:
parent – The resource name of the Location to validate the reward in, e.g. projects/{project}/locations/{location}.
sample_response – The sample response for validating the reward configuration.
example – The example to validate the reward configuration.
single_reward_config – Single reward function configuration for reinforcement tuning. Mutually exclusive with composite_reward_config.
composite_reward_config – Composite reward function configuration for reinforcement tuning. Mutually exclusive with single_reward_config.
config – Optional parameters for the request.
- Returns:
A ValidateRewardResponse with the computed reward(s).
genai.types module¶
- class genai.types.ActivityEnd(**data)¶
Bases:
BaseModelMarks the end of user activity.
This can only be sent if automatic (i.e. server-side) activity detection is disabled.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ActivityEndDict¶
Bases:
TypedDictMarks the end of user activity.
This can only be sent if automatic (i.e. server-side) activity detection is disabled.
- class genai.types.ActivityHandling(*values)¶
Bases:
CaseInSensitiveEnumThe different ways of handling user activity.
- ACTIVITY_HANDLING_UNSPECIFIED = 'ACTIVITY_HANDLING_UNSPECIFIED'¶
If unspecified, the default behavior is START_OF_ACTIVITY_INTERRUPTS.
- NO_INTERRUPTION = 'NO_INTERRUPTION'¶
The model’s response will not be interrupted.
- START_OF_ACTIVITY_INTERRUPTS = 'START_OF_ACTIVITY_INTERRUPTS'¶
If true, start of activity will interrupt the model’s response (also called “barge in”). The model’s current response will be cut-off in the moment of the interruption. This is the default behavior.
- class genai.types.ActivityStart(**data)¶
Bases:
BaseModelMarks the start of user activity.
This can only be sent if automatic (i.e. server-side) activity detection is disabled.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ActivityStartDict¶
Bases:
TypedDictMarks the start of user activity.
This can only be sent if automatic (i.e. server-side) activity detection is disabled.
- class genai.types.AdapterSize(*values)¶
Bases:
CaseInSensitiveEnumAdapter size for tuning. This enum is not supported in Gemini API.
- ADAPTER_SIZE_EIGHT = 'ADAPTER_SIZE_EIGHT'¶
Adapter size 8.
- ADAPTER_SIZE_FOUR = 'ADAPTER_SIZE_FOUR'¶
Adapter size 4.
- ADAPTER_SIZE_ONE = 'ADAPTER_SIZE_ONE'¶
Adapter size 1.
- ADAPTER_SIZE_SIXTEEN = 'ADAPTER_SIZE_SIXTEEN'¶
Adapter size 16.
- ADAPTER_SIZE_THIRTY_TWO = 'ADAPTER_SIZE_THIRTY_TWO'¶
Adapter size 32.
- ADAPTER_SIZE_TWO = 'ADAPTER_SIZE_TWO'¶
Adapter size 2.
- ADAPTER_SIZE_UNSPECIFIED = 'ADAPTER_SIZE_UNSPECIFIED'¶
Adapter size is unspecified.
- class genai.types.AggregationMetric(*values)¶
Bases:
CaseInSensitiveEnumAggregation metric. This enum is not supported in Gemini API.
- AGGREGATION_METRIC_UNSPECIFIED = 'AGGREGATION_METRIC_UNSPECIFIED'¶
Unspecified aggregation metric.
- AVERAGE = 'AVERAGE'¶
Average aggregation metric. Not supported for Pairwise metric.
- MAXIMUM = 'MAXIMUM'¶
Maximum aggregation metric. Not supported for pairwise metric.
- MEDIAN = 'MEDIAN'¶
Median aggregation metric. Not supported for pairwise metric.
- MINIMUM = 'MINIMUM'¶
Minimum aggregation metric. Not supported for pairwise metric.
- MODE = 'MODE'¶
Mode aggregation metric.
- PERCENTILE_P90 = 'PERCENTILE_P90'¶
90th percentile aggregation metric. Not supported for pairwise metric.
- PERCENTILE_P95 = 'PERCENTILE_P95'¶
95th percentile aggregation metric. Not supported for pairwise metric.
- PERCENTILE_P99 = 'PERCENTILE_P99'¶
99th percentile aggregation metric. Not supported for pairwise metric.
- STANDARD_DEVIATION = 'STANDARD_DEVIATION'¶
Standard deviation aggregation metric. Not supported for pairwise metric.
- VARIANCE = 'VARIANCE'¶
Variance aggregation metric. Not supported for pairwise metric.
- class genai.types.AggregationOutput(**data)¶
Bases:
BaseModelThe aggregation result for the entire dataset and all metrics.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- aggregation_results: list[AggregationResult] | None¶
- dataset: EvaluationDataset | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.AggregationOutputDict¶
Bases:
TypedDictThe aggregation result for the entire dataset and all metrics.
This data type is not supported in Gemini API.
- aggregation_results: list[AggregationResultDict] | None¶
One AggregationResult per metric.
- dataset: EvaluationDatasetDict | None¶
The dataset used for evaluation & aggregation.
- class genai.types.AggregationResult(**data)¶
Bases:
BaseModelThe aggregation result for a single metric.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- aggregation_metric: AggregationMetric | None¶
- bleu_metric_value: BleuMetricValue | None¶
- custom_code_execution_result: CustomCodeExecutionResult | None¶
- exact_match_metric_value: ExactMatchMetricValue | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- pairwise_metric_result: PairwiseMetricResult | None¶
- pointwise_metric_result: PointwiseMetricResult | None¶
- rouge_metric_value: RougeMetricValue | None¶
- class genai.types.AggregationResultDict¶
Bases:
TypedDictThe aggregation result for a single metric.
This data type is not supported in Gemini API.
- aggregation_metric: AggregationMetric | None¶
Aggregation metric.
- bleu_metric_value: BleuMetricValueDict | None¶
Results for bleu metric.
- custom_code_execution_result: CustomCodeExecutionResultDict | None¶
Result for code execution metric.
- exact_match_metric_value: ExactMatchMetricValueDict | None¶
Results for exact match metric.
- pairwise_metric_result: PairwiseMetricResultDict | None¶
Result for pairwise metric.
- pointwise_metric_result: PointwiseMetricResultDict | None¶
Result for pointwise metric.
- rouge_metric_value: RougeMetricValueDict | None¶
Results for rouge metric.
- class genai.types.ApiAuth(**data)¶
Bases:
BaseModelThe generic reusable api auth config.
Deprecated. Please use AuthConfig (google/cloud/aiplatform/master/auth.proto) instead. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- api_key_config: ApiAuthApiKeyConfig | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ApiAuthApiKeyConfig(**data)¶
Bases:
BaseModelThe API secret. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- api_key_secret_version: str | None¶
- api_key_string: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ApiAuthApiKeyConfigDict¶
Bases:
TypedDictThe API secret. This data type is not supported in Gemini API.
- api_key_secret_version: str | None¶
Required. The SecretManager secret version resource name storing API key. e.g. projects/{project}/secrets/{secret}/versions/{version}
- api_key_string: str | None¶
The API key string. Either this or api_key_secret_version must be set.
- class genai.types.ApiAuthDict¶
Bases:
TypedDictThe generic reusable api auth config.
Deprecated. Please use AuthConfig (google/cloud/aiplatform/master/auth.proto) instead. This data type is not supported in Gemini API.
- api_key_config: ApiAuthApiKeyConfigDict | None¶
The API secret.
- class genai.types.ApiKeyConfig(**data)¶
Bases:
BaseModelConfig for authentication with API key.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- api_key_secret: str | None¶
- api_key_string: str | None¶
- http_element_location: HttpElementLocation | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str | None¶
- class genai.types.ApiKeyConfigDict¶
Bases:
TypedDictConfig for authentication with API key.
This data type is not supported in Gemini API.
- api_key_secret: str | None¶
//cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the specified resource.
- Type:
Optional. The name of the SecretManager secret version resource storing the API key. Format
- Type:
projects/{project}/secrets/{secrete}/versions/{version} - If both api_key_secret and api_key_string are specified, this field takes precedence over api_key_string. - If specified, the secretmanager.versions.access permission should be granted to Vertex AI Extension Service Agent (https
- api_key_string: str | None¶
Optional. The API key to be used in the request directly.
- http_element_location: HttpElementLocation | None¶
Optional. The location of the API key.
- name: str | None¶
//example.com/act?api_key=”, “api_key” would be the parameter name.
- Type:
Optional. The parameter name of the API key. E.g. If the API request is “https
- class genai.types.ApiSpec(*values)¶
Bases:
CaseInSensitiveEnumThe API spec that the external API implements.
This enum is not supported in Gemini API.
- API_SPEC_UNSPECIFIED = 'API_SPEC_UNSPECIFIED'¶
Unspecified API spec. This value should not be used.
- ELASTIC_SEARCH = 'ELASTIC_SEARCH'¶
Elastic search API spec.
- SIMPLE_SEARCH = 'SIMPLE_SEARCH'¶
Simple search API spec.
- class genai.types.AspectRatio(*values)¶
Bases:
CaseInSensitiveEnumThe aspect ratio for the image output.
- ASPECT_RATIO_EIGHT_BY_ONE = 'ASPECT_RATIO_EIGHT_BY_ONE'¶
1 aspect ratio.
- Type:
8
- ASPECT_RATIO_FIVE_BY_FOUR = 'ASPECT_RATIO_FIVE_BY_FOUR'¶
4 aspect ratio.
- Type:
5
- ASPECT_RATIO_FOUR_BY_FIVE = 'ASPECT_RATIO_FOUR_BY_FIVE'¶
5 aspect ratio.
- Type:
4
- ASPECT_RATIO_FOUR_BY_ONE = 'ASPECT_RATIO_FOUR_BY_ONE'¶
1 aspect ratio.
- Type:
4
- ASPECT_RATIO_FOUR_BY_THREE = 'ASPECT_RATIO_FOUR_BY_THREE'¶
3 aspect ratio.
- Type:
4
- ASPECT_RATIO_NINE_BY_SIXTEEN = 'ASPECT_RATIO_NINE_BY_SIXTEEN'¶
16 aspect ratio.
- Type:
9
- ASPECT_RATIO_ONE_BY_EIGHT = 'ASPECT_RATIO_ONE_BY_EIGHT'¶
8 aspect ratio.
- Type:
1
- ASPECT_RATIO_ONE_BY_FOUR = 'ASPECT_RATIO_ONE_BY_FOUR'¶
4 aspect ratio.
- Type:
1
- ASPECT_RATIO_ONE_BY_ONE = 'ASPECT_RATIO_ONE_BY_ONE'¶
1 aspect ratio.
- Type:
1
- ASPECT_RATIO_SIXTEEN_BY_NINE = 'ASPECT_RATIO_SIXTEEN_BY_NINE'¶
9 aspect ratio.
- Type:
16
- ASPECT_RATIO_THREE_BY_FOUR = 'ASPECT_RATIO_THREE_BY_FOUR'¶
4 aspect ratio.
- Type:
3
- ASPECT_RATIO_THREE_BY_TWO = 'ASPECT_RATIO_THREE_BY_TWO'¶
2 aspect ratio.
- Type:
3
- ASPECT_RATIO_TWENTY_ONE_BY_NINE = 'ASPECT_RATIO_TWENTY_ONE_BY_NINE'¶
9 aspect ratio.
- Type:
21
- ASPECT_RATIO_TWO_BY_THREE = 'ASPECT_RATIO_TWO_BY_THREE'¶
3 aspect ratio.
- Type:
2
- ASPECT_RATIO_UNSPECIFIED = 'ASPECT_RATIO_UNSPECIFIED'¶
Default value. This value is unused.
- class genai.types.AudioChunk(**data)¶
Bases:
BaseModelRepresentation of an audio chunk.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- data: bytes | None¶
- mime_type: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- source_metadata: LiveMusicSourceMetadata | None¶
- class genai.types.AudioChunkDict¶
Bases:
TypedDictRepresentation of an audio chunk.
- data: bytes | None¶
Raw bytes of audio data.
- mime_type: str | None¶
MIME type of the audio chunk.
- source_metadata: LiveMusicSourceMetadataDict | None¶
Prompts and config used for generating this audio chunk.
- class genai.types.AudioResponseFormat(**data)¶
Bases:
BaseModelConfiguration for audio-specific output formatting.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- bit_rate: int | None¶
- mime_type: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- sample_rate: int | None¶
- class genai.types.AudioResponseFormatDict¶
Bases:
TypedDictConfiguration for audio-specific output formatting.
- bit_rate: int | None¶
Optional. Bit rate in bits per second (bps). Only applicable for compressed formats (MP3, Opus).
- mime_type: str | None¶
Optional. The MIME type of the audio output.
- sample_rate: int | None¶
Optional. Sample rate for the generated audio in Hertz.
- class genai.types.AudioTranscriptionConfig(**data)¶
Bases:
BaseModelThe audio transcription configuration in Setup.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- adaptation_phrases: list[str] | None¶
- custom_vocabulary: list[str] | None¶
- diarization: bool | None¶
- language_auto: LanguageAuto | None¶
- language_codes: list[str] | None¶
- language_hints: LanguageHints | None¶
- mode: AudioTranscriptionConfigMode | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- word_timestamp: bool | None¶
- class genai.types.AudioTranscriptionConfigDict¶
Bases:
TypedDictThe audio transcription configuration in Setup.
- adaptation_phrases: list[str] | None¶
Deprecated. A list of phrases used for speech adaptation, which biases the ASR model to improve recognition of these specific terms.
- custom_vocabulary: list[str] | None¶
A list of custom vocabulary phrases, which biases the ASR model to improve recognition of these specific terms.
- diarization: bool | None¶
Configures speaker diarization.
- language_auto: LanguageAutoDict | None¶
Auto-detection is now the default when language_codes is omitted. This field will be removed in a future version.
- Type:
Deprecated
- language_codes: list[str] | None¶
Optional. BCP-47 language codes providing hints about the languages present in the audio. If omitted or empty, defaults to automatic language detection.
- language_hints: LanguageHintsDict | None¶
Use top-level language_codes instead. This field will be removed in a future version.
- Type:
Deprecated
- mode: AudioTranscriptionConfigMode | None¶
VERBATIM, SMART. If unspecified, defaults to VERBATIM transcription. In SMART mode, the model performs disfluency removal (eliminating filler words, repetitions, and false starts), light grammatical cleanup, automatic formatting (paragraphs, bullet points, numbered lists), and minor user edits (inline self-corrections). Timestamps and diarization are incompatible with mode SMART.
- Type:
Optional. Configures transcription mode. Supported values
- word_timestamp: bool | None¶
Configures word-level timestamp generation.
- class genai.types.AudioTranscriptionConfigMode(*values)¶
Bases:
CaseInSensitiveEnumTranscription mode.
- MODE_UNSPECIFIED = 'MODE_UNSPECIFIED'¶
Unspecified transcription mode.
- SMART = 'SMART'¶
Smart transcription mode.
- VERBATIM = 'VERBATIM'¶
Verbatim transcription mode.
- class genai.types.AuthConfig(**data)¶
Bases:
BaseModelThe authentication config to access the API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- api_key: str | None¶
- api_key_config: ApiKeyConfig | None¶
- google_service_account_config: AuthConfigGoogleServiceAccountConfig | None¶
- http_basic_auth_config: AuthConfigHttpBasicAuthConfig | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- oauth_config: AuthConfigOauthConfig | None¶
- oidc_config: AuthConfigOidcConfig | None¶
- class genai.types.AuthConfigDict¶
Bases:
TypedDictThe authentication config to access the API.
- api_key: str | None¶
The authentication config to access the API. Only API key is supported. This field is not supported in Gemini API.
- api_key_config: ApiKeyConfigDict | None¶
Config for API key auth.
- google_service_account_config: AuthConfigGoogleServiceAccountConfigDict | None¶
Config for Google Service Account auth.
- http_basic_auth_config: AuthConfigHttpBasicAuthConfigDict | None¶
Config for HTTP Basic auth.
- oauth_config: AuthConfigOauthConfigDict | None¶
Config for user oauth.
- oidc_config: AuthConfigOidcConfigDict | None¶
Config for user OIDC auth.
- class genai.types.AuthConfigGoogleServiceAccountConfig(**data)¶
Bases:
BaseModelConfig for Google Service Account Authentication.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- service_account: str | None¶
- class genai.types.AuthConfigGoogleServiceAccountConfigDict¶
Bases:
TypedDictConfig for Google Service Account Authentication.
This data type is not supported in Gemini API.
- service_account: str | None¶
//cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the specified service account. - If not specified, the Vertex AI Extension Service Agent will be used to execute the Extension.
- Type:
Optional. The service account that the extension execution service runs as. - If the service account is specified, the iam.serviceAccounts.getAccessToken permission should be granted to Vertex AI Extension Service Agent (https
- class genai.types.AuthConfigHttpBasicAuthConfig(**data)¶
Bases:
BaseModelConfig for HTTP Basic Authentication.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- credential_secret: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.AuthConfigHttpBasicAuthConfigDict¶
Bases:
TypedDictConfig for HTTP Basic Authentication.
This data type is not supported in Gemini API.
- credential_secret: str | None¶
//cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the specified resource.
- Type:
Required. The name of the SecretManager secret version resource storing the base64 encoded credentials. Format
- Type:
projects/{project}/secrets/{secrete}/versions/{version} - If specified, the secretmanager.versions.access permission should be granted to Vertex AI Extension Service Agent (https
- class genai.types.AuthConfigOauthConfig(**data)¶
Bases:
BaseModelConfig for user oauth. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- access_token: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- service_account: str | None¶
- class genai.types.AuthConfigOauthConfigDict¶
Bases:
TypedDictConfig for user oauth. This data type is not supported in Gemini API.
- access_token: str | None¶
Access token for extension endpoint. Only used to propagate token from [[ExecuteExtensionRequest.runtime_auth_config]] at request time.
- service_account: str | None¶
//cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the provided service account.
- Type:
The service account used to generate access tokens for executing the Extension. - If the service account is specified, the iam.serviceAccounts.getAccessToken permission should be granted to Vertex AI Extension Service Agent (https
- class genai.types.AuthConfigOidcConfig(**data)¶
Bases:
BaseModelConfig for user OIDC auth.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- id_token: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- service_account: str | None¶
- class genai.types.AuthConfigOidcConfigDict¶
Bases:
TypedDictConfig for user OIDC auth.
This data type is not supported in Gemini API.
- id_token: str | None¶
OpenID Connect formatted ID token for extension endpoint. Only used to propagate token from [[ExecuteExtensionRequest.runtime_auth_config]] at request time.
- service_account: str | None¶
//cloud.google.com/vertex-ai/docs/general/access-control#service-agents).
- Type:
The service account used to generate an OpenID Connect (OIDC)-compatible JWT token signed by the Google OIDC Provider (accounts.google.com) for extension endpoint (https
- Type:
//cloud.google.com/iam/docs/create-short-lived-credentials-direct#sa-credentials-oidc). - The audience for the token will be set to the URL in the server url defined in the OpenApi spec. - If the service account is provided, the service account should grant iam.serviceAccounts.getOpenIdToken permission to Vertex AI Extension Service Agent (https
- class genai.types.AuthToken(**data)¶
Bases:
BaseModelConfig for auth_tokens.create parameters.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- expire_time: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str | None¶
- new_session_expire_time: str | None¶
- uses: int | None¶
- class genai.types.AuthTokenDict¶
Bases:
TypedDictConfig for auth_tokens.create parameters.
- expire_time: str | None¶
Optional. Input only. Immutable. An optional time after which, when using the resulting token, messages in BidiGenerateContent sessions will be rejected. (Gemini may preemptively close the session after this time.) If not set then this defaults to 30 minutes in the future. If set, this value must be less than 20 hours in the future.
- name: str | None¶
The name of the auth token.
- new_session_expire_time: str | None¶
Optional. Input only. Immutable. The time after which new Live API sessions using the token resulting from this request will be rejected. If not set this defaults to 60 seconds in the future. If set, this value must be less than 20 hours in the future.
- uses: int | None¶
Optional. Input only. Immutable. The number of times the token can be used. If this value is zero then no limit is applied. Resuming a Live API session does not count as a use. If unspecified, the default is 1.
- class genai.types.AuthType(*values)¶
Bases:
CaseInSensitiveEnumType of auth scheme. This enum is not supported in Gemini API.
- API_KEY_AUTH = 'API_KEY_AUTH'¶
API Key Auth.
- AUTH_TYPE_UNSPECIFIED = 'AUTH_TYPE_UNSPECIFIED'¶
- GOOGLE_SERVICE_ACCOUNT_AUTH = 'GOOGLE_SERVICE_ACCOUNT_AUTH'¶
Google Service Account Auth.
- HTTP_BASIC_AUTH = 'HTTP_BASIC_AUTH'¶
HTTP Basic Auth.
- NO_AUTH = 'NO_AUTH'¶
No Auth.
- OAUTH = 'OAUTH'¶
OAuth auth.
- OIDC_AUTH = 'OIDC_AUTH'¶
OpenID Connect (OIDC) Auth.
- class genai.types.AutomaticActivityDetection(**data)¶
Bases:
BaseModelConfigures automatic detection of activity.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- disabled: bool | None¶
- end_of_speech_sensitivity: EndSensitivity | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- prefix_padding_ms: int | None¶
- silence_duration_ms: int | None¶
- start_of_speech_sensitivity: StartSensitivity | None¶
- class genai.types.AutomaticActivityDetectionDict¶
Bases:
TypedDictConfigures automatic detection of activity.
- disabled: bool | None¶
If enabled, detected voice and text input count as activity. If disabled, the client must send activity signals.
- end_of_speech_sensitivity: EndSensitivity | None¶
Determines how likely detected speech is ended.
- prefix_padding_ms: int | None¶
The required duration of detected speech before start-of-speech is committed. The lower this value the more sensitive the start-of-speech detection is and the shorter speech can be recognized. However, this also increases the probability of false positives.
- silence_duration_ms: int | None¶
The required duration of detected non-speech (e.g. silence) before end-of-speech is committed. The larger this value, the longer speech gaps can be without interrupting the user’s activity but this will increase the model’s latency.
- start_of_speech_sensitivity: StartSensitivity | None¶
Determines how likely speech is to be detected.
- class genai.types.AutomaticFunctionCallingConfig(**data)¶
Bases:
BaseModelThe configuration for automatic function calling.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- disable: bool | None¶
- ignore_call_history: bool | None¶
- maximum_remote_calls: int | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.AutomaticFunctionCallingConfigDict¶
Bases:
TypedDictThe configuration for automatic function calling.
- disable: bool | None¶
Whether to disable automatic function calling. If not set or set to False, will enable automatic function calling. If set to True, will disable automatic function calling.
- ignore_call_history: bool | None¶
If automatic function calling is enabled, whether to ignore call history to the response. If not set, SDK will set ignore_call_history to false, and will append the call history to GenerateContentResponse.automatic_function_calling_history.
- maximum_remote_calls: int | None¶
If automatic function calling is enabled, maximum number of remote calls for automatic function calling. This number should be a positive integer. If not set, SDK will set maximum number of remote calls to 10.
- class genai.types.AutoraterConfig(**data)¶
Bases:
BaseModelAutorater config used for evaluation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- autorater_model: str | None¶
- flip_enabled: bool | None¶
- generation_config: GenerationConfig | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- sampling_count: int | None¶
- class genai.types.AutoraterConfigDict¶
Bases:
TypedDictAutorater config used for evaluation.
- autorater_model: str | None¶
The fully qualified name of the publisher model or tuned autorater endpoint to use.
Publisher model format: projects/{project}/locations/{location}/publishers/{publisher}/models/{model}
Tuned model endpoint format: projects/{project}/locations/{location}/endpoints/{endpoint}
- flip_enabled: bool | None¶
Optional. Default is true. Whether to flip the candidate and baseline responses. This is only applicable to the pairwise metric. If enabled, also provide PairwiseMetricSpec.candidate_response_field_name and PairwiseMetricSpec.baseline_response_field_name. When rendering PairwiseMetricSpec.metric_prompt_template, the candidate and baseline fields will be flipped for half of the samples to reduce bias.
- generation_config: GenerationConfigDict | None¶
Configuration options for model generation and outputs.
- sampling_count: int | None¶
Number of samples for each instance in the dataset. If not specified, the default is 4. Minimum value is 1, maximum value is 32.
- class genai.types.AvatarConfig(**data)¶
Bases:
BaseModelConfigures the avatar to be used in the session.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- audio_bitrate_bps: int | None¶
- avatar_name: str | None¶
- customized_avatar: CustomizedAvatar | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- video_bitrate_bps: int | None¶
- class genai.types.AvatarConfigDict¶
Bases:
TypedDictConfigures the avatar to be used in the session.
- audio_bitrate_bps: int | None¶
The bitrate of compressed audio.
- avatar_name: str | None¶
Pre-built avatar id.
- customized_avatar: CustomizedAvatarDict | None¶
Customized avatar appearance with a reference image.
- video_bitrate_bps: int | None¶
The bitrate of compressed video output.
- class genai.types.BatchJob(**data)¶
Bases:
BaseModelConfig for batches.create return value.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- completion_stats: CompletionStats | None¶
- create_time: datetime | None¶
- dest: BatchJobDestination | None¶
- display_name: str | None¶
- property done: bool¶
Returns True if the batch job has ended.
- end_time: datetime | None¶
- model: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str | None¶
- output_info: BatchJobOutputInfo | None¶
- src: BatchJobSource | None¶
- start_time: datetime | None¶
- update_time: datetime | None¶
- class genai.types.BatchJobDestination(**data)¶
Bases:
BaseModelConfig for dest parameter.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- bigquery_uri: str | None¶
- file_name: str | None¶
- format: str | None¶
- gcs_uri: str | None¶
- inlined_embed_content_responses: list[InlinedEmbedContentResponse] | None¶
- inlined_responses: list[InlinedResponse] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- vertex_dataset: VertexMultimodalDatasetDestination | None¶
- class genai.types.BatchJobDestinationDict¶
Bases:
TypedDictConfig for dest parameter.
- bigquery_uri: str | None¶
The BigQuery URI to the output table.
- file_name: str | None¶
The Gemini Developer API’s file resource name of the output data (e.g. “files/12345”). The file will be a JSONL file with a single response per line. The responses will be GenerateContentResponse messages formatted as JSON. The responses will be written in the same order as the input requests.
- format: str | None¶
Storage format of the output files. Must be one of: ‘jsonl’, ‘bigquery’, ‘vertex-dataset’.
- gcs_uri: str | None¶
The Google Cloud Storage URI to the output file.
- inlined_embed_content_responses: list[InlinedEmbedContentResponseDict] | None¶
The responses to the requests in the batch. Returned when the batch was built using inlined requests. The responses will be in the same order as the input requests.
- inlined_responses: list[InlinedResponseDict] | None¶
The responses to the requests in the batch. Returned when the batch was built using inlined requests. The responses will be in the same order as the input requests.
- vertex_dataset: VertexMultimodalDatasetDestinationDict | None¶
This field is experimental and may change in future versions. The Vertex AI dataset destination.
- class genai.types.BatchJobDict¶
Bases:
TypedDictConfig for batches.create return value.
- completion_stats: CompletionStatsDict | None¶
Statistics on completed and failed prediction instances. This field is for Gemini Enterprise Agent Platform only.
- create_time: datetime | None¶
The time when the BatchJob was created.
- dest: BatchJobDestinationDict | None¶
Configuration for the output data.
- display_name: str | None¶
The display name of the BatchJob.
- end_time: datetime | None¶
The time when the BatchJob was completed. This field is for Gemini Enterprise Agent Platform only.
- error: JobErrorDict | None¶
Output only. Only populated when the job’s state is JOB_STATE_FAILED or JOB_STATE_CANCELLED.
- model: str | None¶
The name of the model that produces the predictions via the BatchJob.
- name: str | None¶
The resource name of the BatchJob. Output only.”.
- output_info: BatchJobOutputInfoDict | None¶
Information further describing the output of this job. Output only.
- src: BatchJobSourceDict | None¶
Configuration for the input data. This field is for Gemini Enterprise Agent Platform only.
- start_time: datetime | None¶
Output only. Time when the Job for the first time entered the JOB_STATE_RUNNING state.
- update_time: datetime | None¶
The time when the BatchJob was last updated.
- class genai.types.BatchJobOutputInfo(**data)¶
Bases:
BaseModelRepresents the output_info field in batch jobs.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- bigquery_output_table: str | None¶
- gcs_output_directory: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- vertex_multimodal_dataset_name: str | None¶
- class genai.types.BatchJobOutputInfoDict¶
Bases:
TypedDictRepresents the output_info field in batch jobs.
- bigquery_output_table: str | None¶
The name of the BigQuery table created, in predictions_TIMESTAMP format, into which the prediction output is written.
- gcs_output_directory: str | None¶
The full path of the Cloud Storage directory created, into which the prediction output is written.
- vertex_multimodal_dataset_name: str | None¶
This field is experimental and may change in future versions. The Vertex AI dataset name containing the output data.
- class genai.types.BatchJobSource(**data)¶
Bases:
BaseModelConfig for src parameter.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- bigquery_uri: str | None¶
- file_name: str | None¶
- format: str | None¶
- gcs_uri: list[str] | None¶
- inlined_requests: list[InlinedRequest] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- vertex_dataset_name: str | None¶
- class genai.types.BatchJobSourceDict¶
Bases:
TypedDictConfig for src parameter.
- bigquery_uri: str | None¶
The BigQuery URI to input table.
- file_name: str | None¶
The Gemini Developer API’s file resource name of the input data (e.g. “files/12345”).
- format: str | None¶
Storage format of the input files. Must be one of: ‘jsonl’, ‘bigquery’, ‘vertex-dataset’.
- gcs_uri: list[str] | None¶
The Google Cloud Storage URIs to input files.
- inlined_requests: list[InlinedRequestDict] | None¶
The Gemini Developer API’s inlined input data to run batch job.
- vertex_dataset_name: str | None¶
This field is experimental and may change in future versions. The Vertex AI dataset resource name to use as input. Must be of type multimodal.
- class genai.types.Behavior(*values)¶
Bases:
CaseInSensitiveEnumSpecifies the function Behavior.
If not specified, the system keeps the current function call behavior. This field is currently only supported by the BidiGenerateContent method.
- BLOCKING = 'BLOCKING'¶
If set, the system will wait to receive the function response before continuing the conversation.
- NON_BLOCKING = 'NON_BLOCKING'¶
If set, the system will not wait to receive the function response. Instead, it will attempt to handle function responses as they become available while maintaining the conversation between the user and the model.
- UNSPECIFIED = 'UNSPECIFIED'¶
This value is unspecified.
- class genai.types.BigQuerySource(**data)¶
Bases:
BaseModelThe BigQuery location for the input content.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- input_uri: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.BigQuerySourceDict¶
Bases:
TypedDictThe BigQuery location for the input content.
This data type is not supported in Gemini API.
- input_uri: str | None¶
bq://projectId.bqDatasetId.bqTableId.
- Type:
Required. BigQuery URI to a table, up to 2000 characters long. Accepted forms
- Type:
BigQuery path. For example
- class genai.types.BleuMetricValue(**data)¶
Bases:
BaseModelBleu metric value for an instance.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- score: float | None¶
- class genai.types.BleuMetricValueDict¶
Bases:
TypedDictBleu metric value for an instance.
This data type is not supported in Gemini API.
- score: float | None¶
Output only. Bleu score.
- class genai.types.BleuSpec(**data)¶
Bases:
BaseModelSpec for bleu metric.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- use_effective_order: bool | None¶
- class genai.types.BleuSpecDict¶
Bases:
TypedDictSpec for bleu metric.
- use_effective_order: bool | None¶
Optional. Whether to use_effective_order to compute bleu score.
- class genai.types.Blob(**data)¶
Bases:
BaseModelA content blob.
A Blob contains data of a specific media type. It is used to represent images, audio, and video.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- as_image()¶
Returns the Blob as a Image, or None if the Blob is not an image.
- Return type:
Optional[Image]
- data: bytes | None¶
- display_name: str | None¶
- mime_type: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.BlobDict¶
Bases:
TypedDictA content blob.
A Blob contains data of a specific media type. It is used to represent images, audio, and video.
- data: bytes | None¶
Required. The raw bytes of the data.
- display_name: str | None¶
Optional. The display name of the blob. Used to provide a label or filename to distinguish blobs. This field is only returned in PromptMessage for prompt management. It is used in the Gemini calls only when server-side tools (code_execution, google_search, and url_context) are enabled.
- mime_type: str | None¶
Required. The IANA standard MIME type of the source data.
- class genai.types.BlockedReason(*values)¶
Bases:
CaseInSensitiveEnumOutput only. The reason why the prompt was blocked.
- BLOCKED_REASON_UNSPECIFIED = 'BLOCKED_REASON_UNSPECIFIED'¶
The blocked reason is unspecified.
- BLOCKLIST = 'BLOCKLIST'¶
The prompt was blocked because it contains a term from the terminology blocklist.
- IMAGE_SAFETY = 'IMAGE_SAFETY'¶
The prompt was blocked because it contains content that is unsafe for image generation.
- JAILBREAK = 'JAILBREAK'¶
The prompt was blocked as a jailbreak attempt. This enum value is not supported in Gemini API.
- MODEL_ARMOR = 'MODEL_ARMOR'¶
The prompt was blocked by Model Armor. This enum value is not supported in Gemini API.
- OTHER = 'OTHER'¶
The prompt was blocked for other reasons. For example, it may be due to the prompt’s language, or because it contains other harmful content.
- PROHIBITED_CONTENT = 'PROHIBITED_CONTENT'¶
The prompt was blocked because it contains prohibited content.
- SAFETY = 'SAFETY'¶
The prompt was blocked for safety reasons.
- class genai.types.CachedContent(**data)¶
Bases:
BaseModelA resource used in LLM queries for users to explicitly specify what to cache.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- create_time: datetime | None¶
- display_name: str | None¶
- expire_time: datetime | None¶
- model: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str | None¶
- update_time: datetime | None¶
- usage_metadata: CachedContentUsageMetadata | None¶
- class genai.types.CachedContentDict¶
Bases:
TypedDictA resource used in LLM queries for users to explicitly specify what to cache.
- create_time: datetime | None¶
Creation time of the cache entry.
- display_name: str | None¶
The user-generated meaningful display name of the cached content.
- expire_time: datetime | None¶
Expiration time of the cached content.
- model: str | None¶
The name of the publisher model to use for cached content.
- name: str | None¶
The server-generated resource name of the cached content.
- update_time: datetime | None¶
When the cache entry was last updated in UTC time.
- usage_metadata: CachedContentUsageMetadataDict | None¶
Metadata on the usage of the cached content.
- class genai.types.CachedContentUsageMetadata(**data)¶
Bases:
BaseModelMetadata on the usage of the cached content.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- audio_duration_seconds: int | None¶
- image_count: int | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- text_count: int | None¶
- total_token_count: int | None¶
- video_duration_seconds: int | None¶
- class genai.types.CachedContentUsageMetadataDict¶
Bases:
TypedDictMetadata on the usage of the cached content.
- audio_duration_seconds: int | None¶
Duration of audio in seconds. This field is not supported in Gemini API.
- image_count: int | None¶
Number of images. This field is not supported in Gemini API.
- text_count: int | None¶
Number of text characters. This field is not supported in Gemini API.
- total_token_count: int | None¶
Total number of tokens that the cached content consumes.
- video_duration_seconds: int | None¶
Duration of video in seconds. This field is not supported in Gemini API.
- class genai.types.CancelBatchJobConfig(**data)¶
Bases:
BaseModelOptional parameters.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.CancelBatchJobConfigDict¶
Bases:
TypedDictOptional parameters.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.CancelTuningJobConfig(**data)¶
Bases:
BaseModelOptional parameters for tunings.cancel method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.CancelTuningJobConfigDict¶
Bases:
TypedDictOptional parameters for tunings.cancel method.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.CancelTuningJobResponse(**data)¶
Bases:
BaseModelEmpty response for tunings.cancel method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- sdk_http_response: HttpResponse | None¶
- class genai.types.CancelTuningJobResponseDict¶
Bases:
TypedDictEmpty response for tunings.cancel method.
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.Candidate(**data)¶
Bases:
BaseModelA response candidate generated from the model.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- avg_logprobs: float | None¶
- citation_metadata: CitationMetadata | None¶
- continuation_token: bytes | None¶
- finish_message: str | None¶
- finish_reason: FinishReason | None¶
- grounding_metadata: GroundingMetadata | None¶
- index: int | None¶
- logprobs_result: LogprobsResult | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- safety_ratings: list[SafetyRating] | None¶
- token_count: int | None¶
- url_context_metadata: UrlContextMetadata | None¶
- class genai.types.CandidateDict¶
Bases:
TypedDictA response candidate generated from the model.
- avg_logprobs: float | None¶
Output only. The average log probability of the tokens in this candidate. This is a length-normalized score that can be used to compare the quality of candidates of different lengths. A higher average log probability suggests a more confident and coherent response.
- citation_metadata: CitationMetadataDict | None¶
Source attribution of the generated content.
- content: ContentDict | None¶
Contains the multi-part content of the response.
- continuation_token: bytes | None¶
An opaque continuation token returned when finish_reason is CONTINUATION. Pass it in a subsequent request to continue generation.
- finish_message: str | None¶
Describes the reason the model stopped generating tokens.
- finish_reason: FinishReason | None¶
The reason why the model stopped generating tokens. If empty, the model has not stopped generating the tokens.
- grounding_metadata: GroundingMetadataDict | None¶
Output only. Metadata returned when grounding is enabled. It contains the sources used to ground the generated content.
- index: int | None¶
Output only. The 0-based index of this candidate in the list of generated responses. This is useful for distinguishing between multiple candidates when candidate_count > 1.
- logprobs_result: LogprobsResultDict | None¶
Output only. The detailed log probability information for the tokens in this candidate. This is useful for debugging, understanding model uncertainty, and identifying potential “hallucinations”.
- safety_ratings: list[SafetyRatingDict] | None¶
Output only. A list of ratings for the safety of a response candidate. There is at most one rating per category.
- token_count: int | None¶
Number of tokens for this candidate.
- url_context_metadata: UrlContextMetadataDict | None¶
Output only. Metadata returned when the model uses the url_context tool to get information from a user-provided URL.
- class genai.types.Checkpoint(**data)¶
Bases:
BaseModelDescribes the machine learning model version checkpoint.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- checkpoint_id: str | None¶
- epoch: int | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- step: int | None¶
- class genai.types.CheckpointDict¶
Bases:
TypedDictDescribes the machine learning model version checkpoint.
- checkpoint_id: str | None¶
The ID of the checkpoint.
- epoch: int | None¶
The epoch of the checkpoint.
- step: int | None¶
The step of the checkpoint.
- class genai.types.ChunkingConfig(**data)¶
Bases:
BaseModelConfig for telling the service how to chunk the file.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- white_space_config: WhiteSpaceConfig | None¶
- class genai.types.ChunkingConfigDict¶
Bases:
TypedDictConfig for telling the service how to chunk the file.
- white_space_config: WhiteSpaceConfigDict | None¶
White space chunking configuration.
- class genai.types.Citation(**data)¶
Bases:
BaseModelA citation for a piece of generatedcontent.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- end_index: int | None¶
- license: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- publication_date: GoogleTypeDate | None¶
- start_index: int | None¶
- title: str | None¶
- uri: str | None¶
- class genai.types.CitationDict¶
Bases:
TypedDictA citation for a piece of generatedcontent.
This data type is not supported in Gemini API.
- end_index: int | None¶
Output only. The end index of the citation in the content.
- license: str | None¶
Output only. The license of the source of the citation.
- publication_date: GoogleTypeDateDict | None¶
Output only. The publication date of the source of the citation.
- start_index: int | None¶
Output only. The start index of the citation in the content.
- title: str | None¶
Output only. The title of the source of the citation.
- uri: str | None¶
Output only. The URI of the source of the citation.
- class genai.types.CitationMetadata(**data)¶
Bases:
BaseModelCitation information when the model quotes another source.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.CitationMetadataDict¶
Bases:
TypedDictCitation information when the model quotes another source.
- citations: list[CitationDict] | None¶
Contains citation information when the model directly quotes, at length, from another source. Can include traditional websites and code repositories.
- class genai.types.CodeExecutionResult(**data)¶
Bases:
BaseModelResult of executing the ExecutableCode.
Generated only when the CodeExecution tool is used.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- id: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- output: str | None¶
- class genai.types.CodeExecutionResultDict¶
Bases:
TypedDictResult of executing the ExecutableCode.
Generated only when the CodeExecution tool is used.
- id: str | None¶
Optional. The identifier of the ExecutableCode part this result is for. Only populated if the corresponding ExecutableCode has an id.
- output: str | None¶
Optional. Contains stdout when code execution is successful, stderr or other description otherwise.
- class genai.types.CompletionStats(**data)¶
Bases:
BaseModelSuccess and error statistics of processing multiple entities (for example, DataItems or structured data rows) in batch.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- failed_count: int | None¶
- incomplete_count: int | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- successful_count: int | None¶
- successful_forecast_point_count: int | None¶
- class genai.types.CompletionStatsDict¶
Bases:
TypedDictSuccess and error statistics of processing multiple entities (for example, DataItems or structured data rows) in batch.
This data type is not supported in Gemini API.
- failed_count: int | None¶
Output only. The number of entities for which any error was encountered.
- incomplete_count: int | None¶
Output only. In cases when enough errors are encountered a job, pipeline, or operation may be failed as a whole. Below is the number of entities for which the processing had not been finished (either in successful or failed state). Set to -1 if the number is unknown (for example, the operation failed before the total entity number could be collected).
- successful_count: int | None¶
Output only. The number of entities that had been processed successfully.
- successful_forecast_point_count: int | None¶
Output only. The number of the successful forecast points that are generated by the forecasting model. This is ONLY used by the forecasting batch prediction.
- class genai.types.CompositeReinforcementTuningRewardConfig(**data)¶
Bases:
BaseModelComposite reinforcement tuning reward config.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- weighted_reward_configs: list[CompositeReinforcementTuningRewardConfigWeightedRewardConfig] | None¶
- class genai.types.CompositeReinforcementTuningRewardConfigDict¶
Bases:
TypedDictComposite reinforcement tuning reward config.
- weighted_reward_configs: list[CompositeReinforcementTuningRewardConfigWeightedRewardConfigDict] | None¶
List of reward function configurations with weights.
- class genai.types.CompositeReinforcementTuningRewardConfigWeightedRewardConfig(**data)¶
Bases:
BaseModelComposite reinforcement tuning reward config weighted reward config.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- reward_config: SingleReinforcementTuningRewardConfig | None¶
- weight: float | None¶
- class genai.types.CompositeReinforcementTuningRewardConfigWeightedRewardConfigDict¶
Bases:
TypedDictComposite reinforcement tuning reward config weighted reward config.
- reward_config: SingleReinforcementTuningRewardConfigDict | None¶
Single reward configuration.
- weight: float | None¶
How much this single reward contributes to the total overall reward. Total reward is a linear combination of single rewards with their corresponding weights, i.e.,
` total_reward = ( weight_a * reward_a + weight_b * reward_b + ... ) / (weight_a + weight_b + ...) `
- class genai.types.ComputationBasedMetricSpec(**data)¶
Bases:
BaseModelSpecification for a computation based metric.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- parameters: dict[str, Any] | None¶
- type: ComputationBasedMetricType | None¶
- class genai.types.ComputationBasedMetricSpecDict¶
Bases:
TypedDictSpecification for a computation based metric.
- parameters: dict[str, Any] | None¶
“rougeL”, “split_summaries”: True, “use_stemmer”: True}. BLEU example: {“use_effective_order”: True}.
- Type:
A map of parameters for the metric. ROUGE example
- Type:
{“rouge_type”
- type: ComputationBasedMetricType | None¶
The type of the computation based metric.
- class genai.types.ComputationBasedMetricType(*values)¶
Bases:
CaseInSensitiveEnumRepresents the type of the computation based metric.
- BLEU = 'BLEU'¶
BLEU metric.
- COMPUTATION_BASED_METRIC_TYPE_UNSPECIFIED = 'COMPUTATION_BASED_METRIC_TYPE_UNSPECIFIED'¶
Computation based metric type is unspecified.
- EXACT_MATCH = 'EXACT_MATCH'¶
Exact match metric.
- ROUGE = 'ROUGE'¶
ROUGE metric.
- class genai.types.ComputeTokensConfig(**data)¶
Bases:
BaseModelOptional parameters for computing tokens.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ComputeTokensConfigDict¶
Bases:
TypedDictOptional parameters for computing tokens.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.ComputeTokensResponse(**data)¶
Bases:
BaseModelResponse for computing tokens.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- sdk_http_response: HttpResponse | None¶
- tokens_info: list[TokensInfo] | None¶
- class genai.types.ComputeTokensResponseDict¶
Bases:
TypedDictResponse for computing tokens.
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- tokens_info: list[TokensInfoDict] | None¶
Lists of tokens info from the input. A ComputeTokensRequest could have multiple instances with a prompt in each instance. We also need to return lists of tokens info for the request with multiple instances.
- class genai.types.ComputeTokensResult(**data)¶
Bases:
BaseModelLocal tokenizer compute tokens result.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- tokens_info: list[TokensInfo] | None¶
- class genai.types.ComputeTokensResultDict¶
Bases:
TypedDictLocal tokenizer compute tokens result.
- tokens_info: list[TokensInfoDict] | None¶
Lists of tokens info from the input.
- class genai.types.ComputerUse(**data)¶
Bases:
BaseModelTool to support computer use.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- disabled_safety_policies: list[SafetyPolicy] | None¶
- enable_prompt_injection_detection: bool | None¶
- environment: Environment | None¶
- excluded_predefined_functions: list[str] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ComputerUseDict¶
Bases:
TypedDictTool to support computer use.
- disabled_safety_policies: list[SafetyPolicy] | None¶
Optional. Disabled safety policies for computer use.
- enable_prompt_injection_detection: bool | None¶
Optional. Enables the prompt injection detection check on computer-use request.
- environment: Environment | None¶
Required. The environment being operated.
- excluded_predefined_functions: list[str] | None¶
Using a more restricted / different action space. 2. Improving the definitions / instructions of predefined functions.
- Type:
Optional. By default, [predefined functions](https
- Type:
//cloud.google.com/vertex-ai/generative-ai/docs/computer-use#supported-actions) are included in the final model call. Some of them can be explicitly excluded from being automatically included. This can serve two purposes
- class genai.types.Content(**data)¶
Bases:
BaseModelContains the multi-part content of a message.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- role: str | None¶
- class genai.types.ContentDict¶
Bases:
TypedDictContains the multi-part content of a message.
- parts: list[PartDict] | None¶
List of parts that constitute a single message. Each part may have a different IANA MIME type.
- role: str | None¶
Optional. The producer of the content. Must be either ‘user’ or ‘model’. If not set, the service will default to ‘user’.
- class genai.types.ContentEmbedding(**data)¶
Bases:
BaseModelThe embedding generated from an input content.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- statistics: ContentEmbeddingStatistics | None¶
- values: list[float] | None¶
- class genai.types.ContentEmbeddingDict¶
Bases:
TypedDictThe embedding generated from an input content.
- statistics: ContentEmbeddingStatisticsDict | None¶
Gemini Enterprise Agent Platform only. Statistics of the input text associated with this embedding.
- class genai.types.ContentEmbeddingStatistics(**data)¶
Bases:
BaseModelStatistics of the input text associated with the result of content embedding.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- token_count: float | None¶
- tokens_details: list[ModalityTokenCount] | None¶
- truncated: bool | None¶
- class genai.types.ContentEmbeddingStatisticsDict¶
Bases:
TypedDictStatistics of the input text associated with the result of content embedding.
- token_count: float | None¶
Gemini Enterprise Agent Platform only. Number of tokens of the input text.
- tokens_details: list[ModalityTokenCountDict] | None¶
Gemini Enterprise Agent Platform only. List of modalities and their token count for the input content.
- truncated: bool | None¶
Gemini Enterprise Agent Platform only. If the input text was truncated due to having a length longer than the allowed maximum input.
- class genai.types.ContentReferenceImage(**data)¶
Bases:
BaseModelA content reference image.
A content reference image represents a subject to reference (ex. person, product, animal) provided by the user. It can optionally be provided in addition to a style reference image (ex. background, style reference).
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- reference_id: int | None¶
- reference_type: str | None¶
- class genai.types.ContentReferenceImageDict¶
Bases:
TypedDictA content reference image.
A content reference image represents a subject to reference (ex. person, product, animal) provided by the user. It can optionally be provided in addition to a style reference image (ex. background, style reference).
- reference_id: int | None¶
The id of the reference image.
- reference_type: str | None¶
The type of the reference image. Only set by the SDK.
- class genai.types.ContextWindowCompressionConfig(**data)¶
Bases:
BaseModelEnables context window compression – mechanism managing model context window so it does not exceed given length.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- sliding_window: SlidingWindow | None¶
- trigger_tokens: int | None¶
- class genai.types.ContextWindowCompressionConfigDict¶
Bases:
TypedDictEnables context window compression – mechanism managing model context window so it does not exceed given length.
- sliding_window: SlidingWindowDict | None¶
Sliding window compression mechanism.
- trigger_tokens: int | None¶
Number of tokens (before running turn) that triggers context window compression mechanism.
- class genai.types.ControlReferenceConfig(**data)¶
Bases:
BaseModelConfiguration for a Control reference image.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- control_type: ControlReferenceType | None¶
- enable_control_image_computation: bool | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ControlReferenceConfigDict¶
Bases:
TypedDictConfiguration for a Control reference image.
- control_type: ControlReferenceType | None¶
The type of control reference image to use.
- enable_control_image_computation: bool | None¶
Defaults to False. When set to True, the control image will be computed by the model based on the control type. When set to False, the control image must be provided by the user.
- class genai.types.ControlReferenceImage(**data)¶
Bases:
BaseModelA control reference image.
The image of the control reference image is either a control image provided by the user, or a regular image which the backend will use to generate a control image of. In the case of the latter, the enable_control_image_computation field in the config should be set to True.
A control image is an image that represents a sketch image of areas for the model to fill in based on the prompt.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- config: ControlReferenceConfig | None¶
Re-map config to control_reference_config to send to API.
- control_image_config: ControlReferenceConfig | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- reference_id: int | None¶
- reference_type: str | None¶
- class genai.types.ControlReferenceImageDict¶
Bases:
TypedDictA control reference image.
The image of the control reference image is either a control image provided by the user, or a regular image which the backend will use to generate a control image of. In the case of the latter, the enable_control_image_computation field in the config should be set to True.
A control image is an image that represents a sketch image of areas for the model to fill in based on the prompt.
- config: ControlReferenceConfigDict | None¶
Configuration for the control reference image.
- reference_id: int | None¶
The id of the reference image.
- reference_type: str | None¶
The type of the reference image. Only set by the SDK.
- class genai.types.ControlReferenceType(*values)¶
Bases:
CaseInSensitiveEnumEnum representing the control type of a control reference image.
- CONTROL_TYPE_CANNY = 'CONTROL_TYPE_CANNY'¶
- CONTROL_TYPE_DEFAULT = 'CONTROL_TYPE_DEFAULT'¶
- CONTROL_TYPE_FACE_MESH = 'CONTROL_TYPE_FACE_MESH'¶
- CONTROL_TYPE_SCRIBBLE = 'CONTROL_TYPE_SCRIBBLE'¶
- class genai.types.CountTokensConfig(**data)¶
Bases:
BaseModelConfig for the count_tokens method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- generation_config: GenerationConfig | None¶
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.CountTokensConfigDict¶
Bases:
TypedDictConfig for the count_tokens method.
- generation_config: GenerationConfigDict | None¶
Configuration that the model uses to generate the response. Not supported by the Gemini Developer API.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.CountTokensResponse(**data)¶
Bases:
BaseModelResponse for counting tokens.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- cached_content_token_count: int | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- sdk_http_response: HttpResponse | None¶
- total_tokens: int | None¶
- class genai.types.CountTokensResponseDict¶
Bases:
TypedDictResponse for counting tokens.
- cached_content_token_count: int | None¶
Number of tokens in the cached part of the prompt (the cached content).
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- total_tokens: int | None¶
Total number of tokens.
- class genai.types.CountTokensResult(**data)¶
Bases:
BaseModelLocal tokenizer count tokens result.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- total_tokens: int | None¶
- class genai.types.CountTokensResultDict¶
Bases:
TypedDictLocal tokenizer count tokens result.
- total_tokens: int | None¶
The total number of tokens.
- class genai.types.CreateAuthTokenConfig(**data)¶
Bases:
BaseModelOptional parameters.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- expire_time: datetime | None¶
- http_options: HttpOptions | None¶
- live_connect_constraints: LiveConnectConstraints | None¶
- lock_additional_fields: list[str] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- new_session_expire_time: datetime | None¶
- uses: int | None¶
- class genai.types.CreateAuthTokenConfigDict¶
Bases:
TypedDictOptional parameters.
- expire_time: datetime | None¶
An optional time after which, when using the resulting token, messages in Live API sessions will be rejected. (Gemini may preemptively close the session after this time.)
If not set then this defaults to 30 minutes in the future. If set, this value must be less than 20 hours in the future.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- live_connect_constraints: LiveConnectConstraintsDict | None¶
Configuration specific to Live API connections created using this token.
- lock_additional_fields: list[str] | None¶
Additional fields to lock in the effective LiveConnectParameters.
- new_session_expire_time: datetime | None¶
The time after which new Live API sessions using the token resulting from this request will be rejected.
If not set this defaults to 60 seconds in the future. If set, this value must be less than 20 hours in the future.
- uses: int | None¶
The number of times the token can be used. If this value is zero then no limit is applied. Default is 1. Resuming a Live API session does not count as a use.
- class genai.types.CreateAuthTokenParameters(**data)¶
Bases:
BaseModelConfig for auth_tokens.create parameters.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- config: CreateAuthTokenConfig | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.CreateAuthTokenParametersDict¶
Bases:
TypedDictConfig for auth_tokens.create parameters.
- config: CreateAuthTokenConfigDict | None¶
Optional parameters for the request.
- class genai.types.CreateBatchJobConfig(**data)¶
Bases:
BaseModelConfig for optional parameters.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- dest: BatchJobDestination | str | None¶
- display_name: str | None¶
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- webhook_config: WebhookConfig | None¶
- class genai.types.CreateBatchJobConfigDict¶
Bases:
TypedDictConfig for optional parameters.
- dest: BatchJobDestination | str | BatchJobDestinationDict | None¶
GCS or BigQuery URI prefix for the output predictions. Example: “gs://path/to/output/data” or “bq://projectId.bqDatasetId.bqTableId”.
- display_name: str | None¶
The user-defined name of this BatchJob.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- webhook_config: WebhookConfigDict | None¶
Webhook configuration for receiving notifications when the batch operation completes.
- class genai.types.CreateCachedContentConfig(**data)¶
Bases:
BaseModelOptional configuration for cached content creation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- contents: Content | str | Image | File | Part | list[str | Image | File | Part] | list[Content | str | Image | File | Part | list[str | Image | File | Part]] | None¶
- display_name: str | None¶
- expire_time: datetime | None¶
- http_options: HttpOptions | None¶
- kms_key_name: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- tool_config: ToolConfig | None¶
- ttl: str | None¶
- class genai.types.CreateCachedContentConfigDict¶
Bases:
TypedDictOptional configuration for cached content creation.
- contents: Content | ContentDict | str | Image | File | FileDict | Part | PartDict | list[str | Image | File | FileDict | Part | PartDict] | list[Content | ContentDict | str | Image | File | FileDict | Part | PartDict | list[str | Image | File | FileDict | Part | PartDict]] | None¶
The content to cache.
- display_name: str | None¶
The user-generated meaningful display name of the cached content.
- expire_time: datetime | None¶
01:23Z.
- Type:
Timestamp of when this resource is considered expired. Uses RFC 3339 format, Example
- Type:
2014-10-02T15
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- kms_key_name: str | None¶
The Cloud KMS resource identifier of the customer managed encryption key used to protect a resource. The key needs to be in the same region as where the compute resource is created. See https://cloud.google.com/vertex-ai/docs/general/cmek for more details. If this is set, then all created CachedContent objects will be encrypted with the provided encryption key. Allowed formats: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}
- system_instruction: Content | ContentDict | str | Image | File | FileDict | Part | PartDict | list[str | Image | File | FileDict | Part | PartDict] | None¶
Developer set system instruction.
- tool_config: ToolConfigDict | None¶
Configuration for the tools to use. This config is shared for all tools.
- ttl: str | None¶
“3.5s”.
- Type:
The TTL for this resource. The expiration time is computed
- Type:
now + TTL. It is a duration string, with up to nine fractional digits, terminated by ‘s’. Example
- class genai.types.CreateEmbeddingsBatchJobConfig(**data)¶
Bases:
BaseModelConfig for optional parameters.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- display_name: str | None¶
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.CreateEmbeddingsBatchJobConfigDict¶
Bases:
TypedDictConfig for optional parameters.
- display_name: str | None¶
The user-defined name of this BatchJob.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.CreateFileConfig(**data)¶
Bases:
BaseModelUsed to override the default configuration.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- should_return_http_response: bool | None¶
- class genai.types.CreateFileConfigDict¶
Bases:
TypedDictUsed to override the default configuration.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- should_return_http_response: bool | None¶
If true, the raw HTTP response will be returned in the ‘sdk_http_response’ field.
- class genai.types.CreateFileResponse(**data)¶
Bases:
BaseModelResponse for the create file method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- sdk_http_response: HttpResponse | None¶
- class genai.types.CreateFileResponseDict¶
Bases:
TypedDictResponse for the create file method.
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.CreateFileSearchStoreConfig(**data)¶
Bases:
BaseModelOptional parameters for creating a file search store.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- display_name: str | None¶
- embedding_model: str | None¶
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.CreateFileSearchStoreConfigDict¶
Bases:
TypedDictOptional parameters for creating a file search store.
- display_name: str | None¶
The human-readable display name for the file search store.
- embedding_model: str | None¶
The embedding model to use for the FileSearchStore. Format: models/{model}. If not specified, the default embedding model will be used.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.CreateTuningJobConfig(**data)¶
Bases:
BaseModelFine-tuning job creation request - optional fields.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- adapter_size: AdapterSize | None¶
- base_teacher_model: str | None¶
- batch_size: int | None¶
- beta: float | None¶
- checkpoint_interval: int | None¶
- composite_reward_config: CompositeReinforcementTuningRewardConfig | None¶
- custom_base_model: str | None¶
- description: str | None¶
- encryption_spec: EncryptionSpec | None¶
- epoch_count: int | None¶
- evaluate_interval: int | None¶
- evaluation_config: EvaluationConfig | None¶
- export_last_checkpoint_only: bool | None¶
- http_options: HttpOptions | None¶
- labels: dict[str, str] | None¶
- learning_rate: float | None¶
- learning_rate_multiplier: float | None¶
- max_output_tokens: int | None¶
- method: TuningMethod | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- output_uri: str | None¶
- pre_tuned_model_checkpoint_id: str | None¶
- reward_config: SingleReinforcementTuningRewardConfig | None¶
- samples_per_prompt: int | None¶
- sft_loss_weight_multiplier: float | None¶
- thinking_level: ReinforcementTuningThinkingLevel | None¶
- tuned_model_display_name: str | None¶
- tuned_teacher_model_source: str | None¶
- tuning_mode: TuningMode | None¶
- validation_dataset: TuningValidationDataset | None¶
- validation_dataset_uri: str | None¶
- class genai.types.CreateTuningJobConfigDict¶
Bases:
TypedDictFine-tuning job creation request - optional fields.
- adapter_size: AdapterSize | None¶
Adapter size for tuning.
- base_teacher_model: str | None¶
The base teacher model that is being distilled. Distillation only.
- batch_size: int | None¶
The batch size hyperparameter for tuning. This is only supported for OSS models in Gemini Enterprise Agent Platform.
- beta: float | None¶
Weight for KL Divergence regularization, Preference Optimization tuning only.
- checkpoint_interval: int | None¶
How often at steps to save checkpoints during training. Reinforcement tuning only.
- composite_reward_config: CompositeReinforcementTuningRewardConfigDict | None¶
Composite reward function configuration for reinforcement tuning. Reinforcement tuning only.
- custom_base_model: str | None¶
Custom base model for tuning. This is only supported for OSS models in Gemini Enterprise Agent Platform.
- description: str | None¶
The description of the TuningJob
- encryption_spec: EncryptionSpecDict | None¶
The encryption spec of the tuning job. Customer-managed encryption key options for a TuningJob. If this is set, then all resources created by the TuningJob will be encrypted with provided encryption key.
- epoch_count: int | None¶
Number of complete passes the model makes over the entire training dataset during training.
- evaluate_interval: int | None¶
How often at steps to evaluate the tuning job during training. Reinforcement tuning only.
- evaluation_config: EvaluationConfigDict | None¶
Evaluation config for the tuning job.
- export_last_checkpoint_only: bool | None¶
If set to true, disable intermediate checkpoints and only the last checkpoint will be exported. Otherwise, enable intermediate checkpoints.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- labels: dict[str, str] | None¶
//goo.gl/xmQnxf for more information and examples of labels.
- Type:
Optional. The labels with user-defined metadata to organize TuningJob and generated resources such as Model and Endpoint. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https
- learning_rate: float | None¶
The learning rate for tuning. OSS models only. Mutually exclusive with learning_rate_multiplier.
- learning_rate_multiplier: float | None¶
Multiplier for adjusting the default learning rate. 1P models only. Mutually exclusive with learning_rate.
- max_output_tokens: int | None¶
The maximum number of tokens to generate per prompt. Reinforcement tuning only.
- method: TuningMethod | None¶
The method to use for tuning (SUPERVISED_FINE_TUNING or PREFERENCE_TUNING or DISTILLATION or REINFORCEMENT_TUNING). If not set, the default method (SFT) will be used.
- output_uri: str | None¶
The Google Cloud Storage location where the tuning job outputs are written.
- pre_tuned_model_checkpoint_id: str | None¶
The optional checkpoint id of the pre-tuned model to use for tuning, if applicable.
- reward_config: SingleReinforcementTuningRewardConfigDict | None¶
Reward function configuration for reinforcement tuning. Reinforcement tuning only.
- samples_per_prompt: int | None¶
Number of different responses to generate per prompt during tuning. Reinforcement tuning only.
- sft_loss_weight_multiplier: float | None¶
Multiplier for adjusting the weight of the SFT loss. Distillation only.
- thinking_level: ReinforcementTuningThinkingLevel | None¶
Indicates the maximum thinking depth. Use with earlier models shall result in error. Reinforcement tuning only.
- tuned_model_display_name: str | None¶
The display name of the tuned Model. The name can be up to 128 characters long and can consist of any UTF-8 characters.
- tuned_teacher_model_source: str | None¶
The resource name of the Tuned teacher model. Distillation only.
- tuning_mode: TuningMode | None¶
Tuning mode for tuning.
- validation_dataset: TuningValidationDatasetDict | None¶
Validation dataset for tuning. The dataset must be formatted as a JSONL file.
- validation_dataset_uri: str | None¶
Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file. If no validation dataset is provided, by default the API splits 25% of the training dataset or 50 examples, whichever is larger, as the validation dataset. Reinforcement tuning only.
- class genai.types.CreateTuningJobParameters(**data)¶
Bases:
BaseModelFine-tuning job creation parameters - optional fields.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- base_model: str | None¶
- config: CreateTuningJobConfig | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- training_dataset: TuningDataset | None¶
- class genai.types.CreateTuningJobParametersDict¶
Bases:
TypedDictFine-tuning job creation parameters - optional fields.
- base_model: str | None¶
The base model that is being tuned, e.g., “gemini-flash-latest”.
- config: CreateTuningJobConfigDict | None¶
Configuration for the tuning job.
- training_dataset: TuningDatasetDict | None¶
Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file.
- class genai.types.CustomCodeExecutionResult(**data)¶
Bases:
BaseModelResult for custom code execution metric.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- score: float | None¶
- class genai.types.CustomCodeExecutionResultDict¶
Bases:
TypedDictResult for custom code execution metric.
This data type is not supported in Gemini API.
- score: float | None¶
Output only. Custom code execution score.
- class genai.types.CustomCodeExecutionSpec(**data)¶
Bases:
BaseModelSpecifies a metric that is computed by running user-defined Python functions remotely.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- code_execution_region: str | None¶
- evaluation_function: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.CustomCodeExecutionSpecDict¶
Bases:
TypedDictSpecifies a metric that is computed by running user-defined Python functions remotely.
- code_execution_region: str | None¶
//cloud.google.com/vertex-ai/generative-ai/docs/agent-engine/locations). If unset, the request’s originating region is used; requests from regions where the sandbox is unavailable will fail with UNIMPLEMENTED.
- Type:
Optional. The region to use for code execution. If set, the Code Execution Sandbox will be invoked in the specified region regardless of the request’s originating region. Must be a region where the Code Execution Sandbox is available. For the current list of [supported regions](https
- evaluation_function: str | None¶
A string representing a user-defined function for evaluation. Expected user to define the following function, e.g.:
def evaluate(instance: dict[str, Any]) -> float:
Please include this function signature in the code snippet. Instance is the evaluation instance, any fields populated in the instance are available to the function as instance[field_name].
- class genai.types.CustomMetadata(**data)¶
Bases:
BaseModelUser provided metadata stored as key-value pairs.
This data type is not supported in Vertex AI.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- key: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- numeric_value: float | None¶
- string_list_value: StringList | None¶
- string_value: str | None¶
- class genai.types.CustomMetadataDict¶
Bases:
TypedDictUser provided metadata stored as key-value pairs.
This data type is not supported in Vertex AI.
- key: str | None¶
Required. The key of the metadata to store.
- numeric_value: float | None¶
The numeric value of the metadata to store.
- string_list_value: StringListDict | None¶
The StringList value of the metadata to store.
- string_value: str | None¶
The string value of the metadata to store.
- class genai.types.CustomOutput(**data)¶
Bases:
BaseModelSpec for custom output. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.CustomOutputDict¶
Bases:
TypedDictSpec for custom output. This data type is not supported in Gemini API.
- raw_outputs: RawOutputDict | None¶
Output only. List of raw output strings.
- class genai.types.CustomOutputFormatConfig(**data)¶
Bases:
BaseModelConfig for custom output format.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- return_raw_output: bool | None¶
- class genai.types.CustomOutputFormatConfigDict¶
Bases:
TypedDictConfig for custom output format.
- return_raw_output: bool | None¶
Optional. Whether to return raw output.
- class genai.types.CustomizedAvatar(**data)¶
Bases:
BaseModelConfigures the customized avatar to be used in the session.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- image_data: bytes | None¶
- image_mime_type: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.CustomizedAvatarDict¶
Bases:
TypedDictConfigures the customized avatar to be used in the session.
- image_data: bytes | None¶
The data of the reference image. The dimensions of the reference image should be 9:16 (portrait) with a minimum resolution of 704x1280.
- image_mime_type: str | None¶
The mime type of the reference image, e.g., “image/jpeg”.
- class genai.types.DatasetDistribution(**data)¶
Bases:
BaseModelDistribution computed over a tuning dataset.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- buckets: list[DatasetDistributionDistributionBucket] | None¶
- max: float | None¶
- mean: float | None¶
- median: float | None¶
- min: float | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- p5: float | None¶
- p95: float | None¶
- sum: float | None¶
- class genai.types.DatasetDistributionDict¶
Bases:
TypedDictDistribution computed over a tuning dataset.
This data type is not supported in Gemini API.
- buckets: list[DatasetDistributionDistributionBucketDict] | None¶
Output only. Defines the histogram bucket.
- max: float | None¶
Output only. The maximum of the population values.
- mean: float | None¶
Output only. The arithmetic mean of the values in the population.
- median: float | None¶
Output only. The median of the values in the population.
- min: float | None¶
Output only. The minimum of the population values.
- p5: float | None¶
Output only. The 5th percentile of the values in the population.
- p95: float | None¶
Output only. The 95th percentile of the values in the population.
- sum: float | None¶
Output only. Sum of a given population of values.
- class genai.types.DatasetDistributionDistributionBucket(**data)¶
Bases:
BaseModelDataset bucket used to create a histogram for the distribution given a population of values.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- count: int | None¶
- left: float | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- right: float | None¶
- class genai.types.DatasetDistributionDistributionBucketDict¶
Bases:
TypedDictDataset bucket used to create a histogram for the distribution given a population of values.
This data type is not supported in Gemini API.
- count: int | None¶
Output only. Number of values in the bucket.
- left: float | None¶
Output only. Left bound of the bucket.
- right: float | None¶
Output only. Right bound of the bucket.
- class genai.types.DatasetStats(**data)¶
Bases:
BaseModelStatistics computed over a tuning dataset.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- contents_per_example_distribution: DatasetDistribution | None¶
- dropped_example_indices: list[int] | None¶
- dropped_example_reasons: list[str] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- reinforcement_tuning_user_dataset_examples: ReinforcementTuningUserDatasetExamples | None¶
- total_billable_character_count: int | None¶
- total_billable_token_count: int | None¶
- total_tuning_character_count: int | None¶
- tuning_dataset_example_count: int | None¶
- tuning_step_count: int | None¶
- user_input_token_distribution: DatasetDistribution | None¶
- user_message_per_example_distribution: DatasetDistribution | None¶
- user_output_token_distribution: DatasetDistribution | None¶
- class genai.types.DatasetStatsDict¶
Bases:
TypedDictStatistics computed over a tuning dataset.
This data type is not supported in Gemini API.
- contents_per_example_distribution: DatasetDistributionDict | None¶
Output only. Dataset distributions for the number of contents per example.
- dropped_example_indices: list[int] | None¶
Output only. A partial sample of the indices (starting from 1) of the dropped examples.
- dropped_example_reasons: list[str] | None¶
Output only. For each index in dropped_example_indices, the user-facing reason why the example was dropped.
- reinforcement_tuning_user_dataset_examples: ReinforcementTuningUserDatasetExamplesDict | None¶
Output only. Sample user dataset examples in the training dataset uri for Reinforcement Tuning.
- total_billable_character_count: int | None¶
Output only. Number of billable characters in the tuning dataset.
- total_billable_token_count: int | None¶
Output only. Number of billable tokens in the tuning dataset.
- total_tuning_character_count: int | None¶
Output only. Number of tuning characters in the tuning dataset.
- tuning_dataset_example_count: int | None¶
Output only. Number of examples in the tuning dataset.
- tuning_step_count: int | None¶
Output only. Number of tuning steps for this Tuning Job.
- user_dataset_examples: list[ContentDict] | None¶
Output only. Sample user messages in the training dataset uri.
- user_input_token_distribution: DatasetDistributionDict | None¶
Output only. Dataset distributions for the user input tokens.
- user_message_per_example_distribution: DatasetDistributionDict | None¶
Output only. Dataset distributions for the messages per example.
- user_output_token_distribution: DatasetDistributionDict | None¶
Output only. Dataset distributions for the user output tokens.
- class genai.types.DeleteBatchJobConfig(**data)¶
Bases:
BaseModelOptional parameters for models.get method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.DeleteBatchJobConfigDict¶
Bases:
TypedDictOptional parameters for models.get method.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.DeleteCachedContentConfig(**data)¶
Bases:
BaseModelOptional parameters for caches.delete method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.DeleteCachedContentConfigDict¶
Bases:
TypedDictOptional parameters for caches.delete method.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.DeleteCachedContentResponse(**data)¶
Bases:
BaseModelEmpty response for caches.delete method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- sdk_http_response: HttpResponse | None¶
- class genai.types.DeleteCachedContentResponseDict¶
Bases:
TypedDictEmpty response for caches.delete method.
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.DeleteDocumentConfig(**data)¶
Bases:
BaseModelConfig for optional parameters.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- force: bool | None¶
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.DeleteDocumentConfigDict¶
Bases:
TypedDictConfig for optional parameters.
- force: bool | None¶
If set to true, any Chunk`s and objects related to this `Document will also be deleted.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.DeleteFileConfig(**data)¶
Bases:
BaseModelUsed to override the default configuration.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.DeleteFileConfigDict¶
Bases:
TypedDictUsed to override the default configuration.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.DeleteFileResponse(**data)¶
Bases:
BaseModelResponse for the delete file method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- sdk_http_response: HttpResponse | None¶
- class genai.types.DeleteFileResponseDict¶
Bases:
TypedDictResponse for the delete file method.
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.DeleteFileSearchStoreConfig(**data)¶
Bases:
BaseModelOptional parameters for deleting a FileSearchStore.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- force: bool | None¶
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.DeleteFileSearchStoreConfigDict¶
Bases:
TypedDictOptional parameters for deleting a FileSearchStore.
- force: bool | None¶
If set to true, any Documents and objects related to this FileSearchStore will also be deleted. If false (the default), a FAILED_PRECONDITION error will be returned if the FileSearchStore contains any Documents.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.DeleteModelConfig(**data)¶
Bases:
BaseModelConfiguration for deleting a tuned model.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.DeleteModelConfigDict¶
Bases:
TypedDictConfiguration for deleting a tuned model.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.DeleteModelResponse(**data)¶
Bases:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- sdk_http_response: HttpResponse | None¶
- class genai.types.DeleteModelResponseDict¶
Bases:
TypedDict- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.DeleteResourceJob(**data)¶
Bases:
BaseModelThe return value of delete operation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- done: bool | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str | None¶
- sdk_http_response: HttpResponse | None¶
- class genai.types.DeleteResourceJobDict¶
Bases:
TypedDictThe return value of delete operation.
- done: bool | None¶
- error: JobErrorDict | None¶
- name: str | None¶
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.Delivery(*values)¶
Bases:
CaseInSensitiveEnumDelivery mode for the generated content.
- DELIVERY_UNSPECIFIED = 'DELIVERY_UNSPECIFIED'¶
Default value. This value is unused.
- INLINE = 'INLINE'¶
Generated bytes are returned inline in the response.
- URI = 'URI'¶
Generated content is stored and a URI is returned.
- class genai.types.DistillationDataStats(**data)¶
Bases:
BaseModelStatistics for distillation prompt dataset.
These statistics do not include the responses sampled from the teacher model. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- training_dataset_stats: DatasetStats | None¶
- class genai.types.DistillationDataStatsDict¶
Bases:
TypedDictStatistics for distillation prompt dataset.
These statistics do not include the responses sampled from the teacher model. This data type is not supported in Gemini API.
- training_dataset_stats: DatasetStatsDict | None¶
Output only. Statistics computed for the training dataset.
- class genai.types.DistillationHyperParameters(**data)¶
Bases:
BaseModelDistillation hyperparameters for tuning.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- adapter_size: AdapterSize | None¶
- batch_size: int | None¶
- epoch_count: int | None¶
- generation_config: GenerationConfig | None¶
- learning_rate: float | None¶
- learning_rate_multiplier: float | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.DistillationHyperParametersDict¶
Bases:
TypedDictDistillation hyperparameters for tuning.
- adapter_size: AdapterSize | None¶
The size of the adapter. Can be ‘small’, ‘medium’, or ‘large’.
- batch_size: int | None¶
Batch size for tuning. This feature is only available for open source models.
- epoch_count: int | None¶
Number of complete passes the model makes over the entire training dataset during training.
- generation_config: GenerationConfigDict | None¶
Generation config for Distillation teacher model sampling. Only the following fields are supported for distillation teacher samplings: - temperature - top_p - top_k - candidate_count - thinking_config
- learning_rate: float | None¶
The learning rate for distillation tuning.
- learning_rate_multiplier: float | None¶
Multiplier for adjusting the default learning rate.
- class genai.types.DistillationSamplingSpec(**data)¶
Bases:
BaseModelDistillation sampling spec for tuning.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- base_teacher_model: str | None¶
- hyperparameters: DistillationHyperParameters | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- prompt_dataset_uri: str | None¶
- tuned_teacher_model_source: str | None¶
- validation_dataset_uri: str | None¶
- class genai.types.DistillationSamplingSpecDict¶
Bases:
TypedDictDistillation sampling spec for tuning.
- base_teacher_model: str | None¶
The base teacher model that is being distilled. See [Supported models](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/tuning#supported_models).
- hyperparameters: DistillationHyperParametersDict | None¶
Hyperparameters for distillation tuning.
- prompt_dataset_uri: str | None¶
Cloud Storage path to file containing prompt dataset for distillation. The dataset must be formatted as a JSONL file.
- tuned_teacher_model_source: str | None¶
The resource name of the Tuned teacher model. Format: projects/{project}/locations/{location}/models/{model}.
- validation_dataset_uri: str | None¶
Cloud Storage path to file containing validation dataset for distillation. The dataset must be formatted as a JSONL file.
- class genai.types.DistillationSpec(**data)¶
Bases:
BaseModelDistillation tuning spec for tuning.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- base_teacher_model: str | None¶
- hyper_parameters: DistillationHyperParameters | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- pipeline_root_directory: str | None¶
- prompt_dataset_uri: str | None¶
- student_model: str | None¶
- training_dataset_uri: str | None¶
- tuned_teacher_model_source: str | None¶
- tuning_mode: TuningMode | None¶
- validation_dataset_uri: str | None¶
- class genai.types.DistillationSpecDict¶
Bases:
TypedDictDistillation tuning spec for tuning.
- base_teacher_model: str | None¶
//cloud.google.com/vertex-ai/generative-ai/docs/model-reference/tuning#supported_models).
- Type:
The base teacher model that is being distilled. See [Supported models](https
- hyper_parameters: DistillationHyperParametersDict | None¶
Optional. Hyperparameters for Distillation.
- pipeline_root_directory: str | None¶
Deprecated. A path in a Cloud Storage bucket, which will be treated as the root output directory of the distillation pipeline. It is used by the system to generate the paths of output artifacts.
- prompt_dataset_uri: str | None¶
Optional. Cloud Storage path to file containing prompt dataset for distillation. The dataset must be formatted as a JSONL file.
- student_model: str | None¶
The student model that is being tuned, e.g., “google/gemma-2b-1.1-it”. Deprecated. Use base_model instead.
- training_dataset_uri: str | None¶
Deprecated. Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file.
- tuned_teacher_model_source: str | None¶
projects/{project}/locations/{location}/models/{model}.
- Type:
The resource name of the Tuned teacher model. Format
- tuning_mode: TuningMode | None¶
Optional. Specifies the tuning mode for distillation (sft part). This feature is only available for open source models.
- validation_dataset_uri: str | None¶
Optional. Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file.
- class genai.types.Document(**data)¶
Bases:
BaseModelA Document is a collection of Chunks.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- create_time: datetime | None¶
- custom_metadata: list[CustomMetadata] | None¶
- display_name: str | None¶
- mime_type: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str | None¶
- size_bytes: int | None¶
- state: DocumentState | None¶
- update_time: datetime | None¶
- class genai.types.DocumentDict¶
Bases:
TypedDictA Document is a collection of Chunks.
- create_time: datetime | None¶
Output only. The Timestamp of when the Document was created.
- custom_metadata: list[CustomMetadataDict] | None¶
Optional. User provided custom metadata stored as key-value pairs used for querying. A Document can have a maximum of 20 CustomMetadata.
- display_name: str | None¶
“Semantic Retriever Documentation”.
- Type:
Optional. The human-readable display name for the Document. The display name must be no more than 512 characters in length, including spaces. Example
- mime_type: str | None¶
Output only. The mime type of the Document.
- name: str | None¶
fileSearchStores/{file_search_store_id}/documents/my-awesome-doc-123a456b789c
- Type:
Immutable. Identifier. The Document resource name. The ID (name excluding the “fileSearchStores/*/documents/” prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be derived from display_name along with a 12 character random suffix. Example
- size_bytes: int | None¶
Output only. The size of raw bytes ingested into the Document.
- state: DocumentState | None¶
Output only. Current state of the Document.
- update_time: datetime | None¶
Output only. The Timestamp of when the Document was last updated.
- class genai.types.DocumentState(*values)¶
Bases:
CaseInSensitiveEnumOutput only.
Current state of the Document. This enum is not supported in Vertex AI.
- STATE_ACTIVE = 'STATE_ACTIVE'¶
All Chunks of the Document is processed and available for querying.
- STATE_FAILED = 'STATE_FAILED'¶
Some Chunks of the Document failed processing.
- STATE_PENDING = 'STATE_PENDING'¶
Some Chunks of the Document are being processed (embedding and vector storage).
- STATE_UNSPECIFIED = 'STATE_UNSPECIFIED'¶
The default value. This value is used if the state is omitted.
- class genai.types.DownloadFileConfig(**data)¶
Bases:
BaseModelUsed to override the default configuration.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.DownloadFileConfigDict¶
Bases:
TypedDictUsed to override the default configuration.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.DownloadMediaConfig(**data)¶
Bases:
BaseModelUsed to override the default configuration.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.DownloadMediaConfigDict¶
Bases:
TypedDictUsed to override the default configuration.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.DynamicRetrievalConfig(**data)¶
Bases:
BaseModelDescribes the options to customize dynamic retrieval.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- dynamic_threshold: float | None¶
- mode: DynamicRetrievalConfigMode | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.DynamicRetrievalConfigDict¶
Bases:
TypedDictDescribes the options to customize dynamic retrieval.
- dynamic_threshold: float | None¶
Optional. The threshold to be used in dynamic retrieval. If not set, a system default value is used.
- mode: DynamicRetrievalConfigMode | None¶
The mode of the predictor to be used in dynamic retrieval.
- class genai.types.DynamicRetrievalConfigMode(*values)¶
Bases:
CaseInSensitiveEnumThe mode of the predictor to be used in dynamic retrieval.
- MODE_DYNAMIC = 'MODE_DYNAMIC'¶
Run retrieval only when system decides it is necessary.
- MODE_UNSPECIFIED = 'MODE_UNSPECIFIED'¶
Always trigger retrieval.
- class genai.types.EditImageConfig(**data)¶
Bases:
BaseModelConfiguration for editing an image.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- add_watermark: bool | None¶
- aspect_ratio: str | None¶
- base_steps: int | None¶
- guidance_scale: float | None¶
- http_options: HttpOptions | None¶
- include_rai_reason: bool | None¶
- include_safety_attributes: bool | None¶
- labels: dict[str, str] | None¶
- language: ImagePromptLanguage | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- negative_prompt: str | None¶
- number_of_images: int | None¶
- output_compression_quality: int | None¶
- output_gcs_uri: str | None¶
- output_mime_type: str | None¶
- person_generation: PersonGeneration | None¶
- safety_filter_level: SafetyFilterLevel | None¶
- seed: int | None¶
- class genai.types.EditImageConfigDict¶
Bases:
TypedDictConfiguration for editing an image.
- add_watermark: bool | None¶
Whether to add a watermark to the generated images.
- aspect_ratio: str | None¶
Aspect ratio of the generated images. Supported values are “1:1”, “3:4”, “4:3”, “9:16”, and “16:9”.
- base_steps: int | None¶
The number of sampling steps. A higher value has better image quality, while a lower value has better latency.
- guidance_scale: float | None¶
Controls how much the model adheres to the text prompt. Large values increase output and prompt alignment, but may compromise image quality.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- include_rai_reason: bool | None¶
Whether to include the Responsible AI filter reason if the image is filtered out of the response.
- include_safety_attributes: bool | None¶
Whether to report the safety scores of each generated image and the positive prompt in the response.
- labels: dict[str, str] | None¶
User specified labels to track billing usage.
- language: ImagePromptLanguage | None¶
Language of the text in the prompt.
- negative_prompt: str | None¶
Description of what to discourage in the generated images.
- number_of_images: int | None¶
Number of images to generate.
- output_compression_quality: int | None¶
Compression quality of the generated image (for
image/jpegonly).
- output_gcs_uri: str | None¶
Cloud Storage URI used to store the generated images.
- output_mime_type: str | None¶
MIME type of the generated image.
- person_generation: PersonGeneration | None¶
Allows generation of people by the model.
- safety_filter_level: SafetyFilterLevel | None¶
Filter level for safety filtering.
- seed: int | None¶
Random seed for image generation. This is not available when
add_watermarkis set to true.
- class genai.types.EditImageResponse(**data)¶
Bases:
BaseModelResponse for the request to edit an image.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- generated_images: list[GeneratedImage] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- sdk_http_response: HttpResponse | None¶
- class genai.types.EditImageResponseDict¶
Bases:
TypedDictResponse for the request to edit an image.
- generated_images: list[GeneratedImageDict] | None¶
Generated images.
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.EditMode(*values)¶
Bases:
CaseInSensitiveEnumEnum representing the editing mode.
- EDIT_MODE_BGSWAP = 'EDIT_MODE_BGSWAP'¶
- EDIT_MODE_CONTROLLED_EDITING = 'EDIT_MODE_CONTROLLED_EDITING'¶
- EDIT_MODE_DEFAULT = 'EDIT_MODE_DEFAULT'¶
- EDIT_MODE_INPAINT_INSERTION = 'EDIT_MODE_INPAINT_INSERTION'¶
- EDIT_MODE_INPAINT_REMOVAL = 'EDIT_MODE_INPAINT_REMOVAL'¶
- EDIT_MODE_OUTPAINT = 'EDIT_MODE_OUTPAINT'¶
- EDIT_MODE_PRODUCT_IMAGE = 'EDIT_MODE_PRODUCT_IMAGE'¶
- EDIT_MODE_STYLE = 'EDIT_MODE_STYLE'¶
- class genai.types.EmbedContentBatch(**data)¶
Bases:
BaseModelParameters for the embed_content method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- config: EmbedContentConfig | None¶
- contents: Content | str | Image | File | Part | list[str | Image | File | Part] | list[Content | str | Image | File | Part | list[str | Image | File | Part]] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.EmbedContentBatchDict¶
Bases:
TypedDictParameters for the embed_content method.
- config: EmbedContentConfigDict | None¶
Configuration that contains optional parameters.
- contents: Content | ContentDict | str | Image | File | FileDict | Part | PartDict | list[str | Image | File | FileDict | Part | PartDict] | list[Content | ContentDict | str | Image | File | FileDict | Part | PartDict | list[str | Image | File | FileDict | Part | PartDict]] | None¶
The content to embed. Only the parts.text fields will be counted.
- class genai.types.EmbedContentConfig(**data)¶
Bases:
BaseModelOptional parameters for the embed_content method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- audio_track_extraction: bool | None¶
- auto_truncate: bool | None¶
- document_ocr: bool | None¶
- http_options: HttpOptions | None¶
- mime_type: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- output_dimensionality: int | None¶
- task_type: str | None¶
- title: str | None¶
- class genai.types.EmbedContentConfigDict¶
Bases:
TypedDictOptional parameters for the embed_content method.
- audio_track_extraction: bool | None¶
Gemini Enterprise Agent Platform only. Whether to extract audio from video content. Only applicable to Gemini Embedding 2 models.
- auto_truncate: bool | None¶
Gemini Enterprise Agent Platform only. Whether to silently truncate inputs longer than the max sequence length. If this option is set to false, oversized inputs will lead to an INVALID_ARGUMENT error, similar to other text APIs.
- document_ocr: bool | None¶
Gemini Enterprise Agent Platform only. Whether to enable OCR for document content. Only applicable to Gemini Embedding 2 models.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- mime_type: str | None¶
Gemini Enterprise Agent Platform only. The MIME type of the input.
- output_dimensionality: int | None¶
Reduced dimension for the output embedding. If set, excessive values in the output embedding are truncated from the end. Supported by newer models since 2024 only. You cannot set this value if using the earlier model (models/embedding-001).
- task_type: str | None¶
Type of task for which the embedding will be used.
- title: str | None¶
Title for the text. Only applicable when TaskType is RETRIEVAL_DOCUMENT.
- class genai.types.EmbedContentMetadata(**data)¶
Bases:
BaseModelRequest-level metadata for the Gemini Enterprise Agent Platform Embed Content API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- billable_character_count: int | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.EmbedContentMetadataDict¶
Bases:
TypedDictRequest-level metadata for the Gemini Enterprise Agent Platform Embed Content API.
- billable_character_count: int | None¶
Gemini Enterprise Agent Platform only. The total number of billable characters included in the request.
- class genai.types.EmbedContentParameters(**data)¶
Bases:
BaseModelParameters for the embed_content method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- config: EmbedContentConfig | None¶
- contents: Content | str | Image | File | Part | list[str | Image | File | Part] | list[Content | str | Image | File | Part | list[str | Image | File | Part]] | None¶
- model: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.EmbedContentParametersDict¶
Bases:
TypedDictParameters for the embed_content method.
- config: EmbedContentConfigDict | None¶
Configuration that contains optional parameters.
- contents: Content | ContentDict | str | Image | File | FileDict | Part | PartDict | list[str | Image | File | FileDict | Part | PartDict] | list[Content | ContentDict | str | Image | File | FileDict | Part | PartDict | list[str | Image | File | FileDict | Part | PartDict]] | None¶
The content to embed. Only the parts.text fields will be counted.
- model: str | None¶
ID of the model to use. For a list of models, see Google models.
- class genai.types.EmbedContentResponse(**data)¶
Bases:
BaseModelResponse for the embed_content method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- embeddings: list[ContentEmbedding] | None¶
- metadata: EmbedContentMetadata | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- sdk_http_response: HttpResponse | None¶
- class genai.types.EmbedContentResponseDict¶
Bases:
TypedDictResponse for the embed_content method.
- embeddings: list[ContentEmbeddingDict] | None¶
The embeddings for each request, in the same order as provided in the batch request.
- metadata: EmbedContentMetadataDict | None¶
Gemini Enterprise Agent Platform only. Metadata about the request.
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.EmbeddingApiType(*values)¶
Bases:
CaseInSensitiveEnumEnum representing the Gemini Enterprise Agent Platform embedding API to use.
- EMBED_CONTENT = 'EMBED_CONTENT'¶
embedContent API Endpoint
- PREDICT = 'PREDICT'¶
predict API endpoint (default)
- class genai.types.EmbeddingsBatchJobSource(**data)¶
Bases:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- file_name: str | None¶
- inlined_requests: EmbedContentBatch | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.EmbeddingsBatchJobSourceDict¶
Bases:
TypedDict- file_name: str | None¶
The Gemini Developer API’s file resource name of the input data (e.g. “files/12345”).
- inlined_requests: EmbedContentBatchDict | None¶
The Gemini Developer API’s inlined input data to run batch job.
- class genai.types.EncryptionSpec(**data)¶
Bases:
BaseModelRepresents a customer-managed encryption key specification that can be applied to a Vertex AI resource.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- kms_key_name: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.EncryptionSpecDict¶
Bases:
TypedDictRepresents a customer-managed encryption key specification that can be applied to a Vertex AI resource.
This data type is not supported in Gemini API.
- kms_key_name: str | None¶
Required. Resource name of the Cloud KMS key used to protect the resource. The Cloud KMS key must be in the same region as the resource. It must have the format projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}.
- class genai.types.EndSensitivity(*values)¶
Bases:
CaseInSensitiveEnumEnd of speech sensitivity.
- END_SENSITIVITY_HIGH = 'END_SENSITIVITY_HIGH'¶
Automatic detection ends speech more often.
- END_SENSITIVITY_LOW = 'END_SENSITIVITY_LOW'¶
Automatic detection ends speech less often.
- END_SENSITIVITY_UNSPECIFIED = 'END_SENSITIVITY_UNSPECIFIED'¶
The default is END_SENSITIVITY_LOW for Gemini Enterprise Agent Platform and END_SENSITIVITY_HIGH for Gemini Live.
- class genai.types.Endpoint(**data)¶
Bases:
BaseModelAn endpoint where you deploy models.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- deployed_model_id: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str | None¶
- class genai.types.EndpointDict¶
Bases:
TypedDictAn endpoint where you deploy models.
- deployed_model_id: str | None¶
ID of the model that’s deployed to the endpoint.
- name: str | None¶
Resource name of the endpoint.
- class genai.types.EnterpriseWebSearch(**data)¶
Bases:
BaseModelTool to search public web data, powered by Vertex AI Search and Sec4 compliance.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- blocking_confidence: PhishBlockThreshold | None¶
- exclude_domains: list[str] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.EnterpriseWebSearchDict¶
Bases:
TypedDictTool to search public web data, powered by Vertex AI Search and Sec4 compliance.
This data type is not supported in Gemini API.
- blocking_confidence: PhishBlockThreshold | None¶
Optional. Sites with confidence level chosen & above this value will be blocked from the search results.
- exclude_domains: list[str] | None¶
Optional. List of domains to be excluded from the search results. The default limit is 2000 domains.
- class genai.types.EntityLabel(**data)¶
Bases:
BaseModelAn entity representing the segmented area.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- label: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- score: float | None¶
- class genai.types.EntityLabelDict¶
Bases:
TypedDictAn entity representing the segmented area.
- label: str | None¶
The label of the segmented entity.
- score: float | None¶
The confidence score of the detected label.
- class genai.types.Environment(*values)¶
Bases:
CaseInSensitiveEnumThe environment being operated.
- ENVIRONMENT_BROWSER = 'ENVIRONMENT_BROWSER'¶
Operates in a web browser.
- ENVIRONMENT_DESKTOP = 'ENVIRONMENT_DESKTOP'¶
Operates in a desktop environment.
- ENVIRONMENT_MOBILE = 'ENVIRONMENT_MOBILE'¶
Operates in a mobile environment.
- ENVIRONMENT_UNSPECIFIED = 'ENVIRONMENT_UNSPECIFIED'¶
Defaults to browser.
- class genai.types.EvaluateDatasetResponse(**data)¶
Bases:
BaseModelThe results from an evaluation run performed by the EvaluationService.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- aggregation_output: AggregationOutput | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- output_info: OutputInfo | None¶
- class genai.types.EvaluateDatasetResponseDict¶
Bases:
TypedDictThe results from an evaluation run performed by the EvaluationService.
This data type is not supported in Gemini API.
- aggregation_output: AggregationOutputDict | None¶
Output only. Aggregation statistics derived from results of EvaluationService.
- output_info: OutputInfoDict | None¶
Output only. Output info for EvaluationService.
- class genai.types.EvaluateDatasetRun(**data)¶
Bases:
BaseModelEvaluate Dataset Run Result for Tuning Job.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- checkpoint_id: str | None¶
- error: GoogleRpcStatus | None¶
- evaluate_dataset_response: EvaluateDatasetResponse | None¶
- evaluation_run: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- operation_name: str | None¶
- class genai.types.EvaluateDatasetRunDict¶
Bases:
TypedDictEvaluate Dataset Run Result for Tuning Job.
This data type is not supported in Gemini API.
- checkpoint_id: str | None¶
Output only. The checkpoint id used in the evaluation run. Only populated when evaluating checkpoints.
- error: GoogleRpcStatusDict | None¶
Output only. The error of the evaluation run if any.
- evaluate_dataset_response: EvaluateDatasetResponseDict | None¶
Output only. Results for EvaluationService.
- evaluation_run: str | None¶
projects/{project}/locations/{location}/evaluationRuns/{evaluation_run_id}.
- Type:
Output only. The resource name of the evaluation run. Format
- operation_name: str | None¶
The updated architecture uses evaluation_run instead.
- Type:
Output only. Deprecated
- class genai.types.EvaluationConfig(**data)¶
Bases:
BaseModelEvaluation config for tuning.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- autorater_config: AutoraterConfig | None¶
- inference_generation_config: GenerationConfig | None¶
- metrics: list[Metric | UnifiedMetric] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- output_config: OutputConfig | None¶
- class genai.types.EvaluationConfigDict¶
Bases:
TypedDictEvaluation config for tuning.
- autorater_config: AutoraterConfigDict | None¶
Autorater config for evaluation.
- inference_generation_config: GenerationConfigDict | None¶
Generation config for inference.
- metrics: list[MetricDict | UnifiedMetricDict] | None¶
The metrics used for evaluation.
- output_config: OutputConfigDict | None¶
Config for evaluation output.
- class genai.types.EvaluationDataset(**data)¶
Bases:
BaseModelThe dataset used for evaluation.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- bigquery_source: BigQuerySource | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.EvaluationDatasetDict¶
Bases:
TypedDictThe dataset used for evaluation.
This data type is not supported in Gemini API.
- bigquery_source: BigQuerySourceDict | None¶
BigQuery source holds the dataset.
- gcs_source: GcsSourceDict | None¶
Cloud storage source holds the dataset. Currently only one Cloud Storage file path is supported.
- class genai.types.EvaluationParserConfig(**data)¶
Bases:
BaseModelConfig for parsing LLM responses.
It can be used to parse the LLM response to be evaluated, or the LLM response from LLM-based metrics/Autoraters. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- custom_code_parser_config: EvaluationParserConfigCustomCodeParserConfig | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.EvaluationParserConfigCustomCodeParserConfig(**data)¶
Bases:
BaseModelConfiguration for parsing the LLM response using custom code.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- code_execution_region: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- parsing_function: str | None¶
- class genai.types.EvaluationParserConfigCustomCodeParserConfigDict¶
Bases:
TypedDictConfiguration for parsing the LLM response using custom code.
This data type is not supported in Gemini API.
- code_execution_region: str | None¶
//cloud.google.com/vertex-ai/generative-ai/docs/agent-engine/locations). If unset, the request’s originating region is used.
- Type:
Optional. The region to use for code execution. If set, the Code Execution Sandbox will be invoked in the specified region regardless of the request’s originating region. Must be a region where the Code Execution Sandbox is available. For the current list of [supported regions](https
- parsing_function: str | None¶
list[str]) -> list[dict[str, Any]] | dict[str, Any]: When parsing rubrics, return a list of dictionaries, where each dictionary represents a Rubric. Example for rubrics: [ { “content”: {“property”: {“description”: “The response is factual.”}}, “type”: “FACTUALITY”, “importance”: “HIGH” }, { “content”: {“property”: {“description”: “The response is fluent.”}}, “type”: “FLUENCY”, “importance”: “MEDIUM” } ] When parsing critique results, return a dictionary representing a MetricResult. Example for a metric result: { “score”: 0.8, “explanation”: “The model followed most instructions.”, “rubric_verdicts”: […] } … code for result extraction and aggregation
- Type:
Required. Python function for parsing results. The function should be defined within this string. The function takes a list of strings (LLM responses) and should return either a list of dictionaries (for rubrics) or a single dictionary (for a metric result). Example function signature
- Type:
def parse(responses
- class genai.types.EvaluationParserConfigDict¶
Bases:
TypedDictConfig for parsing LLM responses.
It can be used to parse the LLM response to be evaluated, or the LLM response from LLM-based metrics/Autoraters. This data type is not supported in Gemini API.
- custom_code_parser_config: EvaluationParserConfigCustomCodeParserConfigDict | None¶
Optional. Use custom code to parse the LLM response.
- class genai.types.ExactMatchMetricValue(**data)¶
Bases:
BaseModelExact match metric value for an instance.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- score: float | None¶
- class genai.types.ExactMatchMetricValueDict¶
Bases:
TypedDictExact match metric value for an instance.
This data type is not supported in Gemini API.
- score: float | None¶
Output only. Exact match score.
- class genai.types.ExecutableCode(**data)¶
Bases:
BaseModelCode generated by the model that is meant to be executed, and the result returned to the model.
Generated when using the CodeExecution tool, in which the code will be automatically executed, and a corresponding CodeExecutionResult will also be generated.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- code: str | None¶
- id: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ExecutableCodeDict¶
Bases:
TypedDictCode generated by the model that is meant to be executed, and the result returned to the model.
Generated when using the CodeExecution tool, in which the code will be automatically executed, and a corresponding CodeExecutionResult will also be generated.
- code: str | None¶
Required. The code to be executed.
- id: str | None¶
Optional. Unique identifier of the ExecutableCode part. The server returns the CodeExecutionResult with the matching id.
- class genai.types.ExternalApi(**data)¶
Bases:
BaseModelRetrieve from data source powered by external API for grounding.
The external API is not owned by Google, but need to follow the pre-defined API spec. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- auth_config: AuthConfig | None¶
- elastic_search_params: ExternalApiElasticSearchParams | None¶
- endpoint: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- simple_search_params: ExternalApiSimpleSearchParams | None¶
- class genai.types.ExternalApiDict¶
Bases:
TypedDictRetrieve from data source powered by external API for grounding.
The external API is not owned by Google, but need to follow the pre-defined API spec. This data type is not supported in Gemini API.
- api_auth: ApiAuthDict | None¶
The authentication config to access the API. Deprecated. Please use auth_config instead.
- auth_config: AuthConfigDict | None¶
The authentication config to access the API.
- elastic_search_params: ExternalApiElasticSearchParamsDict | None¶
Parameters for the elastic search API.
- endpoint: str | None¶
//acme.com:443/search
- Type:
The endpoint of the external API. The system will call the API at this endpoint to retrieve the data for grounding. Example
- Type:
https
- simple_search_params: ExternalApiSimpleSearchParamsDict | None¶
Parameters for the simple search API.
- class genai.types.ExternalApiElasticSearchParams(**data)¶
Bases:
BaseModelThe search parameters to use for the ELASTIC_SEARCH spec.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- index: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- num_hits: int | None¶
- search_template: str | None¶
- class genai.types.ExternalApiElasticSearchParamsDict¶
Bases:
TypedDictThe search parameters to use for the ELASTIC_SEARCH spec.
This data type is not supported in Gemini API.
- index: str | None¶
The ElasticSearch index to use.
- num_hits: int | None¶
Optional. Number of hits (chunks) to request. When specified, it is passed to Elasticsearch as the num_hits param.
- search_template: str | None¶
The ElasticSearch search template to use.
- class genai.types.ExternalApiSimpleSearchParams(**data)¶
Bases:
BaseModelThe search parameters to use for SIMPLE_SEARCH spec.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ExternalApiSimpleSearchParamsDict¶
Bases:
TypedDictThe search parameters to use for SIMPLE_SEARCH spec.
This data type is not supported in Gemini API.
- class genai.types.FeatureSelectionPreference(*values)¶
Bases:
CaseInSensitiveEnumOptions for feature selection preference.
- BALANCED = 'BALANCED'¶
- FEATURE_SELECTION_PREFERENCE_UNSPECIFIED = 'FEATURE_SELECTION_PREFERENCE_UNSPECIFIED'¶
- PRIORITIZE_COST = 'PRIORITIZE_COST'¶
- PRIORITIZE_QUALITY = 'PRIORITIZE_QUALITY'¶
- class genai.types.FetchPredictOperationConfig(**data)¶
Bases:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.FetchPredictOperationConfigDict¶
Bases:
TypedDict- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.File(**data)¶
Bases:
BaseModelA file uploaded to the API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- create_time: datetime | None¶
- display_name: str | None¶
- download_uri: str | None¶
- error: FileStatus | None¶
- expiration_time: datetime | None¶
- mime_type: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str | None¶
- sha256_hash: str | None¶
- size_bytes: int | None¶
- source: FileSource | None¶
- update_time: datetime | None¶
- uri: str | None¶
- video_metadata: dict[str, Any] | None¶
- class genai.types.FileData(**data)¶
Bases:
BaseModelURI-based data.
A FileData message contains a URI pointing to data of a specific media type. It is used to represent images, audio, and video stored in Google Cloud Storage.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- display_name: str | None¶
- file_uri: str | None¶
- mime_type: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.FileDataDict¶
Bases:
TypedDictURI-based data.
A FileData message contains a URI pointing to data of a specific media type. It is used to represent images, audio, and video stored in Google Cloud Storage.
- display_name: str | None¶
Optional. The display name of the file. Used to provide a label or filename to distinguish files. This field is only returned in PromptMessage for prompt management. It is used in the Gemini calls only when server side tools (code_execution, google_search, and url_context) are enabled.
- file_uri: str | None¶
Required. The URI of the file in Google Cloud Storage.
- mime_type: str | None¶
Required. The IANA standard MIME type of the source data.
- class genai.types.FileDict¶
Bases:
TypedDictA file uploaded to the API.
- create_time: datetime | None¶
Output only. The timestamp of when the File was created.
- display_name: str | None¶
‘Welcome Image’
- Type:
Optional. The human-readable display name for the File. The display name must be no more than 512 characters in length, including spaces. Example
- download_uri: str | None¶
Output only. The URI of the File, only set for downloadable (generated) files.
- error: FileStatusDict | None¶
Output only. Error status if File processing failed.
- expiration_time: datetime | None¶
Output only. The timestamp of when the File will be deleted. Only set if the File is scheduled to expire.
- mime_type: str | None¶
Output only. MIME type of the file.
- name: str | None¶
files/123-456
- Type:
The File resource name. The ID (name excluding the “files/” prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be generated. Example
- sha256_hash: str | None¶
Output only. SHA-256 hash of the uploaded bytes. The hash value is encoded in base64 format.
- size_bytes: int | None¶
Output only. Size of the file in bytes.
- source: FileSource | None¶
Output only. The source of the File.
- update_time: datetime | None¶
Output only. The timestamp of when the File was last updated.
- uri: str | None¶
Output only. The URI of the File.
- video_metadata: dict[str, Any] | None¶
Output only. Metadata for a video.
- class genai.types.FileSearch(**data)¶
Bases:
BaseModelThe FileSearch tool that retrieves knowledge from Semantic Retrieval corpora.
Files are imported to Semantic Retrieval corpora using the ImportFile API. This data type is not supported in Vertex AI.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- file_search_store_names: list[str] | None¶
- metadata_filter: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- top_k: int | None¶
- class genai.types.FileSearchDict¶
Bases:
TypedDictThe FileSearch tool that retrieves knowledge from Semantic Retrieval corpora.
Files are imported to Semantic Retrieval corpora using the ImportFile API. This data type is not supported in Vertex AI.
- file_search_store_names: list[str] | None¶
fileSearchStores/my-file-search-store-123
- Type:
Required. The names of the file_search_stores to retrieve from. Example
- metadata_filter: str | None¶
Optional. Metadata filter to apply to the semantic retrieval documents and chunks.
- top_k: int | None¶
Optional. The number of semantic retrieval chunks to retrieve.
- class genai.types.FileSearchStore(**data)¶
Bases:
BaseModelA collection of Documents.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- active_documents_count: int | None¶
- create_time: datetime | None¶
- display_name: str | None¶
- embedding_model: str | None¶
- failed_documents_count: int | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str | None¶
- pending_documents_count: int | None¶
- size_bytes: int | None¶
- update_time: datetime | None¶
- class genai.types.FileSearchStoreDict¶
Bases:
TypedDictA collection of Documents.
- active_documents_count: int | None¶
Output only. The number of documents in the FileSearchStore that are active and ready for retrieval.
- create_time: datetime | None¶
Output only. The Timestamp of when the FileSearchStore was created.
- display_name: str | None¶
“Docs on Semantic Retriever”.
- Type:
Optional. The human-readable display name for the FileSearchStore. The display name must be no more than 512 characters in length, including spaces. Example
- embedding_model: str | None¶
The embedding model used by the FileSearchStore.
- failed_documents_count: int | None¶
Output only. The number of documents in the FileSearchStore that have failed processing.
- name: str | None¶
fileSearchStores/my-awesome-file-search-store-123a456b789c If display_name is not provided, the name will be randomly generated.
- Type:
Output only. Immutable. Identifier. The FileSearchStore resource name. It is an ID (name excluding the “fileSearchStores/” prefix) that can contain up to 40 characters that are lowercase alphanumeric or dashes (-). It is output only. The unique name will be derived from display_name along with a 12 character random suffix. Example
- pending_documents_count: int | None¶
Output only. The number of documents in the FileSearchStore that are being processed.
- size_bytes: int | None¶
Output only. The size of raw bytes ingested into the FileSearchStore. This is the total size of all the documents in the FileSearchStore.
- update_time: datetime | None¶
Output only. The Timestamp of when the FileSearchStore was last updated.
- class genai.types.FileSource(*values)¶
Bases:
CaseInSensitiveEnumSource of the File.
- GENERATED = 'GENERATED'¶
- REGISTERED = 'REGISTERED'¶
- SOURCE_UNSPECIFIED = 'SOURCE_UNSPECIFIED'¶
- UPLOADED = 'UPLOADED'¶
- class genai.types.FileState(*values)¶
Bases:
CaseInSensitiveEnumState for the lifecycle of a File.
- ACTIVE = 'ACTIVE'¶
- FAILED = 'FAILED'¶
- PROCESSING = 'PROCESSING'¶
- STATE_UNSPECIFIED = 'STATE_UNSPECIFIED'¶
- class genai.types.FileStatus(**data)¶
Bases:
BaseModelStatus of a File that uses a common error model.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- code: int | None¶
- details: list[dict[str, Any]] | None¶
- message: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.FileStatusDict¶
Bases:
TypedDictStatus of a File that uses a common error model.
- code: int | None¶
The status code. 0 for OK, 1 for CANCELLED
- details: list[dict[str, Any]] | None¶
A list of messages that carry the error details. There is a common set of message types for APIs to use.
- message: str | None¶
A list of messages that carry the error details. There is a common set of message types for APIs to use.
- class genai.types.FinishReason(*values)¶
Bases:
CaseInSensitiveEnumOutput only. The reason why the model stopped generating tokens.
If empty, the model has not stopped generating the tokens.
- BLOCKLIST = 'BLOCKLIST'¶
Token generation stopped because the content contains forbidden terms.
- CONTINUATION = 'CONTINUATION'¶
Token generation stopped because the response reached the per-request token limit, but generation is not yet complete. The response can be continued by passing the returned continuation_token in a subsequent request.
- FINISH_REASON_UNSPECIFIED = 'FINISH_REASON_UNSPECIFIED'¶
The finish reason is unspecified.
- IMAGE_OTHER = 'IMAGE_OTHER'¶
Image generation stopped for a reason not otherwise specified.
- IMAGE_PROHIBITED_CONTENT = 'IMAGE_PROHIBITED_CONTENT'¶
Image generation stopped because the generated images have prohibited content.
- IMAGE_RECITATION = 'IMAGE_RECITATION'¶
Image generation stopped because the generated image may be a recitation from a source.
- IMAGE_SAFETY = 'IMAGE_SAFETY'¶
Token generation stopped because generated images have safety violations.
- LANGUAGE = 'LANGUAGE'¶
The token generation stopped because of using an unsupported language.
- MALFORMED_FUNCTION_CALL = 'MALFORMED_FUNCTION_CALL'¶
The function call generated by the model is invalid.
- MAX_TOKENS = 'MAX_TOKENS'¶
Token generation reached the configured maximum output tokens.
- NO_IMAGE = 'NO_IMAGE'¶
The model was expected to generate an image, but none was generated.
- OTHER = 'OTHER'¶
All other reasons that stopped the token generation.
- PROHIBITED_CONTENT = 'PROHIBITED_CONTENT'¶
Token generation stopped for potentially containing prohibited content.
- RECITATION = 'RECITATION'¶
The token generation stopped because of potential recitation.
- SAFETY = 'SAFETY'¶
When streaming, [content][] is empty if content filters blocks the output.
- Type:
Token generation stopped because the content potentially contains safety violations. NOTE
- SPII = 'SPII'¶
Token generation stopped because the content potentially contains Sensitive Personally Identifiable Information (SPII).
- STOP = 'STOP'¶
Token generation reached a natural stopping point or a configured stop sequence.
- TOO_MANY_TOOL_CALLS = 'TOO_MANY_TOOL_CALLS'¶
Model called too many tools consecutively, thus the system exited execution.
- UNEXPECTED_TOOL_CALL = 'UNEXPECTED_TOOL_CALL'¶
The tool call generated by the model is invalid.
- class genai.types.FullFineTuningSpec(**data)¶
Bases:
BaseModelTuning Spec for Full Fine Tuning.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- hyper_parameters: SupervisedHyperParameters | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- training_dataset_uri: str | None¶
- validation_dataset_uri: str | None¶
- class genai.types.FullFineTuningSpecDict¶
Bases:
TypedDictTuning Spec for Full Fine Tuning.
This data type is not supported in Gemini API.
- hyper_parameters: SupervisedHyperParametersDict | None¶
Optional. Hyperparameters for Full Fine Tuning.
- training_dataset_uri: str | None¶
Required. Training dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.
- validation_dataset_uri: str | None¶
Optional. Validation dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.
- class genai.types.FunctionCall(**data)¶
Bases:
BaseModelA predicted FunctionCall returned from the model that contains a string representing the FunctionDeclaration.name and a structured JSON object containing the parameters and their values.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- args: dict[str, Any] | None¶
- id: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str | None¶
- partial_args: list[PartialArg] | None¶
- will_continue: bool | None¶
- class genai.types.FunctionCallDict¶
Bases:
TypedDictA predicted FunctionCall returned from the model that contains a string representing the FunctionDeclaration.name and a structured JSON object containing the parameters and their values.
- args: dict[str, Any] | None¶
Optional. The function parameters and values in JSON object format. See FunctionDeclaration.parameters for parameter details.
- id: str | None¶
Optional. The unique id of the function call. If populated, the client to execute the function_call and return the response with the matching id.
- name: str | None¶
Optional. The name of the function to call. Matches FunctionDeclaration.name.
- partial_args: list[PartialArgDict] | None¶
Optional. The partial argument value of the function call. If provided, represents the arguments/fields that are streamed incrementally. This field is not supported in Gemini API.
- will_continue: bool | None¶
Optional. Whether this is the last part of the FunctionCall. If true, another partial message for the current FunctionCall is expected to follow. This field is not supported in Gemini API.
- class genai.types.FunctionCallingConfig(**data)¶
Bases:
BaseModelFunction calling config.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- allowed_function_names: list[str] | None¶
- mode: FunctionCallingConfigMode | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- stream_function_call_arguments: bool | None¶
- class genai.types.FunctionCallingConfigDict¶
Bases:
TypedDictFunction calling config.
- allowed_function_names: list[str] | None¶
Optional. Function names to call. Only set when the Mode is ANY. Function names should match FunctionDeclaration.name. With mode set to ANY, model will predict a function call from the set of function names provided.
- mode: FunctionCallingConfigMode | None¶
Optional. Function calling mode.
- stream_function_call_arguments: bool | None¶
Optional. When set to true, arguments of a single function call will be streamed out in multiple parts/contents/responses. Partial parameter results will be returned in the FunctionCall.partial_args field. This field is not supported in Gemini API.
- class genai.types.FunctionCallingConfigMode(*values)¶
Bases:
CaseInSensitiveEnumFunction calling mode.
- ANY = 'ANY'¶
Model is constrained to always predicting function calls only. If “allowed_function_names” are set, the predicted function calls will be limited to any one of “allowed_function_names”, else the predicted function calls will be any one of the provided “function_declarations”.
- AUTO = 'AUTO'¶
Default model behavior, model decides to predict either function calls or natural language response.
- MODE_UNSPECIFIED = 'MODE_UNSPECIFIED'¶
Unspecified function calling mode. This value should not be used.
- NONE = 'NONE'¶
Model will not predict any function calls. Model behavior is same as when not passing any function declarations.
- VALIDATED = 'VALIDATED'¶
Model is constrained to predict either function calls or natural language response. If “allowed_function_names” are set, the predicted function calls will be limited to any one of “allowed_function_names”, else the predicted function calls will be any one of the provided “function_declarations”.
- class genai.types.FunctionDeclaration(**data)¶
Bases:
BaseModelStructured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3).
Included in this declaration are the function name, description, parameters and response type. This FunctionDeclaration is a representation of a block of code that can be used as a Tool by the model and executed by the client.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- description: str | None¶
- classmethod from_callable(*, client, callable, behavior=None, use_json_schema=False)¶
Converts a Callable to a FunctionDeclaration based on the client.
Note: For best results prefer [Google-style docstring](https://google.github.io/styleguide/pyguide.html#383-functions-and-methods) when describing arguments. This function does not parse argument descriptions into the property description slots of the resulting structure. Instead it sends the whole docstring in the top-level function description. Google-style docstring are closest to what the model is trained on.
- Return type:
- classmethod from_callable_with_api_option(*, callable, api_option='GEMINI_API', behavior=None, use_json_schema=False)¶
Converts a Callable to a FunctionDeclaration based on the API option.
Supported API option is ‘ENTERPRISE’, ‘GEMINI_API’ or ‘VERTEX_AI’. If api_option is unset, it will default to ‘GEMINI_API’. If unsupported api_option is provided, it will raise ValueError. Note: ‘VERTEX_AI’ is to be deprecated, please use ‘ENTERPRISE’ instead.
- Return type:
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str | None¶
- parameters_json_schema: Any | None¶
- response_json_schema: Any | None¶
- class genai.types.FunctionDeclarationDict¶
Bases:
TypedDictStructured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3).
Included in this declaration are the function name, description, parameters and response type. This FunctionDeclaration is a representation of a block of code that can be used as a Tool by the model and executed by the client.
- behavior: Behavior | None¶
Optional. Specifies the function Behavior. If not specified, the system keeps the current function call behavior. This field is currently only supported by the BidiGenerateContent method.
- description: str | None¶
Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function.
- name: str | None¶
Required. The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores, dots, colons and dashes, with a maximum length of 128.
- parameters: SchemaDict | None¶
the Schema defining the type used for the parameter. For function with no parameters, this can be left unset. Parameter names must start with a letter or an underscore and must only contain chars a-z, A-Z, 0-9, or underscores with a maximum length of 64. Example with 1 required and 1 optional parameter: type: OBJECT properties: param1: type: STRING param2: type: INTEGER required: - param1
- Type:
Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. string Key
- Type:
the name of the parameter. Parameter names are case sensitive. Schema Value
- parameters_json_schema: Any | None¶
` { "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "integer" } }, "additionalProperties": false, "required": ["name", "age"], "propertyOrdering": ["name", "age"] } `This field is mutually exclusive with parameters.- Type:
Optional. Describes the parameters to the function in JSON Schema format. The schema must describe an object where the properties are the parameters to the function. For example
- response: SchemaDict | None¶
Optional. Describes the output from this function in JSON Schema format. Reflects the Open API 3.03 Response Object. The Schema defines the type used for the response value of the function.
- response_json_schema: Any | None¶
Optional. Describes the output from this function in JSON Schema format. The value specified by the schema is the response value of the function. This field is mutually exclusive with response.
- class genai.types.FunctionResponse(**data)¶
Bases:
BaseModelThe result output from a FunctionCall that contains a string representing the FunctionDeclaration.name and a structured JSON object containing any output from the function is used as context to the model.
This should contain the result of a FunctionCall made based on model prediction.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- classmethod from_mcp_response(*, name, response)¶
- Return type:
- id: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str | None¶
- parts: list[FunctionResponsePart] | None¶
- response: dict[str, Any] | None¶
- scheduling: FunctionResponseScheduling | None¶
- will_continue: bool | None¶
- class genai.types.FunctionResponseBlob(**data)¶
Bases:
BaseModelRaw media bytes for function response.
Text should not be sent as raw bytes, use the ‘text’ field.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- data: bytes | None¶
- display_name: str | None¶
- mime_type: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.FunctionResponseBlobDict¶
Bases:
TypedDictRaw media bytes for function response.
Text should not be sent as raw bytes, use the ‘text’ field.
- data: bytes | None¶
Required. Raw bytes.
- display_name: str | None¶
Optional. Display name of the blob. Used to provide a label or filename to distinguish blobs. This field is only returned in PromptMessage for prompt management. It is currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled. This field is not supported in Gemini API.
- mime_type: str | None¶
Required. The IANA standard MIME type of the source data.
- class genai.types.FunctionResponseDict¶
Bases:
TypedDictThe result output from a FunctionCall that contains a string representing the FunctionDeclaration.name and a structured JSON object containing any output from the function is used as context to the model.
This should contain the result of a FunctionCall made based on model prediction.
- id: str | None¶
Optional. The id of the function call this response is for. Populated by the client to match the corresponding function call id.
- name: str | None¶
Required. The name of the function to call. Matches FunctionDeclaration.name and FunctionCall.name.
- parts: list[FunctionResponsePartDict] | None¶
Optional. Ordered Parts that constitute a function response. Parts may have different IANA MIME types.
- response: dict[str, Any] | None¶
Required. The function response in JSON object format. Use “output” key to specify function output and “error” key to specify error details (if any). If “output” and “error” keys are not specified, then whole “response” is treated as function output.
- scheduling: FunctionResponseScheduling | None¶
Optional. Specifies how the response should be scheduled in the conversation. Only applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults to WHEN_IDLE.
- will_continue: bool | None¶
Optional. Signals that function call continues, and more responses will be returned, turning the function call into a generator. Is only applicable to NON_BLOCKING function calls, is ignored otherwise. If set to false, future responses will not be considered. It is allowed to return empty response with will_continue=False to signal that the function call is finished. This may still trigger the model generation. To avoid triggering the generation and finish the function call, additionally set scheduling to SILENT. This field is not supported in Vertex AI.
- class genai.types.FunctionResponseFileData(**data)¶
Bases:
BaseModelURI based data for function response.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- display_name: str | None¶
- file_uri: str | None¶
- mime_type: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.FunctionResponseFileDataDict¶
Bases:
TypedDictURI based data for function response.
This data type is not supported in Gemini API.
- display_name: str | None¶
Optional. Display name of the file data. Used to provide a label or filename to distinguish file datas. This field is only returned in PromptMessage for prompt management. It is currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled.
- file_uri: str | None¶
Required. URI.
- mime_type: str | None¶
Required. The IANA standard MIME type of the source data.
- class genai.types.FunctionResponsePart(**data)¶
Bases:
BaseModelA datatype containing media that is part of a FunctionResponse message.
A FunctionResponsePart consists of data which has an associated datatype. A FunctionResponsePart can only contain one of the accepted types in FunctionResponsePart.data. A FunctionResponsePart must have a fixed IANA MIME type identifying the type and subtype of the media if the inline_data field is filled with raw bytes.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- file_data: FunctionResponseFileData | None¶
- classmethod from_bytes(*, data, mime_type)¶
Creates a FunctionResponsePart from bytes and mime type.
- Return type:
- Parameters:
data (bytes) – The bytes of the data
mime_type (str) – mime_type: The MIME type of the data.
- classmethod from_uri(*, file_uri, mime_type=None)¶
Creates a FunctionResponsePart from a file uri.
- Return type:
- Parameters:
file_uri (str) – The uri of the file
mime_type (str) – mime_type: The MIME type of the file. If not provided, the MIME type will be automatically determined.
- inline_data: FunctionResponseBlob | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.FunctionResponsePartDict¶
Bases:
TypedDictA datatype containing media that is part of a FunctionResponse message.
A FunctionResponsePart consists of data which has an associated datatype. A FunctionResponsePart can only contain one of the accepted types in FunctionResponsePart.data. A FunctionResponsePart must have a fixed IANA MIME type identifying the type and subtype of the media if the inline_data field is filled with raw bytes.
- file_data: FunctionResponseFileDataDict | None¶
URI based data. This field is not supported in Gemini API.
- inline_data: FunctionResponseBlobDict | None¶
Inline media bytes.
- class genai.types.FunctionResponseScheduling(*values)¶
Bases:
CaseInSensitiveEnumSpecifies how the response should be scheduled in the conversation.
Only applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults to WHEN_IDLE.
- INTERRUPT = 'INTERRUPT'¶
Add the result to the conversation context, interrupt ongoing generation and prompt to generate output.
- SCHEDULING_UNSPECIFIED = 'SCHEDULING_UNSPECIFIED'¶
This value is unused.
- SILENT = 'SILENT'¶
Only add the result to the conversation context, do not interrupt or trigger generation.
- WHEN_IDLE = 'WHEN_IDLE'¶
Add the result to the conversation context, and prompt to generate output without interrupting ongoing generation.
- class genai.types.GcsDestination(**data)¶
Bases:
BaseModelThe Google Cloud Storage location where the output is to be written to.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- output_uri_prefix: str | None¶
- class genai.types.GcsDestinationDict¶
Bases:
TypedDictThe Google Cloud Storage location where the output is to be written to.
- output_uri_prefix: str | None¶
Required. Google Cloud Storage URI to output directory. If the uri doesn’t end with ‘/’, a ‘/’ will be automatically appended. The directory is created if it doesn’t exist.
- class genai.types.GcsSource(**data)¶
Bases:
BaseModelThe Google Cloud Storage location for the input content.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- uris: list[str] | None¶
- class genai.types.GcsSourceDict¶
Bases:
TypedDictThe Google Cloud Storage location for the input content.
This data type is not supported in Gemini API.
- uris: list[str] | None¶
//cloud.google.com/storage/docs/wildcards.
- Type:
Required. Google Cloud Storage URI(-s) to the input file(s). May contain wildcards. For more information on wildcards, see https
- class genai.types.GeminiPreferenceExample(**data)¶
Bases:
BaseModelInput example for preference optimization.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- completions: list[GeminiPreferenceExampleCompletion] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.GeminiPreferenceExampleCompletion(**data)¶
Bases:
BaseModelCompletion and its preference score.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- score: float | None¶
- class genai.types.GeminiPreferenceExampleCompletionDict¶
Bases:
TypedDictCompletion and its preference score.
This data type is not supported in Gemini API.
- completion: ContentDict | None¶
Single turn completion for the given prompt.
- score: float | None¶
The score for the given completion.
- class genai.types.GeminiPreferenceExampleDict¶
Bases:
TypedDictInput example for preference optimization.
This data type is not supported in Gemini API.
- completions: list[GeminiPreferenceExampleCompletionDict] | None¶
List of completions for a given prompt.
- contents: list[ContentDict] | None¶
Multi-turn contents that represents the Prompt.
- class genai.types.GenerateContentConfig(**data)¶
Bases:
BaseModelOptional model configuration parameters.
For more information, see Content generation parameters.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- audio_timestamp: bool | None¶
- audio_transcription_config: AudioTranscriptionConfig | None¶
- automatic_continuation: bool | None¶
- automatic_function_calling: AutomaticFunctionCallingConfig | None¶
- cached_content: str | None¶
- candidate_count: int | None¶
- continuation_token: bytes | None¶
- enable_enhanced_civic_answers: bool | None¶
- frequency_penalty: float | None¶
- http_options: HttpOptions | None¶
- image_config: ImageConfig | None¶
- labels: dict[str, str] | None¶
- logprobs: int | None¶
- max_output_tokens: int | None¶
- media_resolution: MediaResolution | None¶
- model_armor_config: ModelArmorConfig | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_selection_config: ModelSelectionConfig | None¶
- presence_penalty: float | None¶
- response_json_schema: Any | None¶
- response_logprobs: bool | None¶
- response_mime_type: str | None¶
- response_modalities: list[str] | None¶
- response_schema: dict[Any, Any] | type | Schema | GenericAlias | UnionType | _UnionGenericAlias | None¶
- routing_config: GenerationConfigRoutingConfig | None¶
- safety_settings: list[SafetySetting] | None¶
- seed: int | None¶
- service_tier: ServiceTier | None¶
- should_return_http_response: bool | None¶
- speech_config: str | SpeechConfig | None¶
- stop_sequences: list[str] | None¶
- temperature: float | None¶
- thinking_config: ThinkingConfig | None¶
- tool_config: ToolConfig | None¶
- tools: Annotated[list, WrapValidator(func=_validate_tool_list, json_schema_input_type=PydanticUndefined)] | None¶
- top_k: float | None¶
- top_p: float | None¶
- class genai.types.GenerateContentConfigDict¶
Bases:
TypedDictOptional model configuration parameters.
For more information, see Content generation parameters.
- audio_timestamp: bool | None¶
If enabled, audio timestamp will be included in the request to the model.
- audio_transcription_config: AudioTranscriptionConfigDict | None¶
Optional. Configuration for audio transcription (speech recognition).
- automatic_continuation: bool | None¶
Defaults to true. When a response ends with finish reason CONTINUATION, the SDK sends the same request again with the response’s continuation token until the model finishes. Timeouts, retries and billing apply to each request. Set to false to turn this off.
- automatic_function_calling: AutomaticFunctionCallingConfigDict | None¶
The configuration for automatic function calling.
- cached_content: str | None¶
Resource name of a context cache that can be used in subsequent requests.
- candidate_count: int | None¶
Number of response variations to return.
- continuation_token: bytes | None¶
An opaque continuation token used to resume generation from a previous response that stopped with finish_reason set to CONTINUATION.
- enable_enhanced_civic_answers: bool | None¶
Enables enhanced civic answers. It may not be available for all models. This field is not supported in Gemini Enterprise Agent Platform.
- frequency_penalty: float | None¶
Positive values penalize tokens that repeatedly appear in the generated text, increasing the probability of generating more diverse content.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- image_config: ImageConfigDict | None¶
The image generation configuration.
- labels: dict[str, str] | None¶
Labels with user-defined metadata for the request.
- logprobs: int | None¶
Number of top candidate tokens to return the log probabilities for at each generation step.
- max_output_tokens: int | None¶
Maximum number of tokens that can be generated in the response.
- media_resolution: MediaResolution | None¶
If specified, the media resolution specified will be used.
- model_armor_config: ModelArmorConfigDict | None¶
Settings for prompt and response sanitization using the Model Armor service. If supplied, safety_settings must not be supplied.
- model_selection_config: ModelSelectionConfigDict | None¶
Configuration for model selection.
- presence_penalty: float | None¶
Positive values penalize tokens that already appear in the generated text, increasing the probability of generating more diverse content.
- response_json_schema: Any | None¶
Optional. Output schema of the generated response. This is an alternative to response_schema that accepts [JSON Schema](https://json-schema.org/). If set, response_schema must be omitted, but response_mime_type is required. While the full JSON Schema may be sent, not all features are supported. Specifically, only the following properties are supported: - $id - $defs - $ref - $anchor - type - format - title - description - enum (for strings and numbers) - items - prefixItems - minItems - maxItems - minimum - maximum - anyOf - oneOf (interpreted the same as anyOf) - properties - additionalProperties - required The non-standard propertyOrdering property may also be set. Cyclic references are unrolled to a limited degree and, as such, may only be used within non-required properties. (Nullable properties are not sufficient.) If $ref is set on a sub-schema, no other properties, except for than those starting as a $, may be set.
- response_logprobs: bool | None¶
Whether to return the log probabilities of the tokens that were chosen by the model at each step.
- response_mime_type: str | None¶
Output response mimetype of the generated candidate text. Supported mimetype:
text/plain: (default) Text output.
application/json: JSON response in the candidates.
The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined.
- response_modalities: list[str] | None¶
The requested modalities of the response. Represents the set of modalities that the model can return.
- response_schema: dict[Any, Any] | type | Schema | GenericAlias | UnionType | _UnionGenericAlias | SchemaDict | None¶
The Schema object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. Represents a select subset of an [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema). If set, a compatible response_mime_type must also be set. Compatible mimetypes: application/json: Schema for JSON response.
If response_schema doesn’t process your schema correctly, try using response_json_schema instead.
- routing_config: GenerationConfigRoutingConfigDict | None¶
Configuration for model router requests.
- safety_settings: list[SafetySettingDict] | None¶
Safety settings in the request to block unsafe content in the response.
- seed: int | None¶
When
seedis fixed to a specific number, the model makes a best effort to provide the same response for repeated requests. By default, a random number is used.
- service_tier: ServiceTier | None¶
The service tier to use for the request. For example, ServiceTier.FLEX.
- should_return_http_response: bool | None¶
If true, the raw HTTP response will be returned in the ‘sdk_http_response’ field.
- speech_config: str | SpeechConfig | SpeechConfigDict | None¶
The speech generation configuration.
- stop_sequences: list[str] | None¶
List of strings that tells the model to stop generating text if one of the strings is encountered in the response.
- system_instruction: Content | ContentDict | str | Image | File | FileDict | Part | PartDict | list[str | Image | File | FileDict | Part | PartDict] | None¶
Instructions for the model to steer it toward better performance. For example, “Answer as concisely as possible” or “Don’t use technical terms in your response”.
- temperature: float | None¶
Value that controls the degree of randomness in token selection. Lower temperatures are good for prompts that require a less open-ended or creative response, while higher temperatures can lead to more diverse or creative results.
- thinking_config: ThinkingConfigDict | None¶
The thinking features configuration.
- tool_config: ToolConfigDict | None¶
Associates model output to a specific function call.
- tools: list[ToolDict | Callable[[...], Any]] | None¶
Code that enables the system to interact with external systems to perform an action outside of the knowledge and scope of the model.
- top_k: float | None¶
For each token selection step, the
top_ktokens with the highest probabilities are sampled. Then tokens are further filtered based ontop_pwith the final token selected using temperature sampling. Use a lower number for less random responses and a higher number for more random responses.
- top_p: float | None¶
Tokens are selected from the most to least probable until the sum of their probabilities equals this value. Use a lower value for less random responses and a higher value for more random responses.
- class genai.types.GenerateContentResponse(**data)¶
Bases:
BaseModelResponse message for PredictionService.GenerateContent.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- property code_execution_result: str | None¶
Returns the code execution result in the response.
If there are multiple candidates, this returns the code execution result from only the first one.
- create_time: datetime | None¶
- property executable_code: str | None¶
Returns the executable code in the response.
If there are multiple candidates, this returns the executable code from only the first one.
- property function_calls: list[FunctionCall] | None¶
Returns the list of function calls in the response.
If there are multiple candidates, this returns the function calls from only the first one.
- property initial_prompt_token_count: int | None¶
Returns the prompt token count from the initial request prior to any continuation hops.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_status: ModelStatus | None¶
- model_version: str | None¶
- parsed: BaseModel | dict[Any, Any] | Enum | None¶
- property parts: list[Part] | None¶
Returns the content-parts in the response.
If there are multiple candidates, returns the parts from only the first one.
- prompt_feedback: GenerateContentResponsePromptFeedback | None¶
- response_id: str | None¶
- sdk_http_response: HttpResponse | None¶
- property text: str | None¶
Returns the concatenation of all text parts in the response.
If there are multiple candidates, returns the text from only the first one. If there are non-text parts in the response, this returns only the text parts.
- usage_metadata: GenerateContentResponseUsageMetadata | None¶
- class genai.types.GenerateContentResponseDict¶
Bases:
TypedDictResponse message for PredictionService.GenerateContent.
- candidates: list[CandidateDict] | None¶
Response variations returned by the model.
- create_time: datetime | None¶
Timestamp when the request is made to the server.
- model_status: ModelStatusDict | None¶
Output only. The current model status of this model. This field is not supported in Vertex AI.
- model_version: str | None¶
Output only. The model version used to generate the response.
- prompt_feedback: GenerateContentResponsePromptFeedbackDict | None¶
Sent only in the first stream chunk. Only happens when no candidates were generated due to content violations.
- Type:
Output only. Content filter results for a prompt sent in the request. Note
- response_id: str | None¶
Output only. response_id is used to identify each response. It is the encoding of the event_id.
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- usage_metadata: GenerateContentResponseUsageMetadataDict | None¶
Usage metadata about the response(s).
- class genai.types.GenerateContentResponsePromptFeedback(**data)¶
Bases:
BaseModelContent filter results for a prompt sent in the request.
Note: This is sent only in the first stream chunk and only if no candidates were generated due to content violations.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- block_reason: BlockedReason | None¶
- block_reason_message: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- safety_ratings: list[SafetyRating] | None¶
- class genai.types.GenerateContentResponsePromptFeedbackDict¶
Bases:
TypedDictContent filter results for a prompt sent in the request.
Note: This is sent only in the first stream chunk and only if no candidates were generated due to content violations.
- block_reason: BlockedReason | None¶
Output only. The reason why the prompt was blocked.
- block_reason_message: str | None¶
Output only. A readable message that explains the reason why the prompt was blocked. This field is not supported in Gemini API.
- safety_ratings: list[SafetyRatingDict] | None¶
Output only. A list of safety ratings for the prompt. There is one rating per category.
- class genai.types.GenerateContentResponseUsageMetadata(**data)¶
Bases:
BaseModelUsage metadata about the content generation request and response.
This message provides a detailed breakdown of token usage and other relevant metrics. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- cache_tokens_details: list[ModalityTokenCount] | None¶
- cached_content_token_count: int | None¶
- candidates_token_count: int | None¶
- candidates_tokens_details: list[ModalityTokenCount] | None¶
- property initial_prompt_token_count: int | None¶
Returns the prompt token count from the initial request prior to any continuation hops.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(context, /)¶
This function is meant to behave like a BaseModel method to initialize private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Return type:
None- Parameters:
self – The BaseModel instance.
context – The context.
- prompt_token_count: int | None¶
- prompt_tokens_details: list[ModalityTokenCount] | None¶
- thoughts_token_count: int | None¶
- tool_use_prompt_token_count: int | None¶
- tool_use_prompt_tokens_details: list[ModalityTokenCount] | None¶
- total_token_count: int | None¶
- traffic_type: TrafficType | None¶
- class genai.types.GenerateContentResponseUsageMetadataDict¶
Bases:
TypedDictUsage metadata about the content generation request and response.
This message provides a detailed breakdown of token usage and other relevant metrics. This data type is not supported in Gemini API.
- cache_tokens_details: list[ModalityTokenCountDict] | None¶
Output only. A detailed breakdown of the token count for each modality in the cached content.
- cached_content_token_count: int | None¶
Output only. The number of tokens in the cached content that was used for this request.
- candidates_token_count: int | None¶
The total number of tokens in the generated candidates.
- candidates_tokens_details: list[ModalityTokenCountDict] | None¶
Output only. A detailed breakdown of the token count for each modality in the generated candidates.
- prompt_token_count: int | None¶
The total number of tokens in the prompt. This includes any text, images, or other media provided in the request. When cached_content is set, this also includes the number of tokens in the cached content.
- prompt_tokens_details: list[ModalityTokenCountDict] | None¶
Output only. A detailed breakdown of the token count for each modality in the prompt.
- thoughts_token_count: int | None¶
Output only. The number of tokens that were part of the model’s generated “thoughts” output, if applicable.
- tool_use_prompt_token_count: int | None¶
Output only. The number of tokens in the results from tool executions, which are provided back to the model as input, if applicable.
- tool_use_prompt_tokens_details: list[ModalityTokenCountDict] | None¶
Output only. A detailed breakdown by modality of the token counts from the results of tool executions, which are provided back to the model as input.
- total_token_count: int | None¶
The total number of tokens for the entire request. This is the sum of prompt_token_count, candidates_token_count, tool_use_prompt_token_count, and thoughts_token_count.
- traffic_type: TrafficType | None¶
Output only. The traffic type for this request.
- class genai.types.GenerateImagesConfig(**data)¶
Bases:
BaseModelThe config for generating an images.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- add_watermark: bool | None¶
- aspect_ratio: str | None¶
- enhance_prompt: bool | None¶
- guidance_scale: float | None¶
- http_options: HttpOptions | None¶
- image_size: str | None¶
- include_rai_reason: bool | None¶
- include_safety_attributes: bool | None¶
- labels: dict[str, str] | None¶
- language: ImagePromptLanguage | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- negative_prompt: str | None¶
- number_of_images: int | None¶
- output_compression_quality: int | None¶
- output_gcs_uri: str | None¶
- output_mime_type: str | None¶
- person_generation: PersonGeneration | None¶
- safety_filter_level: SafetyFilterLevel | None¶
- seed: int | None¶
- class genai.types.GenerateImagesConfigDict¶
Bases:
TypedDictThe config for generating an images.
- add_watermark: bool | None¶
Whether to add a watermark to the generated images.
- aspect_ratio: str | None¶
Aspect ratio of the generated images. Supported values are “1:1”, “3:4”, “4:3”, “9:16”, and “16:9”.
- enhance_prompt: bool | None¶
Whether to use the prompt rewriting logic.
- guidance_scale: float | None¶
Controls how much the model adheres to the text prompt. Large values increase output and prompt alignment, but may compromise image quality.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- image_size: str | None¶
The size of the largest dimension of the generated image. Supported sizes are 1K and 2K (not supported for Imagen 3 models).
- include_rai_reason: bool | None¶
Whether to include the Responsible AI filter reason if the image is filtered out of the response.
- include_safety_attributes: bool | None¶
Whether to report the safety scores of each generated image and the positive prompt in the response.
- labels: dict[str, str] | None¶
User specified labels to track billing usage.
- language: ImagePromptLanguage | None¶
Language of the text in the prompt.
- negative_prompt: str | None¶
Description of what to discourage in the generated images.
- number_of_images: int | None¶
Number of images to generate.
- output_compression_quality: int | None¶
Compression quality of the generated image (for
image/jpegonly).
- output_gcs_uri: str | None¶
Cloud Storage URI used to store the generated images.
- output_mime_type: str | None¶
MIME type of the generated image.
- person_generation: PersonGeneration | None¶
Allows generation of people by the model.
- safety_filter_level: SafetyFilterLevel | None¶
Filter level for safety filtering.
- seed: int | None¶
Random seed for image generation. This is not available when
add_watermarkis set to true.
- class genai.types.GenerateImagesResponse(**data)¶
Bases:
BaseModelThe output images response.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- generated_images: list[GeneratedImage] | None¶
- property images: list[Image | None]¶
Returns the list of all generated images.
A convenience method for accessing the images. Some attributes of the generated image are only available through the
GeneratedImageobject.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- positive_prompt_safety_attributes: SafetyAttributes | None¶
- sdk_http_response: HttpResponse | None¶
- class genai.types.GenerateImagesResponseDict¶
Bases:
TypedDictThe output images response.
- generated_images: list[GeneratedImageDict] | None¶
List of generated images.
- positive_prompt_safety_attributes: SafetyAttributesDict | None¶
Safety attributes of the positive prompt. Only populated if
include_safety_attributesis set to True.
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.GenerateVideosConfig(**data)¶
Bases:
BaseModelConfiguration for generating videos.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- aspect_ratio: str | None¶
- compression_quality: VideoCompressionQuality | None¶
- duration_seconds: int | None¶
- enhance_prompt: bool | None¶
- fps: int | None¶
- generate_audio: bool | None¶
- http_options: HttpOptions | None¶
- labels: dict[str, str] | None¶
- mask: VideoGenerationMask | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- negative_prompt: str | None¶
- number_of_videos: int | None¶
- output_gcs_uri: str | None¶
- person_generation: str | None¶
- pubsub_topic: str | None¶
- reference_images: list[VideoGenerationReferenceImage] | None¶
- resize_mode: ImageResizeMode | None¶
- resolution: str | None¶
- seed: int | None¶
- webhook_config: WebhookConfig | None¶
- class genai.types.GenerateVideosConfigDict¶
Bases:
TypedDictConfiguration for generating videos.
- aspect_ratio: str | None¶
9 (landscape) and 9:16 (portrait) are supported.
- Type:
The aspect ratio for the generated video. 16
- compression_quality: VideoCompressionQuality | None¶
Compression quality of the generated videos.
- duration_seconds: int | None¶
Duration of the clip for video generation in seconds.
- enhance_prompt: bool | None¶
Whether to use the prompt rewriting logic.
- fps: int | None¶
Frames per second for video generation.
- generate_audio: bool | None¶
Whether to generate audio along with the video.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- labels: dict[str, str] | None¶
User specified labels to track billing usage.
- last_frame: ImageDict | None¶
Image to use as the last frame of generated videos. Only supported for image to video use cases.
- mask: VideoGenerationMaskDict | None¶
The mask to use for generating videos.
- negative_prompt: str | None¶
Explicitly state what should not be included in the generated videos.
- number_of_videos: int | None¶
Number of output videos.
- output_gcs_uri: str | None¶
The gcs bucket where to save the generated videos.
- person_generation: str | None¶
Whether allow to generate person videos, and restrict to specific ages. Supported values are: dont_allow, allow_adult.
- pubsub_topic: str | None¶
The pubsub topic where to publish the video generation progress.
- reference_images: list[VideoGenerationReferenceImageDict] | None¶
The images to use as the references to generate the videos. If this field is provided, the text prompt field must also be provided. The image, video, or last_frame field are not supported. Each image must be associated with a type. Veo 2 supports up to 3 asset images or 1 style image.
- resize_mode: ImageResizeMode | None¶
Resize mode of the image input for video generation.
- resolution: str | None¶
The resolution for the generated video. 720p and 1080p are supported.
- seed: int | None¶
The RNG seed. If RNG seed is exactly same for each request with unchanged inputs, the prediction results will be consistent. Otherwise, a random RNG seed will be used each time to produce a different result.
- webhook_config: WebhookConfigDict | None¶
Webhook configuration for receiving notifications when the video generation operation completes.
- class genai.types.GenerateVideosOperation(**data)¶
Bases:
BaseModel,OperationA video generation operation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- classmethod from_api_response(api_response, is_vertex_ai=False)¶
Instantiates a GenerateVideosOperation from an API response.
- Return type:
Self
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- response: GenerateVideosResponse | None¶
- result: GenerateVideosResponse | None¶
- class genai.types.GenerateVideosResponse(**data)¶
Bases:
BaseModelResponse with generated videos.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- generated_videos: list[GeneratedVideo] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- rai_media_filtered_count: int | None¶
- rai_media_filtered_reasons: list[str] | None¶
- class genai.types.GenerateVideosResponseDict¶
Bases:
TypedDictResponse with generated videos.
- generated_videos: list[GeneratedVideoDict] | None¶
List of the generated videos
- rai_media_filtered_count: int | None¶
Returns if any videos were filtered due to RAI policies.
- rai_media_filtered_reasons: list[str] | None¶
Returns rai failure reasons if any.
- class genai.types.GenerateVideosSource(**data)¶
Bases:
BaseModelA set of source input(s) for video generation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- prompt: str | None¶
- class genai.types.GenerateVideosSourceDict¶
Bases:
TypedDictA set of source input(s) for video generation.
- image: ImageDict | None¶
The input image for generating the videos. Optional if prompt is provided. Not allowed if video is provided.
- prompt: str | None¶
The text prompt for generating the videos. Optional if image or video is provided.
- class genai.types.GeneratedImage(**data)¶
Bases:
BaseModelAn output image.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- enhanced_prompt: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- rai_filtered_reason: str | None¶
- safety_attributes: SafetyAttributes | None¶
- class genai.types.GeneratedImageDict¶
Bases:
TypedDictAn output image.
- enhanced_prompt: str | None¶
The rewritten prompt used for the image generation if the prompt enhancer is enabled.
- rai_filtered_reason: str | None¶
Responsible AI filter reason if the image is filtered out of the response.
- safety_attributes: SafetyAttributesDict | None¶
Safety attributes of the image. Lists of RAI categories and their scores of each content.
- class genai.types.GeneratedImageMask(**data)¶
Bases:
BaseModelA generated image mask.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- labels: list[EntityLabel] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.GeneratedImageMaskDict¶
Bases:
TypedDictA generated image mask.
- labels: list[EntityLabelDict] | None¶
The detected entities on the segmented area.
- class genai.types.GeneratedVideo(**data)¶
Bases:
BaseModelA generated video.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.GeneratedVideoDict¶
Bases:
TypedDictA generated video.
- class genai.types.GenerationConfig(**data)¶
Bases:
BaseModelGeneration config.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- audio_timestamp: bool | None¶
- audio_transcription_config: AudioTranscriptionConfig | None¶
- candidate_count: int | None¶
- enable_affective_dialog: bool | None¶
- enable_enhanced_civic_answers: bool | None¶
- frequency_penalty: float | None¶
- logprobs: int | None¶
- max_output_tokens: int | None¶
- media_resolution: MediaResolution | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_selection_config: ModelSelectionConfig | None¶
- presence_penalty: float | None¶
- response_format: list[ResponseFormat] | None¶
- response_json_schema: Any | None¶
- response_logprobs: bool | None¶
- response_mime_type: str | None¶
- routing_config: GenerationConfigRoutingConfig | None¶
- seed: int | None¶
- speech_config: SpeechConfig | None¶
- stop_sequences: list[str] | None¶
- temperature: float | None¶
- thinking_config: ThinkingConfig | None¶
- top_k: float | None¶
- top_p: float | None¶
- translation_config: TranslationConfig | None¶
- class genai.types.GenerationConfigDict¶
Bases:
TypedDictGeneration config.
- audio_timestamp: bool | None¶
Optional. If enabled, audio timestamps will be included in the request to the model. This can be useful for synchronizing audio with other modalities in the response. This field is not supported in Gemini API.
- audio_transcription_config: AudioTranscriptionConfigDict | None¶
Optional. Configuration for audio transcription (speech recognition).
- candidate_count: int | None¶
Optional. The number of candidate responses to generate. A higher candidate_count can provide more options to choose from, but it also consumes more resources. This can be useful for generating a variety of responses and selecting the best one.
- enable_affective_dialog: bool | None¶
Optional. If enabled, the model will detect emotions and adapt its responses accordingly. For example, if the model detects that the user is frustrated, it may provide a more empathetic response.
- enable_enhanced_civic_answers: bool | None¶
Optional. Enables enhanced civic answers. It may not be available for all models. This field is not supported in Vertex AI.
- frequency_penalty: float | None¶
Optional. Penalizes tokens based on their frequency in the generated text. A positive value helps to reduce the repetition of words and phrases. Valid values can range from [-2.0, 2.0].
- logprobs: int | None¶
Optional. The number of top log probabilities to return for each token. This can be used to see which other tokens were considered likely candidates for a given position. A higher value will return more options, but it will also increase the size of the response.
- max_output_tokens: int | None¶
Optional. The maximum number of tokens to generate in the response. A token is approximately four characters. The default value varies by model. This parameter can be used to control the length of the generated text and prevent overly long responses.
- media_resolution: MediaResolution | None¶
Optional. The token resolution at which input media content is sampled. This is used to control the trade-off between the quality of the response and the number of tokens used to represent the media. A higher resolution allows the model to perceive more detail, which can lead to a more nuanced response, but it will also use more tokens. This does not affect the image dimensions sent to the model.
- model_selection_config: ModelSelectionConfigDict | None¶
Optional. Config for model selection.
- presence_penalty: float | None¶
Optional. Penalizes tokens that have already appeared in the generated text. A positive value encourages the model to generate more diverse and less repetitive text. Valid values can range from [-2.0, 2.0].
- response_format: list[ResponseFormatDict] | None¶
Optional. New response format field for the model to configure output formatting and delivery.
- response_json_schema: Any | None¶
Output schema of the generated response. This is an alternative to response_schema that accepts [JSON Schema](https://json-schema.org/).
- response_logprobs: bool | None¶
Optional. If set to true, the log probabilities of the output tokens are returned. Log probabilities are the logarithm of the probability of a token appearing in the output. A higher log probability means the token is more likely to be generated. This can be useful for analyzing the model’s confidence in its own output and for debugging.
- response_mime_type: str | None¶
Use response_format instead.
- Type:
Optional. The IANA standard MIME type of the response. The model will generate output that conforms to this MIME type. Supported values include ‘text/plain’ (default) and ‘application/json’. The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined. Deprecated
- response_modalities: list[Modality] | None¶
Optional. The modalities of the response. The model will generate a response that includes all the specified modalities. For example, if this is set to [TEXT, IMAGE], the response will include both text and an image.
- response_schema: SchemaDict | None¶
Use response_format instead.
- Type:
Optional. Lets you to specify a schema for the model’s response, ensuring that the output conforms to a particular structure. This is useful for generating structured data such as JSON. The schema is a subset of the [OpenAPI 3.0 schema object](https
- Type:
//spec.openapis.org/oas/v3.0.3#schema) object. When this field is set, you must also set the response_mime_type to application/json. Deprecated
- routing_config: GenerationConfigRoutingConfigDict | None¶
Optional. Routing configuration. This field is not supported in Gemini API.
- seed: int | None¶
Optional. A seed for the random number generator. By setting a seed, you can make the model’s output mostly deterministic. For a given prompt and parameters (like temperature, top_p, etc.), the model will produce the same response every time. However, it’s not a guaranteed absolute deterministic behavior. This is different from parameters like temperature, which control the level of randomness. seed ensures that the “random” choices the model makes are the same on every run, making it essential for testing and ensuring reproducible results.
- speech_config: SpeechConfigDict | None¶
Optional. The speech generation config.
- stop_sequences: list[str] | None¶
Optional. A list of character sequences that will stop the model from generating further tokens. If a stop sequence is generated, the output will end at that point. This is useful for controlling the length and structure of the output. For example, you can use [” “, “###”] to stop generation at a new line or a specific marker.
- temperature: float | None¶
Optional. Controls the randomness of the output. A higher temperature results in more creative and diverse responses, while a lower temperature makes the output more predictable and focused. The valid range is (0.0, 2.0].
- thinking_config: ThinkingConfigDict | None¶
Optional. Configuration for thinking features. An error will be returned if this field is set for models that don’t support thinking.
- top_k: float | None¶
Optional. Specifies the top-k sampling threshold. The model considers only the top k most probable tokens for the next token. This can be useful for generating more coherent and less random text. For example, a top_k of 40 means the model will choose the next word from the 40 most likely words.
- top_p: float | None¶
Optional. Specifies the nucleus sampling threshold. The model considers only the smallest set of tokens whose cumulative probability is at least top_p. This helps generate more diverse and less repetitive responses. For example, a top_p of 0.9 means the model considers tokens until the cumulative probability of the tokens to select from reaches 0.9. It’s recommended to adjust either temperature or top_p, but not both.
- translation_config: TranslationConfigDict | None¶
Optional. Config for translation.
- class genai.types.GenerationConfigRoutingConfig(**data)¶
Bases:
BaseModelThe configuration for routing the request to a specific model.
This can be used to control which model is used for the generation, either automatically or by specifying a model name. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- auto_mode: GenerationConfigRoutingConfigAutoRoutingMode | None¶
- manual_mode: GenerationConfigRoutingConfigManualRoutingMode | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.GenerationConfigRoutingConfigAutoRoutingMode(**data)¶
Bases:
BaseModelThe configuration for automated routing.
When automated routing is specified, the routing will be determined by the pretrained routing model and customer provided model routing preference. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_routing_preference: Literal['UNKNOWN', 'PRIORITIZE_QUALITY', 'BALANCED', 'PRIORITIZE_COST'] | None¶
- class genai.types.GenerationConfigRoutingConfigAutoRoutingModeDict¶
Bases:
TypedDictThe configuration for automated routing.
When automated routing is specified, the routing will be determined by the pretrained routing model and customer provided model routing preference. This data type is not supported in Gemini API.
- model_routing_preference: Literal['UNKNOWN', 'PRIORITIZE_QUALITY', 'BALANCED', 'PRIORITIZE_COST'] | None¶
The model routing preference.
- class genai.types.GenerationConfigRoutingConfigDict¶
Bases:
TypedDictThe configuration for routing the request to a specific model.
This can be used to control which model is used for the generation, either automatically or by specifying a model name. This data type is not supported in Gemini API.
- auto_mode: GenerationConfigRoutingConfigAutoRoutingModeDict | None¶
In this mode, the model is selected automatically based on the content of the request.
- manual_mode: GenerationConfigRoutingConfigManualRoutingModeDict | None¶
In this mode, the model is specified manually.
- class genai.types.GenerationConfigRoutingConfigManualRoutingMode(**data)¶
Bases:
BaseModelThe configuration for manual routing.
When manual routing is specified, the model will be selected based on the model name provided. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_name: str | None¶
- class genai.types.GenerationConfigRoutingConfigManualRoutingModeDict¶
Bases:
TypedDictThe configuration for manual routing.
When manual routing is specified, the model will be selected based on the model name provided. This data type is not supported in Gemini API.
- model_name: str | None¶
The name of the model to use. Only public LLM models are accepted.
- class genai.types.GenerationConfigThinkingConfig(**data)¶
Bases:
ThinkingConfigConfig for thinking feature.
This class will be deprecated. Please use ThinkingConfig instead.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.GenerationConfigThinkingConfigDict¶
Bases:
ThinkingConfigDictConfig for thinking feature.
This class will be deprecated. Please use ThinkingConfig instead.
- include_thoughts: bool | None¶
- thinking_budget: int | None¶
- thinking_level: ThinkingLevel | None¶
- class genai.types.GetBatchJobConfig(**data)¶
Bases:
BaseModelOptional parameters.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.GetBatchJobConfigDict¶
Bases:
TypedDictOptional parameters.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.GetCachedContentConfig(**data)¶
Bases:
BaseModelOptional parameters for caches.get method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.GetCachedContentConfigDict¶
Bases:
TypedDictOptional parameters for caches.get method.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.GetDocumentConfig(**data)¶
Bases:
BaseModelOptional Config.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.GetDocumentConfigDict¶
Bases:
TypedDictOptional Config.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.GetFileConfig(**data)¶
Bases:
BaseModelUsed to override the default configuration.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.GetFileConfigDict¶
Bases:
TypedDictUsed to override the default configuration.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.GetFileSearchStoreConfig(**data)¶
Bases:
BaseModelOptional parameters for getting a FileSearchStore.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.GetFileSearchStoreConfigDict¶
Bases:
TypedDictOptional parameters for getting a FileSearchStore.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.GetModelConfig(**data)¶
Bases:
BaseModelOptional parameters for models.get method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.GetModelConfigDict¶
Bases:
TypedDictOptional parameters for models.get method.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.GetOperationConfig(**data)¶
Bases:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.GetOperationConfigDict¶
Bases:
TypedDict- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.GetTuningJobConfig(**data)¶
Bases:
BaseModelOptional parameters for tunings.get method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.GetTuningJobConfigDict¶
Bases:
TypedDictOptional parameters for tunings.get method.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.GoogleMaps(**data)¶
Bases:
BaseModelTool to retrieve knowledge from Google Maps.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- auth_config: AuthConfig | None¶
- enable_widget: bool | None¶
- grounding_types: GoogleMapsGroundingTypes | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.GoogleMapsDict¶
Bases:
TypedDictTool to retrieve knowledge from Google Maps.
- auth_config: AuthConfigDict | None¶
The authentication config to access the API. Only API key is supported. This field is not supported in Gemini API.
- enable_widget: bool | None¶
Deprecated. The Google Maps contextual widget behavior in Grounding with Google Maps is being deprecated; this field is planned for removal and no longer has any effect once removed. Optional. Whether to return a widget context token in the GroundingMetadata of the response.
- grounding_types: GoogleMapsGroundingTypesDict | None¶
Optional. Specifies the types of Google Maps grounding to enable. Defaults to places when unset. This field is not supported in Gemini API.
- class genai.types.GoogleMapsGroundingTypes(**data)¶
Bases:
BaseModelDefines the types of Google Maps grounding that can be enabled and their configurations.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- places: GoogleMapsPlaces | None¶
- routing: GoogleMapsRouting | None¶
- class genai.types.GoogleMapsGroundingTypesDict¶
Bases:
TypedDictDefines the types of Google Maps grounding that can be enabled and their configurations.
This data type is not supported in Gemini API.
- places: GoogleMapsPlacesDict | None¶
Optional. Enables grounding with Google Maps Places. This is the default grounding type when no GroundingTypes are specified.
- routing: GoogleMapsRoutingDict | None¶
Optional. Enables grounding with Google Maps Routing APIs (ComputeRoutes and SearchAlongRoute).
- class genai.types.GoogleMapsPlaces(**data)¶
Bases:
BaseModelGrounding with Google Maps Places data (e.g.
QueryPlaces). This is the default Google Maps grounding type when no other type is specified. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.GoogleMapsPlacesDict¶
Bases:
TypedDictGrounding with Google Maps Places data (e.g.
QueryPlaces). This is the default Google Maps grounding type when no other type is specified. This data type is not supported in Gemini API.
- class genai.types.GoogleMapsRouting(**data)¶
Bases:
BaseModelGrounding with Google Maps Routing APIs (ComputeRoutes and SearchAlongRoute).
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.GoogleMapsRoutingDict¶
Bases:
TypedDictGrounding with Google Maps Routing APIs (ComputeRoutes and SearchAlongRoute).
This data type is not supported in Gemini API.
- class genai.types.GoogleRpcStatus(**data)¶
Bases:
BaseModelThe Status type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs.
It is used by [gRPC](https://github.com/grpc). Each Status message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- code: int | None¶
- details: list[dict[str, Any]] | None¶
- message: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.GoogleRpcStatusDict¶
Bases:
TypedDictThe Status type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs.
It is used by [gRPC](https://github.com/grpc). Each Status message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). This data type is not supported in Gemini API.
- code: int | None¶
The status code, which should be an enum value of google.rpc.Code.
- details: list[dict[str, Any]] | None¶
A list of messages that carry the error details. There is a common set of message types for APIs to use.
- message: str | None¶
A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
- class genai.types.GoogleSearch(**data)¶
Bases:
BaseModelGoogleSearch tool type.
Tool to support Google Search in Model. Powered by Google.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- blocking_confidence: PhishBlockThreshold | None¶
- exclude_domains: list[str] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- search_types: SearchTypes | None¶
- class genai.types.GoogleSearchDict¶
Bases:
TypedDictGoogleSearch tool type.
Tool to support Google Search in Model. Powered by Google.
- blocking_confidence: PhishBlockThreshold | None¶
Optional. Sites with confidence level chosen & above this value will be blocked from the search results. This field is not supported in Gemini API.
- exclude_domains: list[str] | None¶
[“amazon.com”, “facebook.com”]. This field is not supported in Gemini API.
- Type:
Optional. List of domains to be excluded from the search results. The default limit is 2000 domains. Example
- search_types: SearchTypesDict | None¶
Optional. The set of search types to enable. If not set, web search is enabled by default.
- time_range_filter: IntervalDict | None¶
Optional. Filter search results to a specific time range. If customers set a start time, they must set an end time (and vice versa). This field is not supported in Vertex AI.
- class genai.types.GoogleSearchRetrieval(**data)¶
Bases:
BaseModelTool to retrieve public web data for grounding, powered by Google.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- dynamic_retrieval_config: DynamicRetrievalConfig | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.GoogleSearchRetrievalDict¶
Bases:
TypedDictTool to retrieve public web data for grounding, powered by Google.
- dynamic_retrieval_config: DynamicRetrievalConfigDict | None¶
Specifies the dynamic retrieval configuration for the given source.
- class genai.types.GoogleTypeDate(**data)¶
Bases:
BaseModelRepresents a whole or partial calendar date, such as a birthday.
The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following: * A full date, with non-zero year, month, and day values. * A month and day, with a zero year (for example, an anniversary). * A year on its own, with a zero month and a zero day. * A year and month, with a zero day (for example, a credit card expiration date). Related types: * google.type.TimeOfDay * google.type.DateTime * google.protobuf.Timestamp. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- day: int | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- month: int | None¶
- year: int | None¶
- class genai.types.GoogleTypeDateDict¶
Bases:
TypedDictRepresents a whole or partial calendar date, such as a birthday.
The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following: * A full date, with non-zero year, month, and day values. * A month and day, with a zero year (for example, an anniversary). * A year on its own, with a zero month and a zero day. * A year and month, with a zero day (for example, a credit card expiration date). Related types: * google.type.TimeOfDay * google.type.DateTime * google.protobuf.Timestamp. This data type is not supported in Gemini API.
- day: int | None¶
Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn’t significant.
- month: int | None¶
Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
- year: int | None¶
Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
- class genai.types.GroundingChunk(**data)¶
Bases:
BaseModelA piece of evidence that supports a claim made by the model.
This is used to show a citation for a claim made by the model. When grounding is enabled, the model returns a GroundingChunk that contains a reference to the source of the information.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- image: GroundingChunkImage | None¶
- maps: GroundingChunkMaps | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- retrieved_context: GroundingChunkRetrievedContext | None¶
- web: GroundingChunkWeb | None¶
- class genai.types.GroundingChunkCustomMetadata(**data)¶
Bases:
BaseModelUser provided metadata about the GroundingFact.
This data type is not supported in Vertex AI.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- key: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- numeric_value: float | None¶
- string_list_value: GroundingChunkStringList | None¶
- string_value: str | None¶
- class genai.types.GroundingChunkCustomMetadataDict¶
Bases:
TypedDictUser provided metadata about the GroundingFact.
This data type is not supported in Vertex AI.
- key: str | None¶
The key of the metadata.
- numeric_value: float | None¶
Optional. The numeric value of the metadata. The expected range for this value depends on the specific key used.
- string_list_value: GroundingChunkStringListDict | None¶
Optional. A list of string values for the metadata.
- string_value: str | None¶
Optional. The string value of the metadata.
- class genai.types.GroundingChunkDict¶
Bases:
TypedDictA piece of evidence that supports a claim made by the model.
This is used to show a citation for a claim made by the model. When grounding is enabled, the model returns a GroundingChunk that contains a reference to the source of the information.
- image: GroundingChunkImageDict | None¶
A grounding chunk from an image search result. See the Image message for details.
- maps: GroundingChunkMapsDict | None¶
A Maps chunk is a piece of evidence that comes from Google Maps.
It contains information about a place, such as its name, address, and reviews. This is used to provide the user with rich, location-based information.
- retrieved_context: GroundingChunkRetrievedContextDict | None¶
A grounding chunk from a data source retrieved by a retrieval tool, such as Vertex AI Search. See the RetrievedContext message for details
- web: GroundingChunkWebDict | None¶
A grounding chunk from a web page, typically from Google Search. See the Web message for details.
- class genai.types.GroundingChunkImage(**data)¶
Bases:
BaseModelAn Image chunk is a piece of evidence that comes from an image search result.
It contains the URI of the image search result and the URI of the image. This is used to provide the user with a link to the source of the information.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- domain: str | None¶
- image_uri: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- source_uri: str | None¶
- title: str | None¶
- class genai.types.GroundingChunkImageDict¶
Bases:
TypedDictAn Image chunk is a piece of evidence that comes from an image search result.
It contains the URI of the image search result and the URI of the image. This is used to provide the user with a link to the source of the information.
- domain: str | None¶
The domain of the image search result page.
- image_uri: str | None¶
The URI of the image.
- source_uri: str | None¶
The URI of the image search result page.
- title: str | None¶
The title of the image search result page.
- class genai.types.GroundingChunkMaps(**data)¶
Bases:
BaseModelA Maps chunk is a piece of evidence that comes from Google Maps.
It contains information about a place, such as its name, address, and reviews. This is used to provide the user with rich, location-based information.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- place_answer_sources: GroundingChunkMapsPlaceAnswerSources | None¶
- place_id: str | None¶
- route: GroundingChunkMapsRoute | None¶
- text: str | None¶
- title: str | None¶
- uri: str | None¶
- class genai.types.GroundingChunkMapsDict¶
Bases:
TypedDictA Maps chunk is a piece of evidence that comes from Google Maps.
It contains information about a place, such as its name, address, and reviews. This is used to provide the user with rich, location-based information.
- place_answer_sources: GroundingChunkMapsPlaceAnswerSourcesDict | None¶
The sources that were used to generate the place answer.
This includes review snippets and photos that were used to generate the answer, as well as URIs to flag content.
- place_id: str | None¶
This Place’s resource name, in places/{place_id} format.
This can be used to look up the place in the Google Maps API.
- route: GroundingChunkMapsRouteDict | None¶
Output only. Route information.
- text: str | None¶
The text of the place answer.
- title: str | None¶
The title of the place.
- uri: str | None¶
The URI of the place.
- class genai.types.GroundingChunkMapsPlaceAnswerSources(**data)¶
Bases:
BaseModelThe sources that were used to generate the place answer.
This includes review snippets and photos that were used to generate the answer, as well as URIs to flag content.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- flag_content_uri: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- review_snippet: list[GroundingChunkMapsPlaceAnswerSourcesReviewSnippet] | None¶
- review_snippets: list[GroundingChunkMapsPlaceAnswerSourcesReviewSnippet] | None¶
- class genai.types.GroundingChunkMapsPlaceAnswerSourcesAuthorAttribution(**data)¶
Bases:
BaseModelAuthor attribution for a photo or review.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- display_name: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- photo_uri: str | None¶
- uri: str | None¶
- class genai.types.GroundingChunkMapsPlaceAnswerSourcesAuthorAttributionDict¶
Bases:
TypedDictAuthor attribution for a photo or review.
- display_name: str | None¶
Name of the author of the Photo or Review.
- photo_uri: str | None¶
Profile photo URI of the author of the Photo or Review.
- uri: str | None¶
URI of the author of the Photo or Review.
- class genai.types.GroundingChunkMapsPlaceAnswerSourcesDict¶
Bases:
TypedDictThe sources that were used to generate the place answer.
This includes review snippets and photos that were used to generate the answer, as well as URIs to flag content.
- flag_content_uri: str | None¶
A link where users can flag a problem with the generated answer.
- review_snippet: list[GroundingChunkMapsPlaceAnswerSourcesReviewSnippetDict] | None¶
Snippets of reviews that were used to generate the answer.
- review_snippets: list[GroundingChunkMapsPlaceAnswerSourcesReviewSnippetDict] | None¶
Snippets of reviews that were used to generate the answer.
- class genai.types.GroundingChunkMapsPlaceAnswerSourcesReviewSnippet(**data)¶
Bases:
BaseModelEncapsulates a review snippet.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- author_attribution: GroundingChunkMapsPlaceAnswerSourcesAuthorAttribution | None¶
- flag_content_uri: str | None¶
- google_maps_uri: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- relative_publish_time_description: str | None¶
- review: str | None¶
- review_id: str | None¶
- title: str | None¶
- class genai.types.GroundingChunkMapsPlaceAnswerSourcesReviewSnippetDict¶
Bases:
TypedDictEncapsulates a review snippet.
- author_attribution: GroundingChunkMapsPlaceAnswerSourcesAuthorAttributionDict | None¶
This review’s author.
- flag_content_uri: str | None¶
A link where users can flag a problem with the review.
- google_maps_uri: str | None¶
A link to show the review on Google Maps.
- relative_publish_time_description: str | None¶
A string of formatted recent time, expressing the review time relative to the current time in a form appropriate for the language and country.
- review: str | None¶
A reference representing this place review which may be used to look up this place review again.
- review_id: str | None¶
Id of the review referencing the place.
- title: str | None¶
Title of the review.
- class genai.types.GroundingChunkMapsRoute(**data)¶
Bases:
BaseModelRoute information from Google Maps.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- distance_meters: int | None¶
- duration: str | None¶
- encoded_polyline: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.GroundingChunkMapsRouteDict¶
Bases:
TypedDictRoute information from Google Maps.
This data type is not supported in Gemini API.
- distance_meters: int | None¶
The total distance of the route, in meters.
- duration: str | None¶
The total duration of the route.
- encoded_polyline: str | None¶
//developers.google.com/maps/documentation/utilities/polylinealgorithm
- Type:
An encoded polyline of the route. See https
- class genai.types.GroundingChunkRetrievedContext(**data)¶
Bases:
BaseModelContext retrieved from a data source to ground the model’s response.
This is used when a retrieval tool fetches information from a user-provided corpus or a public dataset.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- custom_metadata: list[GroundingChunkCustomMetadata] | None¶
- document_name: str | None¶
- file_search_store: str | None¶
- media_id: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- page_number: int | None¶
- text: str | None¶
- title: str | None¶
- uri: str | None¶
- class genai.types.GroundingChunkRetrievedContextDict¶
Bases:
TypedDictContext retrieved from a data source to ground the model’s response.
This is used when a retrieval tool fetches information from a user-provided corpus or a public dataset.
- custom_metadata: list[GroundingChunkCustomMetadataDict] | None¶
Optional. User-provided metadata about the retrieved context. This field is not supported in Vertex AI.
- document_name: str | None¶
Output only. The full resource name of the referenced Vertex AI Search document. This is used to identify the specific document that was retrieved. The format is projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}. This field is not supported in Gemini API.
- file_search_store: str | None¶
fileSearchStores/123. This field is not supported in Vertex AI.
- Type:
Optional. Name of the FileSearchStore containing the document. Example
- media_id: str | None¶
fileSearchStores/{file_search_store_id}/media/{blob_id}. This field is not supported in Vertex AI.
- Type:
Optional. The media blob resource name for multimodal file search results. Format
- page_number: int | None¶
Optional. Page number of the retrieved context, if applicable. This field is not supported in Vertex AI.
- rag_chunk: RagChunkDict | None¶
Additional context for a Retrieval-Augmented Generation (RAG) retrieval result. This is populated only when the RAG retrieval tool is used. This field is not supported in Gemini API.
- text: str | None¶
The content of the retrieved data source.
- title: str | None¶
The title of the retrieved data source.
- uri: str | None¶
The URI of the retrieved data source.
- class genai.types.GroundingChunkStringList(**data)¶
Bases:
BaseModelA list of string values. This data type is not supported in Vertex AI.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- values: list[str] | None¶
- class genai.types.GroundingChunkStringListDict¶
Bases:
TypedDictA list of string values. This data type is not supported in Vertex AI.
- class genai.types.GroundingChunkWeb(**data)¶
Bases:
BaseModelA Web chunk is a piece of evidence that comes from a web page.
It contains the URI of the web page, the title of the page, and the domain of the page. This is used to provide the user with a link to the source of the information.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- domain: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- title: str | None¶
- uri: str | None¶
- class genai.types.GroundingChunkWebDict¶
Bases:
TypedDictA Web chunk is a piece of evidence that comes from a web page.
It contains the URI of the web page, the title of the page, and the domain of the page. This is used to provide the user with a link to the source of the information.
- domain: str | None¶
The domain of the web page that contains the evidence. This can be used to filter out low-quality sources. This field is not supported in Gemini API.
- title: str | None¶
The title of the web page that contains the evidence.
- uri: str | None¶
The URI of the web page that contains the evidence.
- class genai.types.GroundingMetadata(**data)¶
Bases:
BaseModelInformation for various kinds of grounding.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- google_maps_widget_context_token: str | None¶
- grounding_chunks: list[GroundingChunk] | None¶
- grounding_supports: list[GroundingSupport] | None¶
- image_search_queries: list[str] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- retrieval_metadata: RetrievalMetadata | None¶
- retrieval_queries: list[str] | None¶
- search_entry_point: SearchEntryPoint | None¶
- source_flagging_uris: list[GroundingMetadataSourceFlaggingUri] | None¶
- web_search_queries: list[str] | None¶
- class genai.types.GroundingMetadataDict¶
Bases:
TypedDictInformation for various kinds of grounding.
- google_maps_widget_context_token: str | None¶
The Google Maps contextual widget behavior in Grounding with Google Maps is being deprecated; this field is planned for removal and will no longer be populated once removed. A token that can be used to render a Google Maps widget with the contextual data. This field is populated only when the grounding source is Google Maps.
- Type:
Optional. Output only. Deprecated
- grounding_chunks: list[GroundingChunkDict] | None¶
A list of supporting references retrieved from the grounding source. This field is populated when the grounding source is Google Search, Vertex AI Search, or Google Maps.
- grounding_supports: list[GroundingSupportDict] | None¶
List of grounding support.
- image_search_queries: list[str] | None¶
Optional. The image search queries that were used to generate the content. This field is populated only when the grounding source is Google Search with the Image Search search_type enabled.
- retrieval_metadata: RetrievalMetadataDict | None¶
Metadata related to retrieval in the grounding flow.
- retrieval_queries: list[str] | None¶
Optional. The queries that were executed by the retrieval tools. This field is populated only when the grounding source is a retrieval tool, such as Vertex AI Search. This field is not supported in Gemini API.
- search_entry_point: SearchEntryPointDict | None¶
Optional. Google search entry for the following-up web searches.
- source_flagging_uris: list[GroundingMetadataSourceFlaggingUriDict] | None¶
Optional. Output only. A list of URIs that can be used to flag a place or review for inappropriate content. This field is populated only when the grounding source is Google Maps. This field is not supported in Gemini API.
- web_search_queries: list[str] | None¶
Web search queries for the following-up web search.
- class genai.types.GroundingMetadataSourceFlaggingUri(**data)¶
Bases:
BaseModelA URI that can be used to flag a place or review for inappropriate content.
This is populated only when the grounding source is Google Maps. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- flag_content_uri: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- source_id: str | None¶
- class genai.types.GroundingMetadataSourceFlaggingUriDict¶
Bases:
TypedDictA URI that can be used to flag a place or review for inappropriate content.
This is populated only when the grounding source is Google Maps. This data type is not supported in Gemini API.
- flag_content_uri: str | None¶
The URI that can be used to flag the content.
- source_id: str | None¶
The ID of the place or review.
- class genai.types.GroundingSupport(**data)¶
Bases:
BaseModelGrounding support.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- confidence_scores: list[float] | None¶
- grounding_chunk_indices: list[int] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- rendered_parts: list[int] | None¶
- class genai.types.GroundingSupportDict¶
Bases:
TypedDictGrounding support.
- confidence_scores: list[float] | None¶
Confidence score of the support references.
Ranges from 0 to 1. 1 is the most confident. This list must have the same size as the grounding_chunk_indices.
- grounding_chunk_indices: list[int] | None¶
A list of indices (into ‘grounding_chunk’) specifying the citations associated with the claim. For instance [1,3,4] means that grounding_chunk[1], grounding_chunk[3], grounding_chunk[4] are the retrieved content attributed to the claim.
- rendered_parts: list[int] | None¶
Indices into the rendered_parts field of the GroundingMetadata message. These indices specify which rendered parts are associated with this support message.
- segment: SegmentDict | None¶
Segment of the content this support belongs to.
- class genai.types.HarmBlockMethod(*values)¶
Bases:
CaseInSensitiveEnumThe method for blocking content.
If not specified, the default behavior is to use the probability score. This enum is not supported in Gemini API.
- HARM_BLOCK_METHOD_UNSPECIFIED = 'HARM_BLOCK_METHOD_UNSPECIFIED'¶
The harm block method is unspecified.
- PROBABILITY = 'PROBABILITY'¶
The harm block method uses the probability score.
- SEVERITY = 'SEVERITY'¶
The harm block method uses both probability and severity scores.
- class genai.types.HarmBlockThreshold(*values)¶
Bases:
CaseInSensitiveEnumThe threshold for blocking content.
If the harm probability exceeds this threshold, the content will be blocked.
- BLOCK_LOW_AND_ABOVE = 'BLOCK_LOW_AND_ABOVE'¶
Block content with a low harm probability or higher.
- BLOCK_MEDIUM_AND_ABOVE = 'BLOCK_MEDIUM_AND_ABOVE'¶
Block content with a medium harm probability or higher.
- BLOCK_NONE = 'BLOCK_NONE'¶
Do not block any content, regardless of its harm probability.
- BLOCK_ONLY_HIGH = 'BLOCK_ONLY_HIGH'¶
Block content with a high harm probability.
- HARM_BLOCK_THRESHOLD_UNSPECIFIED = 'HARM_BLOCK_THRESHOLD_UNSPECIFIED'¶
The harm block threshold is unspecified.
- OFF = 'OFF'¶
Turn off the safety filter entirely.
- class genai.types.HarmCategory(*values)¶
Bases:
CaseInSensitiveEnumThe harm category to be blocked.
- HARM_CATEGORY_CIVIC_INTEGRITY = 'HARM_CATEGORY_CIVIC_INTEGRITY'¶
Election filter is not longer supported. The harm category is civic integrity.
- Type:
Deprecated
- HARM_CATEGORY_DANGEROUS_CONTENT = 'HARM_CATEGORY_DANGEROUS_CONTENT'¶
Content that promotes, facilitates, or enables dangerous activities.
- HARM_CATEGORY_HARASSMENT = 'HARM_CATEGORY_HARASSMENT'¶
Abusive, threatening, or content intended to bully, torment, or ridicule.
- HARM_CATEGORY_HATE_SPEECH = 'HARM_CATEGORY_HATE_SPEECH'¶
Content that promotes violence or incites hatred against individuals or groups based on certain attributes.
- HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT = 'HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT'¶
Images that contain dangerous content. This enum value is not supported in Gemini API.
- HARM_CATEGORY_IMAGE_HARASSMENT = 'HARM_CATEGORY_IMAGE_HARASSMENT'¶
Images that contain harassment. This enum value is not supported in Gemini API.
- HARM_CATEGORY_IMAGE_HATE = 'HARM_CATEGORY_IMAGE_HATE'¶
Images that contain hate speech. This enum value is not supported in Gemini API.
- HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT = 'HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT'¶
Images that contain sexually explicit content. This enum value is not supported in Gemini API.
- HARM_CATEGORY_JAILBREAK = 'HARM_CATEGORY_JAILBREAK'¶
Prompts designed to bypass safety filters.
- HARM_CATEGORY_SEXUALLY_EXPLICIT = 'HARM_CATEGORY_SEXUALLY_EXPLICIT'¶
Content that contains sexually explicit material.
- HARM_CATEGORY_UNSPECIFIED = 'HARM_CATEGORY_UNSPECIFIED'¶
Default value. This value is unused.
- class genai.types.HarmProbability(*values)¶
Bases:
CaseInSensitiveEnumOutput only. The probability of harm for this category.
- HARM_PROBABILITY_UNSPECIFIED = 'HARM_PROBABILITY_UNSPECIFIED'¶
The harm probability is unspecified.
- HIGH = 'HIGH'¶
The harm probability is high.
- LOW = 'LOW'¶
The harm probability is low.
- MEDIUM = 'MEDIUM'¶
The harm probability is medium.
- NEGLIGIBLE = 'NEGLIGIBLE'¶
The harm probability is negligible.
- class genai.types.HarmSeverity(*values)¶
Bases:
CaseInSensitiveEnumOutput only.
The severity of harm for this category. This enum is not supported in Gemini API.
- HARM_SEVERITY_HIGH = 'HARM_SEVERITY_HIGH'¶
The harm severity is high.
- HARM_SEVERITY_LOW = 'HARM_SEVERITY_LOW'¶
The harm severity is low.
- HARM_SEVERITY_MEDIUM = 'HARM_SEVERITY_MEDIUM'¶
The harm severity is medium.
- HARM_SEVERITY_NEGLIGIBLE = 'HARM_SEVERITY_NEGLIGIBLE'¶
The harm severity is negligible.
- HARM_SEVERITY_UNSPECIFIED = 'HARM_SEVERITY_UNSPECIFIED'¶
The harm severity is unspecified.
- class genai.types.HistoryConfig(**data)¶
Bases:
BaseModelConfiguration for history exchange between client and server.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- initial_history_in_client_content: bool | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.HistoryConfigDict¶
Bases:
TypedDictConfiguration for history exchange between client and server.
- initial_history_in_client_content: bool | None¶
If true, after sending setup_complete, the server will wait and at first process client_content messages until turn_complete is true. This initial history will not trigger a model call and may end with model content. After turn_complete is true, the client can start the realtime conversation via realtime_input.
- class genai.types.HttpElementLocation(*values)¶
Bases:
CaseInSensitiveEnumThe location of the API key. This enum is not supported in Gemini API.
- HTTP_IN_BODY = 'HTTP_IN_BODY'¶
Element is in the HTTP request body.
- HTTP_IN_COOKIE = 'HTTP_IN_COOKIE'¶
Element is in the HTTP request cookie.
- HTTP_IN_HEADER = 'HTTP_IN_HEADER'¶
Element is in the HTTP request header.
- HTTP_IN_PATH = 'HTTP_IN_PATH'¶
Element is in the HTTP request path.
- HTTP_IN_QUERY = 'HTTP_IN_QUERY'¶
Element is in the HTTP request query.
- HTTP_IN_UNSPECIFIED = 'HTTP_IN_UNSPECIFIED'¶
- class genai.types.HttpOptions(**data)¶
Bases:
BaseModelHTTP options to be used in each of the requests.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- aiohttp_client: ClientSession | None¶
- api_version: str | None¶
- async_client_args: dict[str, Any] | None¶
- base_url: str | None¶
- base_url_resource_scope: ResourceScope | None¶
- client_args: dict[str, Any] | None¶
- extra_body: dict[str, Any] | None¶
- headers: dict[str, str] | None¶
- httpx_async_client: AsyncClient | AsyncClient | None¶
- httpx_client: Client | Client | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- retry_options: HttpRetryOptions | None¶
- timeout: int | None¶
- class genai.types.HttpOptionsDict¶
Bases:
TypedDictHTTP options to be used in each of the requests.
- api_version: str | None¶
Specifies the version of the API to use.
- async_client_args: dict[str, Any] | None¶
Args passed to the async HTTP client.
- base_url: str | None¶
The base URL for the AI platform service endpoint.
- base_url_resource_scope: ResourceScope | None¶
The resource scope used to constructing the resource name when base_url is set
- client_args: dict[str, Any] | None¶
Args passed to the HTTP client.
- extra_body: dict[str, Any] | None¶
Extra parameters to add to the request body. The structure must match the backend API’s request structure. - Gemini Enterprise Agent Platform backend API docs: https://cloud.google.com/vertex-ai/docs/reference/rest - GeminiAPI backend API docs: https://ai.google.dev/api/rest
- headers: dict[str, str] | None¶
Additional HTTP headers to be sent with the request.
- retry_options: HttpRetryOptionsDict | None¶
HTTP retry options for the request.
- timeout: int | None¶
Timeout for the request in milliseconds.
- class genai.types.HttpResponse(**data)¶
Bases:
BaseModelA wrapper class for the http response.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- body: str | None¶
- headers: dict[str, str] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.HttpResponseDict¶
Bases:
TypedDictA wrapper class for the http response.
- body: str | None¶
The raw HTTP response body, in JSON format.
- headers: dict[str, str] | None¶
Used to retain the processed HTTP headers in the response.
- class genai.types.HttpRetryOptions(**data)¶
Bases:
BaseModelHTTP retry options to be used in each of the requests.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- attempts: int | None¶
- exp_base: float | None¶
- http_status_codes: list[int] | None¶
- initial_delay: float | None¶
- jitter: float | None¶
- max_delay: float | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.HttpRetryOptionsDict¶
Bases:
TypedDictHTTP retry options to be used in each of the requests.
- attempts: int | None¶
Maximum number of attempts, including the original request. If 0 or 1, it means no retries. If not specified, default to 5.
- exp_base: float | None¶
Multiplier by which the delay increases after each attempt. If not specified, default to 2.0.
- http_status_codes: list[int] | None¶
List of HTTP status codes that should trigger a retry. If not specified, a default set of retryable codes (408, 429, and 5xx) may be used.
- initial_delay: float | None¶
Initial delay before the first retry, in fractions of a second. If not specified, default to 1.0 second.
- jitter: float | None¶
Randomness factor for the delay. If not specified, default to 1.0.
- max_delay: float | None¶
Maximum delay between retries, in fractions of a second. If not specified, default to 60.0 seconds.
- class genai.types.Image(**data)¶
Bases:
BaseModelAn image.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- classmethod from_file(*, location, mime_type=None)¶
Lazy-loads an image from a local file or Google Cloud Storage.
- Return type:
- Parameters:
location – The local path or Google Cloud Storage URI from which to load the image.
mime_type – The MIME type of the image. If not provided, the MIME type will be automatically determined.
- Returns:
A loaded image as an Image object.
- gcs_uri: str | None¶
- image_bytes: bytes | None¶
- mime_type: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(context, /)¶
This function is meant to behave like a BaseModel method to initialize private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Return type:
None- Parameters:
self – The BaseModel instance.
context – The context.
- save(location)¶
Saves the image to a file.
- Return type:
None- Parameters:
location – Local path where to save the image.
- show()¶
Shows the image.
This method only works in a notebook environment.
- Return type:
None
- class genai.types.ImageConfig(**data)¶
Bases:
BaseModelThe image generation configuration to be used in GenerateContentConfig.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- aspect_ratio: str | None¶
- image_output_options: ImageConfigImageOutputOptions | None¶
- image_size: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- output_compression_quality: int | None¶
- output_mime_type: str | None¶
- person_generation: str | None¶
- prominent_people: ProminentPeople | None¶
- class genai.types.ImageConfigDict¶
Bases:
TypedDictThe image generation configuration to be used in GenerateContentConfig.
- aspect_ratio: str | None¶
Aspect ratio of the generated images. Supported values are “1:1”, “2:3”, “3:2”, “3:4”, “4:3”, “9:16”, “16:9”, and “21:9”.
- image_output_options: ImageConfigImageOutputOptionsDict | None¶
Optional. The image output format for generated images. This field is not supported in Gemini API.
- image_size: str | None¶
Optional. Specifies the size of generated images. Supported values are 1K, 2K, 4K. If not specified, the model will use default value 1K.
- output_compression_quality: int | None¶
Compression quality of the generated image (for
image/jpegonly). This field is not supported in Gemini API.
- output_mime_type: str | None¶
MIME type of the generated image. This field is not supported in Gemini API.
- person_generation: str | None¶
Controls the generation of people. Supported values are: ALLOW_ALL, ALLOW_ADULT, ALLOW_NONE.
- prominent_people: ProminentPeople | None¶
Optional. Controls whether prominent people (celebrities) generation is allowed. If used with personGeneration, personGeneration enum would take precedence. For instance, if ALLOW_NONE is set, all person generation would be blocked. If this field is unspecified, the default behavior is to allow prominent people. This field is not supported in Gemini API.
- class genai.types.ImageConfigImageOutputOptions(**data)¶
Bases:
BaseModelThe image output format for generated images.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- compression_quality: int | None¶
- mime_type: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ImageConfigImageOutputOptionsDict¶
Bases:
TypedDictThe image output format for generated images.
This data type is not supported in Gemini API.
- compression_quality: int | None¶
Optional. The compression quality of the output image.
- mime_type: str | None¶
Optional. The image format that the output should be saved as.
- class genai.types.ImageDict¶
Bases:
TypedDictAn image.
- gcs_uri: str | None¶
The Cloud Storage URI of the image.
Imagecan contain a value for this field or theimage_bytesfield but not both.
- image_bytes: bytes | None¶
The image bytes data.
Imagecan contain a value for this field or thegcs_urifield but not both.
- mime_type: str | None¶
The MIME type of the image.
- class genai.types.ImagePromptLanguage(*values)¶
Bases:
CaseInSensitiveEnumEnum that specifies the language of the text in the prompt.
- auto = 'auto'¶
Auto-detect the language.
- en = 'en'¶
English
- es = 'es'¶
Spanish
- hi = 'hi'¶
Hindi
- ja = 'ja'¶
Japanese
- ko = 'ko'¶
Korean
- pt = 'pt'¶
Portuguese
- zh = 'zh'¶
Chinese
- class genai.types.ImageResizeMode(*values)¶
Bases:
CaseInSensitiveEnumResize mode for the image input for video generation.
- CROP = 'CROP'¶
Crop the image to fit the correct aspect ratio (so we lose parts of the image in the process).
- PAD = 'PAD'¶
Pad the image to fit the correct aspect ratio (so we don’t lose any parts of the image in the process).
- class genai.types.ImageResponseFormat(**data)¶
Bases:
BaseModelConfiguration for image-specific output formatting.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- aspect_ratio: AspectRatio | None¶
- mime_type: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ImageResponseFormatDict¶
Bases:
TypedDictConfiguration for image-specific output formatting.
- aspect_ratio: AspectRatio | None¶
Optional. The aspect ratio for the image output.
- mime_type: str | None¶
Optional. The MIME type of the image output.
- class genai.types.ImageSearch(**data)¶
Bases:
BaseModelImage search for grounding and related configurations.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ImageSearchDict¶
Bases:
TypedDictImage search for grounding and related configurations.
- class genai.types.ImageSize(*values)¶
Bases:
CaseInSensitiveEnumThe size of the image output.
- IMAGE_SIZE_FIVE_TWELVE = 'IMAGE_SIZE_FIVE_TWELVE'¶
512px image size.
- IMAGE_SIZE_FOUR_K = 'IMAGE_SIZE_FOUR_K'¶
4K image size.
- IMAGE_SIZE_ONE_K = 'IMAGE_SIZE_ONE_K'¶
1K image size.
- IMAGE_SIZE_TWO_K = 'IMAGE_SIZE_TWO_K'¶
2K image size.
- IMAGE_SIZE_UNSPECIFIED = 'IMAGE_SIZE_UNSPECIFIED'¶
Default value. This value is unused.
- class genai.types.ImportFileConfig(**data)¶
Bases:
BaseModelOptional parameters for importing a file.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- chunking_config: ChunkingConfig | None¶
- custom_metadata: list[CustomMetadata] | None¶
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ImportFileConfigDict¶
Bases:
TypedDictOptional parameters for importing a file.
- chunking_config: ChunkingConfigDict | None¶
Config for telling the service how to chunk the file.
- custom_metadata: list[CustomMetadataDict] | None¶
User provided custom metadata stored as key-value pairs used for querying.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.ImportFileOperation(**data)¶
Bases:
BaseModel,OperationLong-running operation for importing a file to a FileSearchStore.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- classmethod from_api_response(api_response, is_vertex_ai=False)¶
Instantiates a ImportFileOperation from an API response.
- Return type:
Self
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- response: ImportFileResponse | None¶
- class genai.types.ImportFileResponse(**data)¶
Bases:
BaseModelResponse for ImportFile to import a File API file with a file search store.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- document_name: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- parent: str | None¶
- sdk_http_response: HttpResponse | None¶
- class genai.types.ImportFileResponseDict¶
Bases:
TypedDictResponse for ImportFile to import a File API file with a file search store.
- document_name: str | None¶
The identifier for the Document imported.
- parent: str | None¶
The name of the FileSearchStore containing Documents.
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.InlinedEmbedContentResponse(**data)¶
Bases:
BaseModelConfig for inlined_embedding_responses parameter.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- metadata: dict[str, Any] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- response: SingleEmbedContentResponse | None¶
- class genai.types.InlinedEmbedContentResponseDict¶
Bases:
TypedDictConfig for inlined_embedding_responses parameter.
- error: JobErrorDict | None¶
Output only. The error encountered while processing the request.
- metadata: dict[str, Any] | None¶
Output only. The metadata associated with the request.
- response: SingleEmbedContentResponseDict | None¶
Output only. The response to the request.
- class genai.types.InlinedRequest(**data)¶
Bases:
BaseModelConfig for inlined request.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- config: GenerateContentConfig | None¶
- contents: Content | str | Image | File | Part | list[str | Image | File | Part] | list[Content | str | Image | File | Part | list[str | Image | File | Part]] | None¶
- metadata: dict[str, str] | None¶
- model: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.InlinedRequestDict¶
Bases:
TypedDictConfig for inlined request.
- config: GenerateContentConfigDict | None¶
Configuration that contains optional model parameters.
- contents: Content | ContentDict | str | Image | File | FileDict | Part | PartDict | list[str | Image | File | FileDict | Part | PartDict] | list[Content | ContentDict | str | Image | File | FileDict | Part | PartDict | list[str | Image | File | FileDict | Part | PartDict]] | None¶
Content of the request.
- metadata: dict[str, str] | None¶
The metadata to be associated with the request.
- model: str | None¶
ID of the model to use. For a list of models, see Google models.
- class genai.types.InlinedResponse(**data)¶
Bases:
BaseModelConfig for inlined_responses parameter.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- metadata: dict[str, str] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- response: GenerateContentResponse | None¶
- class genai.types.InlinedResponseDict¶
Bases:
TypedDictConfig for inlined_responses parameter.
- error: JobErrorDict | None¶
The error encountered while processing the request.
- metadata: dict[str, str] | None¶
The metadata to be associated with the request.
- response: GenerateContentResponseDict | None¶
The response to the request.
- class genai.types.InteractionStatus(*values)¶
Bases:
CaseInSensitiveEnumThe different activity states of the live session.
- IDLE = 'IDLE'¶
The server has completed all processing and background reasoning.
- INTERACTION_STATUS_UNSPECIFIED = 'INTERACTION_STATUS_UNSPECIFIED'¶
Unspecified interaction status.
- IN_PROGRESS = 'IN_PROGRESS'¶
The server is still actively processing user input or running background reasoning. More model output may follow.
- REQUIRES_ACTION = 'REQUIRES_ACTION'¶
Use IDLE instead.
- Type:
Deprecated
- class genai.types.Interval(**data)¶
Bases:
BaseModelRepresents a time interval, encoded as a Timestamp start (inclusive) and a Timestamp end (exclusive).
The start must be less than or equal to the end. When the start equals the end, the interval is empty (matches no time). When both start and end are unspecified, the interval matches any time.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- end_time: datetime | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- start_time: datetime | None¶
- class genai.types.IntervalDict¶
Bases:
TypedDictRepresents a time interval, encoded as a Timestamp start (inclusive) and a Timestamp end (exclusive).
The start must be less than or equal to the end. When the start equals the end, the interval is empty (matches no time). When both start and end are unspecified, the interval matches any time.
- end_time: datetime | None¶
Optional. Exclusive end of the interval. If specified, a Timestamp matching this interval will have to be before the end.
- start_time: datetime | None¶
Optional. Inclusive start of the interval. If specified, a Timestamp matching this interval will have to be the same or after the start.
- class genai.types.JSONSchema(**data)¶
Bases:
BaseModelA subset of JSON Schema according to 2020-12 JSON Schema draft.
Represents a subset of a JSON Schema object that is used by the Gemini model. The difference between this class and the Schema class is that this class is compatible with OpenAPI 3.1 schema objects. And the Schema class is used to make API call to Gemini model.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- additional_properties: Any | None¶
- any_of: list[JSONSchema] | None¶
- default: Any | None¶
- defs: dict[str, JSONSchema] | None¶
- description: str | None¶
- enum: list[Any] | None¶
- format: str | None¶
- items: JSONSchema | None¶
- max_items: int | None¶
- max_length: int | None¶
- max_properties: int | None¶
- maximum: float | None¶
- min_items: int | None¶
- min_length: int | None¶
- min_properties: int | None¶
- minimum: float | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- one_of: list[JSONSchema] | None¶
- pattern: str | None¶
- properties: dict[str, JSONSchema] | None¶
- ref: str | None¶
- required: list[str] | None¶
- title: str | None¶
- type: JSONSchemaType | list[JSONSchemaType] | None¶
- unique_items: bool | None¶
- class genai.types.JSONSchemaType(*values)¶
Bases:
EnumThe type of the data supported by JSON Schema.
The values of the enums are lower case strings, while the values of the enums for the Type class are upper case strings.
- ARRAY = 'array'¶
- BOOLEAN = 'boolean'¶
- INTEGER = 'integer'¶
- NULL = 'null'¶
- NUMBER = 'number'¶
- OBJECT = 'object'¶
- STRING = 'string'¶
- class genai.types.JobError(**data)¶
Bases:
BaseModelJob error.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- code: int | None¶
- details: list[str] | None¶
- message: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.JobErrorDict¶
Bases:
TypedDictJob error.
- code: int | None¶
The status code.
- details: list[str] | None¶
A list of messages that carry the error details. There is a common set of message types for APIs to use.
- message: str | None¶
A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the details field.
- class genai.types.JobState(*values)¶
Bases:
CaseInSensitiveEnumJob state.
- JOB_STATE_CANCELLED = 'JOB_STATE_CANCELLED'¶
The job has been cancelled.
- JOB_STATE_CANCELLING = 'JOB_STATE_CANCELLING'¶
The job is being cancelled. From this state the job may only go to either JOB_STATE_SUCCEEDED, JOB_STATE_FAILED or JOB_STATE_CANCELLED.
- JOB_STATE_EXPIRED = 'JOB_STATE_EXPIRED'¶
The job has expired.
- JOB_STATE_FAILED = 'JOB_STATE_FAILED'¶
The job failed.
- JOB_STATE_PARTIALLY_SUCCEEDED = 'JOB_STATE_PARTIALLY_SUCCEEDED'¶
The job is partially succeeded, some results may be missing due to errors.
- JOB_STATE_PAUSED = 'JOB_STATE_PAUSED'¶
The job has been stopped, and can be resumed.
- JOB_STATE_PENDING = 'JOB_STATE_PENDING'¶
The service is preparing to run the job.
- JOB_STATE_QUEUED = 'JOB_STATE_QUEUED'¶
The job has been just created or resumed and processing has not yet begun.
- JOB_STATE_RUNNING = 'JOB_STATE_RUNNING'¶
The job is in progress.
- JOB_STATE_SUCCEEDED = 'JOB_STATE_SUCCEEDED'¶
The job completed successfully.
- JOB_STATE_UNSPECIFIED = 'JOB_STATE_UNSPECIFIED'¶
The job state is unspecified.
- JOB_STATE_UPDATING = 'JOB_STATE_UPDATING'¶
The job is being updated. Only jobs in the JOB_STATE_RUNNING state can be updated. After updating, the job goes back to the JOB_STATE_RUNNING state.
- class genai.types.LLMBasedMetricSpec(**data)¶
Bases:
BaseModelSpecification for an LLM based metric.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- additional_config: dict[str, Any] | None¶
- judge_autorater_config: AutoraterConfig | None¶
- metric_prompt_template: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- predefined_rubric_generation_spec: PredefinedMetricSpec | None¶
- result_parser_config: EvaluationParserConfig | None¶
- rubric_generation_spec: RubricGenerationSpec | None¶
- rubric_group_key: str | None¶
- system_instruction: str | None¶
- class genai.types.LLMBasedMetricSpecDict¶
Bases:
TypedDictSpecification for an LLM based metric.
- additional_config: dict[str, Any] | None¶
Optional. Optional additional configuration for the metric.
- judge_autorater_config: AutoraterConfigDict | None¶
Optional configuration for the judge LLM (Autorater).
- metric_prompt_template: str | None¶
Template for the prompt sent to the judge model.
- predefined_rubric_generation_spec: PredefinedMetricSpecDict | None¶
Dynamically generate rubrics using a predefined spec.
- result_parser_config: EvaluationParserConfigDict | None¶
Optional. The parser config for the metric result.
- rubric_generation_spec: RubricGenerationSpecDict | None¶
Dynamically generate rubrics using this specification.
- rubric_group_key: str | None¶
Use a pre-defined group of rubrics associated with the input. Refers to a key in the rubric_groups map of EvaluationInstance.
- system_instruction: str | None¶
System instruction for the judge model.
- class genai.types.Language(*values)¶
Bases:
CaseInSensitiveEnumProgramming language of the code.
- LANGUAGE_UNSPECIFIED = 'LANGUAGE_UNSPECIFIED'¶
Unspecified language. This value should not be used.
- PYTHON = 'PYTHON'¶
Python >= 3.10, with numpy and simpy available.
- class genai.types.LanguageAuto(**data)¶
Bases:
BaseModelDeprecated: Language auto-detection is now the default when language_codes is omitted.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.LanguageAutoDict¶
Bases:
TypedDictDeprecated: Language auto-detection is now the default when language_codes is omitted.
- class genai.types.LanguageHints(**data)¶
Bases:
BaseModelDeprecated: Use AudioTranscriptionConfig.language_codes instead.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- language_codes: list[str] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.LanguageHintsDict¶
Bases:
TypedDictDeprecated: Use AudioTranscriptionConfig.language_codes instead.
- language_codes: list[str] | None¶
Deprecated. BCP-47 language codes.
- class genai.types.LatLng(**data)¶
Bases:
BaseModelAn object that represents a latitude/longitude pair.
This is expressed as a pair of doubles to represent degrees latitude and degrees longitude. Unless specified otherwise, this object must conform to the WGS84 standard. Values must be within normalized ranges.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- latitude: float | None¶
- longitude: float | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.LatLngDict¶
Bases:
TypedDictAn object that represents a latitude/longitude pair.
This is expressed as a pair of doubles to represent degrees latitude and degrees longitude. Unless specified otherwise, this object must conform to the WGS84 standard. Values must be within normalized ranges.
- latitude: float | None¶
The latitude in degrees. It must be in the range [-90.0, +90.0].
- longitude: float | None¶
The longitude in degrees. It must be in the range [-180.0, +180.0].
- class genai.types.ListBatchJobsConfig(**data)¶
Bases:
BaseModelConfig for optional parameters.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- filter: str | None¶
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- page_size: int | None¶
- page_token: str | None¶
- class genai.types.ListBatchJobsConfigDict¶
Bases:
TypedDictConfig for optional parameters.
- filter: str | None¶
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- page_size: int | None¶
- page_token: str | None¶
- class genai.types.ListBatchJobsResponse(**data)¶
Bases:
BaseModelConfig for batches.list return value.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- next_page_token: str | None¶
- sdk_http_response: HttpResponse | None¶
- class genai.types.ListBatchJobsResponseDict¶
Bases:
TypedDictConfig for batches.list return value.
- batch_jobs: list[BatchJobDict] | None¶
- next_page_token: str | None¶
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.ListCachedContentsConfig(**data)¶
Bases:
BaseModelConfig for caches.list method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- page_size: int | None¶
- page_token: str | None¶
- class genai.types.ListCachedContentsConfigDict¶
Bases:
TypedDictConfig for caches.list method.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- page_size: int | None¶
- page_token: str | None¶
- class genai.types.ListCachedContentsResponse(**data)¶
Bases:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- cached_contents: list[CachedContent] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- next_page_token: str | None¶
- sdk_http_response: HttpResponse | None¶
- class genai.types.ListCachedContentsResponseDict¶
Bases:
TypedDict- cached_contents: list[CachedContentDict] | None¶
List of cached contents.
- next_page_token: str | None¶
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.ListDocumentsConfig(**data)¶
Bases:
BaseModelConfig for optional parameters.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- page_size: int | None¶
- page_token: str | None¶
- class genai.types.ListDocumentsConfigDict¶
Bases:
TypedDictConfig for optional parameters.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- page_size: int | None¶
- page_token: str | None¶
- class genai.types.ListDocumentsResponse(**data)¶
Bases:
BaseModelConfig for documents.list return value.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- next_page_token: str | None¶
- sdk_http_response: HttpResponse | None¶
- class genai.types.ListDocumentsResponseDict¶
Bases:
TypedDictConfig for documents.list return value.
- documents: list[DocumentDict] | None¶
The returned `Document`s.
- next_page_token: str | None¶
A token, which can be sent as page_token to retrieve the next page. If this field is omitted, there are no more pages.
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.ListFileSearchStoresConfig(**data)¶
Bases:
BaseModelOptional parameters for listing FileSearchStore.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- page_size: int | None¶
- page_token: str | None¶
- class genai.types.ListFileSearchStoresConfigDict¶
Bases:
TypedDictOptional parameters for listing FileSearchStore.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- page_size: int | None¶
- page_token: str | None¶
- class genai.types.ListFileSearchStoresResponse(**data)¶
Bases:
BaseModelConfig for file_search_stores.list return value.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- file_search_stores: list[FileSearchStore] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- next_page_token: str | None¶
- sdk_http_response: HttpResponse | None¶
- class genai.types.ListFileSearchStoresResponseDict¶
Bases:
TypedDictConfig for file_search_stores.list return value.
- file_search_stores: list[FileSearchStoreDict] | None¶
The returned file search stores.
- next_page_token: str | None¶
A token, which can be sent as page_token to retrieve the next page. If this field is omitted, there are no more pages.
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.ListFilesConfig(**data)¶
Bases:
BaseModelUsed to override the default configuration.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- page_size: int | None¶
- page_token: str | None¶
- class genai.types.ListFilesConfigDict¶
Bases:
TypedDictUsed to override the default configuration.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- page_size: int | None¶
- page_token: str | None¶
- class genai.types.ListFilesResponse(**data)¶
Bases:
BaseModelResponse for the list files method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- next_page_token: str | None¶
- sdk_http_response: HttpResponse | None¶
- class genai.types.ListFilesResponseDict¶
Bases:
TypedDictResponse for the list files method.
- next_page_token: str | None¶
A token that can be sent as a page_token into a subsequent ListFiles call.
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.ListModelsConfig(**data)¶
Bases:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- filter: str | None¶
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- page_size: int | None¶
- page_token: str | None¶
- query_base: bool | None¶
- class genai.types.ListModelsConfigDict¶
Bases:
TypedDict- filter: str | None¶
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- page_size: int | None¶
- page_token: str | None¶
- query_base: bool | None¶
Set true to list base models, false to list tuned models.
- class genai.types.ListModelsResponse(**data)¶
Bases:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- next_page_token: str | None¶
- sdk_http_response: HttpResponse | None¶
- class genai.types.ListModelsResponseDict¶
Bases:
TypedDict- next_page_token: str | None¶
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.ListTuningJobsConfig(**data)¶
Bases:
BaseModelConfiguration for the list tuning jobs method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- filter: str | None¶
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- page_size: int | None¶
- page_token: str | None¶
- class genai.types.ListTuningJobsConfigDict¶
Bases:
TypedDictConfiguration for the list tuning jobs method.
- filter: str | None¶
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- page_size: int | None¶
- page_token: str | None¶
- class genai.types.ListTuningJobsResponse(**data)¶
Bases:
BaseModelResponse for the list tuning jobs method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- next_page_token: str | None¶
- sdk_http_response: HttpResponse | None¶
- class genai.types.ListTuningJobsResponseDict¶
Bases:
TypedDictResponse for the list tuning jobs method.
- next_page_token: str | None¶
A token to retrieve the next page of results. Pass this token in a subsequent [GenAiTuningService.ListTuningJobs] call to retrieve the next page of results.
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- tuning_jobs: list[TuningJobDict] | None¶
The tuning jobs that match the request.
- class genai.types.LiveClientContent(**data)¶
Bases:
BaseModelIncremental update of the current conversation delivered from the client.
All the content here will unconditionally be appended to the conversation history and used as part of the prompt to the model to generate content.
A message here will interrupt any current model generation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- turn_complete: bool | None¶
- class genai.types.LiveClientContentDict¶
Bases:
TypedDictIncremental update of the current conversation delivered from the client.
All the content here will unconditionally be appended to the conversation history and used as part of the prompt to the model to generate content.
A message here will interrupt any current model generation.
- turn_complete: bool | None¶
If true, indicates that the server content generation should start with the currently accumulated prompt. Otherwise, the server will await additional messages before starting generation.
- turns: list[ContentDict] | None¶
The content appended to the current conversation with the model.
For single-turn queries, this is a single instance. For multi-turn queries, this is a repeated field that contains conversation history and latest request.
- class genai.types.LiveClientMessage(**data)¶
Bases:
BaseModelMessages sent by the client in the API call.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- client_content: LiveClientContent | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- realtime_input: LiveClientRealtimeInput | None¶
- setup: LiveClientSetup | None¶
- tool_response: LiveClientToolResponse | None¶
- class genai.types.LiveClientMessageDict¶
Bases:
TypedDictMessages sent by the client in the API call.
- client_content: LiveClientContentDict | None¶
Incremental update of the current conversation delivered from the client.
- realtime_input: LiveClientRealtimeInputDict | None¶
User input that is sent in real time.
- setup: LiveClientSetupDict | None¶
Message to be sent by the system when connecting to the API. SDK users should not send this message.
- tool_response: LiveClientToolResponseDict | None¶
Response to a ToolCallMessage received from the server.
- class genai.types.LiveClientRealtimeInput(**data)¶
Bases:
BaseModelUser input that is sent in real time.
This is different from LiveClientContent in a few ways:
Can be sent continuously without interruption to model generation.
If there is a need to mix data interleaved across the LiveClientContent and the LiveClientRealtimeInput, server attempts to optimize for best response, but there are no guarantees.
End of turn is not explicitly specified, but is rather derived from user activity (for example, end of speech).
Even before the end of turn, the data is processed incrementally to optimize for a fast start of the response from the model.
Is always assumed to be the user’s input (cannot be used to populate conversation history).
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- activity_end: ActivityEnd | None¶
- activity_start: ActivityStart | None¶
- audio_stream_end: bool | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- text: str | None¶
- class genai.types.LiveClientRealtimeInputDict¶
Bases:
TypedDictUser input that is sent in real time.
This is different from LiveClientContent in a few ways:
Can be sent continuously without interruption to model generation.
If there is a need to mix data interleaved across the LiveClientContent and the LiveClientRealtimeInput, server attempts to optimize for best response, but there are no guarantees.
End of turn is not explicitly specified, but is rather derived from user activity (for example, end of speech).
Even before the end of turn, the data is processed incrementally to optimize for a fast start of the response from the model.
Is always assumed to be the user’s input (cannot be used to populate conversation history).
- activity_end: ActivityEndDict | None¶
Marks the end of user activity.
- activity_start: ActivityStartDict | None¶
Marks the start of user activity.
- audio_stream_end: bool | None¶
Indicates that the audio stream has ended, e.g. because the microphone was turned off.
This should only be sent when automatic activity detection is enabled (which is the default).
The client can reopen the stream by sending an audio message.
- text: str | None¶
The realtime text input stream.
- class genai.types.LiveClientSetup(**data)¶
Bases:
BaseModelMessage contains configuration that will apply for the duration of the streaming session.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- avatar_config: AvatarConfig | None¶
- context_window_compression: ContextWindowCompressionConfig | None¶
- explicit_vad_signal: bool | None¶
- generation_config: GenerationConfig | None¶
- history_config: HistoryConfig | None¶
- input_audio_transcription: AudioTranscriptionConfig | None¶
- labels: dict[str, str] | None¶
- model: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- output_audio_transcription: AudioTranscriptionConfig | None¶
- proactivity: ProactivityConfig | None¶
- safety_settings: list[SafetySetting] | None¶
- session_resumption: SessionResumptionConfig | None¶
- tools: Annotated[list, WrapValidator(func=_validate_tool_list, json_schema_input_type=PydanticUndefined)] | None¶
- class genai.types.LiveClientSetupDict¶
Bases:
TypedDictMessage contains configuration that will apply for the duration of the streaming session.
- avatar_config: AvatarConfigDict | None¶
Configures the avatar model behavior.
- context_window_compression: ContextWindowCompressionConfigDict | None¶
Configures context window compression mechanism.
If included, server will compress context window to fit into given length.
- explicit_vad_signal: bool | None¶
Configures the explicit VAD signal. If enabled, the client will send vad_signal to indicate the start and end of speech. This allows the server to process the audio more efficiently.
- generation_config: GenerationConfigDict | None¶
The generation configuration for the session. Note: only a subset of fields are supported.
- history_config: HistoryConfigDict | None¶
Configures the exchange of history between the client and the server.
- input_audio_transcription: AudioTranscriptionConfigDict | None¶
The transcription of the input aligns with the input audio language.
- labels: dict[str, str] | None¶
Safety identifiers from aggregators: Use the key safety_identifier (e.g. {“safety_identifier”: “user_session_123”})
- Type:
Optional. Labels with user-defined metadata for the request. Optional. Labels must follow standard unified Cloud label requirements
- Type:
Label keys must start with a letter. - Label keys and values can be no longer than 63 characters (Unicode codepoints) and can only contain lowercase letters, numeric characters, underscores, and dashes. - International characters are allowed. Usage
- model: str | None¶
The fully qualified name of the publisher model or tuned model endpoint to use.
- output_audio_transcription: AudioTranscriptionConfigDict | None¶
The transcription of the output aligns with the language code specified for the output audio.
- proactivity: ProactivityConfigDict | None¶
Configures the proactivity of the model. This allows the model to respond proactively to the input and to ignore irrelevant input.
- safety_settings: list[SafetySettingDict] | None¶
Safety settings in the request to block unsafe content in the response.
- session_resumption: SessionResumptionConfigDict | None¶
Configures session resumption mechanism.
If included server will send SessionResumptionUpdate messages.
- system_instruction: Content | ContentDict | str | Image | File | FileDict | Part | PartDict | list[str | Image | File | FileDict | Part | PartDict] | None¶
The user provided system instructions for the model. Note: only text should be used in parts and content in each part will be in a separate paragraph.
- class genai.types.LiveClientToolResponse(**data)¶
Bases:
BaseModelClient generated response to a ToolCall received from the server.
Individual FunctionResponse objects are matched to the respective FunctionCall objects by the id field.
Note that in the unary and server-streaming GenerateContent APIs function calling happens by exchanging the Content parts, while in the bidi GenerateContent APIs function calling happens over this dedicated set of messages.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- function_responses: list[FunctionResponse] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.LiveClientToolResponseDict¶
Bases:
TypedDictClient generated response to a ToolCall received from the server.
Individual FunctionResponse objects are matched to the respective FunctionCall objects by the id field.
Note that in the unary and server-streaming GenerateContent APIs function calling happens by exchanging the Content parts, while in the bidi GenerateContent APIs function calling happens over this dedicated set of messages.
- function_responses: list[FunctionResponseDict] | None¶
The response to the function calls.
- class genai.types.LiveConnectConfig(**data)¶
Bases:
BaseModelSession config for the API connection.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- avatar_config: AvatarConfig | None¶
- context_window_compression: ContextWindowCompressionConfig | None¶
- enable_affective_dialog: bool | None¶
- explicit_vad_signal: bool | None¶
- generation_config: GenerationConfig | None¶
- history_config: HistoryConfig | None¶
- http_options: HttpOptions | None¶
- input_audio_transcription: AudioTranscriptionConfig | None¶
- max_output_tokens: int | None¶
- media_resolution: MediaResolution | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- output_audio_transcription: AudioTranscriptionConfig | None¶
- proactivity: ProactivityConfig | None¶
- realtime_input_config: RealtimeInputConfig | None¶
- safety_settings: list[SafetySetting] | None¶
- seed: int | None¶
- session_resumption: SessionResumptionConfig | None¶
- speech_config: SpeechConfig | None¶
- temperature: float | None¶
- thinking_config: ThinkingConfig | None¶
- tools: Annotated[list, WrapValidator(func=_validate_tool_list, json_schema_input_type=PydanticUndefined)] | None¶
- top_k: float | None¶
- top_p: float | None¶
- translation_config: TranslationConfig | None¶
- class genai.types.LiveConnectConfigDict¶
Bases:
TypedDictSession config for the API connection.
- avatar_config: AvatarConfigDict | None¶
Configures the avatar model behavior.
- context_window_compression: ContextWindowCompressionConfigDict | None¶
Configures context window compression mechanism.
If included, server will compress context window to fit into given length.
- enable_affective_dialog: bool | None¶
If enabled, the model will detect emotions and adapt its responses accordingly.
- explicit_vad_signal: bool | None¶
Configures the explicit VAD signal. If enabled, the client will send vad_signal to indicate the start and end of speech. This allows the server to process the audio more efficiently.
- generation_config: GenerationConfigDict | None¶
The generation configuration for the session.
- history_config: HistoryConfigDict | None¶
Configures the exchange of history between the client and the server.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- input_audio_transcription: AudioTranscriptionConfigDict | None¶
The transcription of the input aligns with the input audio language.
- max_output_tokens: int | None¶
Maximum number of tokens that can be generated in the response.
- media_resolution: MediaResolution | None¶
If specified, the media resolution specified will be used.
- output_audio_transcription: AudioTranscriptionConfigDict | None¶
The transcription of the output aligns with the language code specified for the output audio.
- proactivity: ProactivityConfigDict | None¶
Configures the proactivity of the model. This allows the model to respond proactively to the input and to ignore irrelevant input.
- realtime_input_config: RealtimeInputConfigDict | None¶
Configures the realtime input behavior in BidiGenerateContent.
- response_modalities: list[Modality] | None¶
The requested modalities of the response. Represents the set of modalities that the model can return. Defaults to AUDIO if not specified.
- safety_settings: list[SafetySettingDict] | None¶
Safety settings in the request to block unsafe content in the response.
- seed: int | None¶
When
seedis fixed to a specific number, the model makes a best effort to provide the same response for repeated requests. By default, a random number is used.
- session_resumption: SessionResumptionConfigDict | None¶
Configures session resumption mechanism.
If included the server will send SessionResumptionUpdate messages.
- speech_config: SpeechConfigDict | None¶
The speech generation configuration.
- system_instruction: Content | ContentDict | str | Image | File | FileDict | Part | PartDict | list[str | Image | File | FileDict | Part | PartDict] | None¶
The user provided system instructions for the model. Note: only text should be used in parts and content in each part will be in a separate paragraph.
- temperature: float | None¶
Value that controls the degree of randomness in token selection. Lower temperatures are good for prompts that require a less open-ended or creative response, while higher temperatures can lead to more diverse or creative results.
- thinking_config: ThinkingConfigDict | None¶
Config for thinking features. An error will be returned if this field is set for models that don’t support thinking.
- tools: list[ToolDict | Callable[[...], Any]] | None¶
A list of Tools the model may use to generate the next response.
A Tool is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model.
- top_k: float | None¶
For each token selection step, the
top_ktokens with the highest probabilities are sampled. Then tokens are further filtered based ontop_pwith the final token selected using temperature sampling. Use a lower number for less random responses and a higher number for more random responses.
- top_p: float | None¶
Tokens are selected from the most to least probable until the sum of their probabilities equals this value. Use a lower value for less random responses and a higher value for more random responses.
- translation_config: TranslationConfigDict | None¶
Config for translation.
- class genai.types.LiveConnectConstraints(**data)¶
Bases:
BaseModelConfig for LiveConnectConstraints for Auth Token creation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- config: LiveConnectConfig | None¶
- model: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.LiveConnectConstraintsDict¶
Bases:
TypedDictConfig for LiveConnectConstraints for Auth Token creation.
- config: LiveConnectConfigDict | None¶
Configuration specific to Live API connections created using this token.
- model: str | None¶
ID of the model to configure in the ephemeral token for Live API. For a list of models, see Gemini models <https://ai.google.dev/gemini-api/docs/models>.
- class genai.types.LiveConnectParameters(**data)¶
Bases:
BaseModelParameters for connecting to the live API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- config: LiveConnectConfig | None¶
- model: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.LiveConnectParametersDict¶
Bases:
TypedDictParameters for connecting to the live API.
- config: LiveConnectConfigDict | None¶
Optional configuration parameters for the request.
- model: str | None¶
ID of the model to use. For a list of models, see Google models.
- class genai.types.LiveMusicClientContent(**data)¶
Bases:
BaseModelUser input to start or steer the music.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- weighted_prompts: list[WeightedPrompt] | None¶
- class genai.types.LiveMusicClientContentDict¶
Bases:
TypedDictUser input to start or steer the music.
- weighted_prompts: list[WeightedPromptDict] | None¶
Weighted prompts as the model input.
- class genai.types.LiveMusicClientMessage(**data)¶
Bases:
BaseModelMessages sent by the client in the LiveMusicClientMessage call.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- client_content: LiveMusicClientContent | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- music_generation_config: LiveMusicGenerationConfig | None¶
- playback_control: LiveMusicPlaybackControl | None¶
- setup: LiveMusicClientSetup | None¶
- class genai.types.LiveMusicClientMessageDict¶
Bases:
TypedDictMessages sent by the client in the LiveMusicClientMessage call.
- client_content: LiveMusicClientContentDict | None¶
User input to influence music generation.
- music_generation_config: LiveMusicGenerationConfigDict | None¶
Configuration for music generation.
- playback_control: LiveMusicPlaybackControl | None¶
Playback control signal for the music generation.
- setup: LiveMusicClientSetupDict | None¶
Message to be sent in the first (and only in the first) LiveMusicClientMessage. Clients should wait for a LiveMusicSetupComplete message before sending any additional messages.
- class genai.types.LiveMusicClientSetup(**data)¶
Bases:
BaseModelMessage to be sent by the system when connecting to the API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.LiveMusicClientSetupDict¶
Bases:
TypedDictMessage to be sent by the system when connecting to the API.
- model: str | None¶
models/{model}.
- Type:
The model’s resource name. Format
- class genai.types.LiveMusicConnectParameters(**data)¶
Bases:
BaseModelParameters for connecting to the live API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.LiveMusicConnectParametersDict¶
Bases:
TypedDictParameters for connecting to the live API.
- model: str | None¶
The model’s resource name.
- class genai.types.LiveMusicFilteredPrompt(**data)¶
Bases:
BaseModelA prompt that was filtered with the reason.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- filtered_reason: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- text: str | None¶
- class genai.types.LiveMusicFilteredPromptDict¶
Bases:
TypedDictA prompt that was filtered with the reason.
- filtered_reason: str | None¶
The reason the prompt was filtered.
- text: str | None¶
The text prompt that was filtered.
- class genai.types.LiveMusicGenerationConfig(**data)¶
Bases:
BaseModelConfiguration for music generation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- bpm: int | None¶
- brightness: float | None¶
- density: float | None¶
- guidance: float | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- music_generation_mode: MusicGenerationMode | None¶
- mute_bass: bool | None¶
- mute_drums: bool | None¶
- only_bass_and_drums: bool | None¶
- seed: int | None¶
- temperature: float | None¶
- top_k: int | None¶
- class genai.types.LiveMusicGenerationConfigDict¶
Bases:
TypedDictConfiguration for music generation.
- bpm: int | None¶
Beats per minute. Range is [60, 200].
- brightness: float | None¶
Brightness of the music. Range is [0.0, 1.0].
- density: float | None¶
Density of sounds. Range is [0.0, 1.0].
- guidance: float | None¶
Controls how closely the model follows prompts. Higher guidance follows more closely, but will make transitions more abrupt. Range is [0.0, 6.0].
- music_generation_mode: MusicGenerationMode | None¶
The mode of music generation. Default mode is QUALITY.
- mute_bass: bool | None¶
Whether the audio output should contain bass.
- mute_drums: bool | None¶
Whether the audio output should contain drums.
- only_bass_and_drums: bool | None¶
Whether the audio output should contain only bass and drums.
- seed: int | None¶
Seeds audio generation. If not set, the request uses a randomly generated seed.
- temperature: float | None¶
Controls the variance in audio generation. Higher values produce higher variance. Range is [0.0, 3.0].
- top_k: int | None¶
Controls how the model selects tokens for output. Samples the topK tokens with the highest probabilities. Range is [1, 1000].
- class genai.types.LiveMusicPlaybackControl(*values)¶
Bases:
CaseInSensitiveEnumThe playback control signal to apply to the music generation.
- PAUSE = 'PAUSE'¶
Hold the music generation. Use PLAY to resume from the current position.
- PLAY = 'PLAY'¶
Start generating the music.
- PLAYBACK_CONTROL_UNSPECIFIED = 'PLAYBACK_CONTROL_UNSPECIFIED'¶
This value is unused.
- RESET_CONTEXT = 'RESET_CONTEXT'¶
Reset the context of the music generation without stopping it. Retains the current prompts and config.
- STOP = 'STOP'¶
Stop the music generation and reset the context (prompts retained). Use PLAY to restart the music generation.
- class genai.types.LiveMusicServerContent(**data)¶
Bases:
BaseModelServer update generated by the model in response to client messages.
Content is generated as quickly as possible, and not in real time. Clients may choose to buffer and play it out in real time.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- audio_chunks: list[AudioChunk] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.LiveMusicServerContentDict¶
Bases:
TypedDictServer update generated by the model in response to client messages.
Content is generated as quickly as possible, and not in real time. Clients may choose to buffer and play it out in real time.
- audio_chunks: list[AudioChunkDict] | None¶
The audio chunks that the model has generated.
- class genai.types.LiveMusicServerMessage(**data)¶
Bases:
BaseModelResponse message for the LiveMusicClientMessage call.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- filtered_prompt: LiveMusicFilteredPrompt | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- server_content: LiveMusicServerContent | None¶
- setup_complete: LiveMusicServerSetupComplete | None¶
- class genai.types.LiveMusicServerMessageDict¶
Bases:
TypedDictResponse message for the LiveMusicClientMessage call.
- filtered_prompt: LiveMusicFilteredPromptDict | None¶
A prompt that was filtered with the reason.
- server_content: LiveMusicServerContentDict | None¶
Content generated by the model in response to client messages.
- setup_complete: LiveMusicServerSetupCompleteDict | None¶
Message sent in response to a LiveMusicClientSetup message from the client. Clients should wait for this message before sending any additional messages.
- class genai.types.LiveMusicServerSetupComplete(**data)¶
Bases:
BaseModelSent in response to a LiveMusicClientSetup message from the client.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.LiveMusicServerSetupCompleteDict¶
Bases:
TypedDictSent in response to a LiveMusicClientSetup message from the client.
- class genai.types.LiveMusicSetConfigParameters(**data)¶
Bases:
BaseModelParameters for setting config for the live music API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- music_generation_config: LiveMusicGenerationConfig | None¶
- class genai.types.LiveMusicSetConfigParametersDict¶
Bases:
TypedDictParameters for setting config for the live music API.
- music_generation_config: LiveMusicGenerationConfigDict | None¶
Configuration for music generation.
- class genai.types.LiveMusicSetWeightedPromptsParameters(**data)¶
Bases:
BaseModelParameters for setting weighted prompts for the live music API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- weighted_prompts: list[WeightedPrompt] | None¶
- class genai.types.LiveMusicSetWeightedPromptsParametersDict¶
Bases:
TypedDictParameters for setting weighted prompts for the live music API.
- weighted_prompts: list[WeightedPromptDict] | None¶
A map of text prompts to weights to use for the generation request.
- class genai.types.LiveMusicSourceMetadata(**data)¶
Bases:
BaseModelPrompts and config used for generating this audio chunk.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- client_content: LiveMusicClientContent | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- music_generation_config: LiveMusicGenerationConfig | None¶
- class genai.types.LiveMusicSourceMetadataDict¶
Bases:
TypedDictPrompts and config used for generating this audio chunk.
- client_content: LiveMusicClientContentDict | None¶
Weighted prompts for generating this audio chunk.
- music_generation_config: LiveMusicGenerationConfigDict | None¶
Music generation config for generating this audio chunk.
- class genai.types.LiveSendRealtimeInputParameters(**data)¶
Bases:
BaseModelParameters for sending realtime input to the live API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- activity_end: ActivityEnd | None¶
- activity_start: ActivityStart | None¶
- audio_stream_end: bool | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- text: str | None¶
- class genai.types.LiveSendRealtimeInputParametersDict¶
Bases:
TypedDictParameters for sending realtime input to the live API.
- activity_end: ActivityEndDict | None¶
Marks the end of user activity.
- activity_start: ActivityStartDict | None¶
Marks the start of user activity.
- audio_stream_end: bool | None¶
Indicates that the audio stream has ended, e.g. because the microphone was turned off.
This should only be sent when automatic activity detection is enabled (which is the default).
The client can reopen the stream by sending an audio message.
- text: str | None¶
The realtime text input stream.
- class genai.types.LiveServerContent(**data)¶
Bases:
BaseModelIncremental server update generated by the model in response to client messages.
Content is generated as quickly as possible, and not in real time. Clients may choose to buffer and play it out in real time.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- generation_complete: bool | None¶
- grounding_metadata: GroundingMetadata | None¶
- input_transcription: Transcription | None¶
- interaction_status: InteractionStatus | None¶
- interim_input_transcription: Transcription | None¶
- interrupted: bool | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- output_transcription: Transcription | None¶
- turn_complete: bool | None¶
- turn_complete_reason: TurnCompleteReason | None¶
- url_context_metadata: UrlContextMetadata | None¶
- waiting_for_input: bool | None¶
- class genai.types.LiveServerContentDict¶
Bases:
TypedDictIncremental server update generated by the model in response to client messages.
Content is generated as quickly as possible, and not in real time. Clients may choose to buffer and play it out in real time.
- generation_complete: bool | None¶
If true, indicates that the model is done generating. When model is interrupted while generating there will be no generation_complete message in interrupted turn, it will go through interrupted > turn_complete. When model assumes realtime playback there will be delay between generation_complete and turn_complete that is caused by model waiting for playback to finish. If true, indicates that the model has finished generating all content. This is a signal to the client that it can stop sending messages.
- grounding_metadata: GroundingMetadataDict | None¶
Metadata returned to client when grounding is enabled.
- input_transcription: TranscriptionDict | None¶
Input transcription. The transcription is independent to the model turn which means it doesn’t imply any ordering between transcription and model turn.
- interaction_status: InteractionStatus | None¶
The current activity status of the live session. Always sent alongside turn_complete.
- interim_input_transcription: TranscriptionDict | None¶
Low latency transcription updated while the user is speaking.
- interrupted: bool | None¶
If true, indicates that a client message has interrupted current model generation. If the client is playing out the content in realtime, this is a good signal to stop and empty the current queue.
- model_turn: ContentDict | None¶
The content that the model has generated as part of the current conversation with the user.
- output_transcription: TranscriptionDict | None¶
Output transcription. The transcription is independent to the model turn which means it doesn’t imply any ordering between transcription and model turn.
- turn_complete: bool | None¶
If true, indicates that the model is done generating. Generation will only start in response to additional client messages. Can be set alongside content, indicating that the content is the last in the turn.
- turn_complete_reason: TurnCompleteReason | None¶
Reason for the turn is complete.
- url_context_metadata: UrlContextMetadataDict | None¶
Metadata related to url context retrieval tool.
- waiting_for_input: bool | None¶
If true, indicates that the model is not generating content because it is waiting for more input from the user, e.g. because it expects the user to continue talking.
- class genai.types.LiveServerGoAway(**data)¶
Bases:
BaseModelServer will not be able to service client soon.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- time_left: str | None¶
- class genai.types.LiveServerGoAwayDict¶
Bases:
TypedDictServer will not be able to service client soon.
- time_left: str | None¶
The remaining time before the connection will be terminated as ABORTED. The minimal time returned here is specified differently together with the rate limits for a given model.
- class genai.types.LiveServerMessage(**data)¶
Bases:
BaseModelResponse message for API call.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- property data: bytes | None¶
Returns the concatenation of all inline data parts in the response.
If there are non-data parts in the response, only the concatenated data result from the data parts will be returned.
- go_away: LiveServerGoAway | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- server_content: LiveServerContent | None¶
- session_resumption_update: LiveServerSessionResumptionUpdate | None¶
- setup_complete: LiveServerSetupComplete | None¶
- property text: str | None¶
Returns the concatenation of all text parts in the response.
If there are non-text parts in the response, only the concatenated text result from text parts will be returned.
- tool_call: LiveServerToolCall | None¶
- tool_call_cancellation: LiveServerToolCallCancellation | None¶
- usage_metadata: UsageMetadata | None¶
- voice_activity: VoiceActivity | None¶
- voice_activity_detection_signal: VoiceActivityDetectionSignal | None¶
- class genai.types.LiveServerMessageDict¶
Bases:
TypedDictResponse message for API call.
- go_away: LiveServerGoAwayDict | None¶
Server will disconnect soon.
- server_content: LiveServerContentDict | None¶
Content generated by the model in response to client messages.
- session_resumption_update: LiveServerSessionResumptionUpdateDict | None¶
Update of the session resumption state.
- setup_complete: LiveServerSetupCompleteDict | None¶
Sent in response to a LiveClientSetup message from the client.
- tool_call: LiveServerToolCallDict | None¶
Request for the client to execute the function_calls and return the responses with the matching `id`s.
- tool_call_cancellation: LiveServerToolCallCancellationDict | None¶
Notification for the client that a previously issued ToolCallMessage with the specified `id`s should have been not executed and should be cancelled.
- usage_metadata: UsageMetadataDict | None¶
Usage metadata about model response(s).
- voice_activity: VoiceActivityDict | None¶
Voice activity signal.
- voice_activity_detection_signal: VoiceActivityDetectionSignalDict | None¶
Voice activity detection signal. Allowlisted only.
- class genai.types.LiveServerSessionResumptionUpdate(**data)¶
Bases:
BaseModelUpdate of the session resumption state.
Only sent if session_resumption was set in the connection config.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- last_consumed_client_message_index: int | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- new_handle: str | None¶
- resumable: bool | None¶
- class genai.types.LiveServerSessionResumptionUpdateDict¶
Bases:
TypedDictUpdate of the session resumption state.
Only sent if session_resumption was set in the connection config.
- last_consumed_client_message_index: int | None¶
Index of last message sent by client that is included in state represented by this SessionResumptionToken. Only sent when SessionResumptionConfig.transparent is set.
Presence of this index allows users to transparently reconnect and avoid issue of losing some part of realtime audio input/video. If client wishes to temporarily disconnect (for example as result of receiving GoAway) they can do it without losing state by buffering messages sent since last SessionResumptionTokenUpdate. This field will enable them to limit buffering (avoid keeping all requests in RAM).
Note: This should not be used for when resuming a session at some time later – in those cases partial audio and video frames are likely not needed.
- new_handle: str | None¶
New handle that represents state that can be resumed. Empty if `resumable`=false.
- resumable: bool | None¶
True if session can be resumed at this point. It might be not possible to resume session at some points. In that case we send update empty new_handle and resumable=false. Example of such case could be model executing function calls or just generating. Resuming session (using previous session token) in such state will result in some data loss.
- class genai.types.LiveServerSetupComplete(**data)¶
Bases:
BaseModelSent in response to a LiveGenerateContentSetup message from the client.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- session_id: str | None¶
- voice_consent_signature: VoiceConsentSignature | None¶
- class genai.types.LiveServerSetupCompleteDict¶
Bases:
TypedDictSent in response to a LiveGenerateContentSetup message from the client.
- session_id: str | None¶
The session id of the live session.
- voice_consent_signature: VoiceConsentSignatureDict | None¶
Signature of the verified consent audio. This is populated when the request has a ReplicatedVoiceConfig with consent_audio set, if the consent verification was successful. This may be used in a subsequent request instead of the consent_audio to verify the same consent.
- class genai.types.LiveServerToolCall(**data)¶
Bases:
BaseModelRequest for the client to execute the function_calls and return the responses with the matching `id`s.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- function_calls: list[FunctionCall] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.LiveServerToolCallCancellation(**data)¶
Bases:
BaseModelNotification for the client that a previously issued ToolCallMessage with the specified `id`s should have been not executed and should be cancelled.
If there were side-effects to those tool calls, clients may attempt to undo the tool calls. This message occurs only in cases where the clients interrupt server turns.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- ids: list[str] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.LiveServerToolCallCancellationDict¶
Bases:
TypedDictNotification for the client that a previously issued ToolCallMessage with the specified `id`s should have been not executed and should be cancelled.
If there were side-effects to those tool calls, clients may attempt to undo the tool calls. This message occurs only in cases where the clients interrupt server turns.
- ids: list[str] | None¶
The ids of the tool calls to be cancelled.
- class genai.types.LiveServerToolCallDict¶
Bases:
TypedDictRequest for the client to execute the function_calls and return the responses with the matching `id`s.
- function_calls: list[FunctionCallDict] | None¶
The function call to be executed.
- class genai.types.LogprobsResult(**data)¶
Bases:
BaseModelThe log probabilities of the tokens generated by the model.
This is useful for understanding the model’s confidence in its predictions and for debugging. For example, you can use log probabilities to identify when the model is making a less confident prediction or to explore alternative responses that the model considered. A low log probability can also indicate that the model is “hallucinating” or generating factually incorrect information.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- chosen_candidates: list[LogprobsResultCandidate] | None¶
- log_probability_sum: float | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- top_candidates: list[LogprobsResultTopCandidates] | None¶
- class genai.types.LogprobsResultCandidate(**data)¶
Bases:
BaseModelA single token and its associated log probability.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- log_probability: float | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- token: str | None¶
- token_id: int | None¶
- class genai.types.LogprobsResultCandidateDict¶
Bases:
TypedDictA single token and its associated log probability.
- log_probability: float | None¶
The log probability of this token. A higher value indicates that the model was more confident in this token. The log probability can be used to assess the relative likelihood of different tokens and to identify when the model is uncertain.
- token: str | None¶
The token’s string representation.
- token_id: int | None¶
The token’s numerical ID. While the token field provides the string representation of the token, the token_id is the numerical representation that the model uses internally. This can be useful for developers who want to build custom logic based on the model’s vocabulary.
- class genai.types.LogprobsResultDict¶
Bases:
TypedDictThe log probabilities of the tokens generated by the model.
This is useful for understanding the model’s confidence in its predictions and for debugging. For example, you can use log probabilities to identify when the model is making a less confident prediction or to explore alternative responses that the model considered. A low log probability can also indicate that the model is “hallucinating” or generating factually incorrect information.
- chosen_candidates: list[LogprobsResultCandidateDict] | None¶
A list of the chosen candidate tokens at each decoding step. The length of this list is equal to the total number of decoding steps. Note that the chosen candidate might not be in top_candidates.
- log_probability_sum: float | None¶
Sum of log probabilities for all tokens. This field is not supported in Vertex AI.
- top_candidates: list[LogprobsResultTopCandidatesDict] | None¶
A list of the top candidate tokens at each decoding step. The length of this list is equal to the total number of decoding steps.
- class genai.types.LogprobsResultTopCandidates(**data)¶
Bases:
BaseModelA list of the top candidate tokens and their log probabilities at each decoding step.
This can be used to see what other tokens the model considered.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- candidates: list[LogprobsResultCandidate] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.LogprobsResultTopCandidatesDict¶
Bases:
TypedDictA list of the top candidate tokens and their log probabilities at each decoding step.
This can be used to see what other tokens the model considered.
- candidates: list[LogprobsResultCandidateDict] | None¶
The list of candidate tokens, sorted by log probability in descending order.
- class genai.types.MaskReferenceConfig(**data)¶
Bases:
BaseModelConfiguration for a Mask reference image.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- mask_dilation: float | None¶
- mask_mode: MaskReferenceMode | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- segmentation_classes: list[int] | None¶
- class genai.types.MaskReferenceConfigDict¶
Bases:
TypedDictConfiguration for a Mask reference image.
- mask_dilation: float | None¶
Dilation percentage of the mask provided. Float between 0 and 1.
- mask_mode: MaskReferenceMode | None¶
Prompts the model to generate a mask instead of you needing to provide one (unless MASK_MODE_USER_PROVIDED is used).
- segmentation_classes: list[int] | None¶
A list of up to 5 class ids to use for semantic segmentation. Automatically creates an image mask based on specific objects.
- class genai.types.MaskReferenceImage(**data)¶
Bases:
BaseModelA mask reference image.
This encapsulates either a mask image provided by the user and configs for the user provided mask, or only config parameters for the model to generate a mask.
A mask image is an image whose non-zero values indicate where to edit the base image. If the user provides a mask image, the mask must be in the same dimensions as the raw image.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- config: MaskReferenceConfig | None¶
Re-map config to mask_reference_config to send to API.
- mask_image_config: MaskReferenceConfig | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- reference_id: int | None¶
- reference_type: str | None¶
- class genai.types.MaskReferenceImageDict¶
Bases:
TypedDictA mask reference image.
This encapsulates either a mask image provided by the user and configs for the user provided mask, or only config parameters for the model to generate a mask.
A mask image is an image whose non-zero values indicate where to edit the base image. If the user provides a mask image, the mask must be in the same dimensions as the raw image.
- config: MaskReferenceConfigDict | None¶
Configuration for the mask reference image.
- reference_id: int | None¶
The id of the reference image.
- reference_type: str | None¶
The type of the reference image. Only set by the SDK.
- class genai.types.MaskReferenceMode(*values)¶
Bases:
CaseInSensitiveEnumEnum representing the mask mode of a mask reference image.
- MASK_MODE_BACKGROUND = 'MASK_MODE_BACKGROUND'¶
- MASK_MODE_DEFAULT = 'MASK_MODE_DEFAULT'¶
- MASK_MODE_FOREGROUND = 'MASK_MODE_FOREGROUND'¶
- MASK_MODE_SEMANTIC = 'MASK_MODE_SEMANTIC'¶
- MASK_MODE_USER_PROVIDED = 'MASK_MODE_USER_PROVIDED'¶
- class genai.types.MatchOperation(*values)¶
Bases:
CaseInSensitiveEnumMatch operation to use for evaluating rewards.
This enum is not supported in Gemini API.
- EXACT_MATCH = 'EXACT_MATCH'¶
The match operation returns true expression is an exact match of the target.
- MATCH_OPERATION_UNSPECIFIED = 'MATCH_OPERATION_UNSPECIFIED'¶
Default value. A user error will be returned if not set.
- PARTIAL_MATCH = 'PARTIAL_MATCH'¶
The match operation returns true if expression is a substring of the target.
- REGEX_CONTAINS = 'REGEX_CONTAINS'¶
//cloud.google.com/bigquery/docs/reference/standard-sql/string_functions#regexp_contains) REGEX_CONTAINS(target, expression).
- Type:
Equivalent to [GoogleSQL](https
- class genai.types.McpServer(**data)¶
Bases:
BaseModelA MCPServer is a server that can be called by the model to perform actions.
It is a server that implements the MCP protocol. Next ID: 7. This data type is not supported in Vertex AI.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str | None¶
- streamable_http_transport: StreamableHttpTransport | None¶
- class genai.types.McpServerDict¶
Bases:
TypedDictA MCPServer is a server that can be called by the model to perform actions.
It is a server that implements the MCP protocol. Next ID: 7. This data type is not supported in Vertex AI.
- name: str | None¶
The name of the MCPServer.
- streamable_http_transport: StreamableHttpTransportDict | None¶
A transport that can stream HTTP requests and responses.
- class genai.types.MediaModality(*values)¶
Bases:
CaseInSensitiveEnumThe modality that this token count applies to.
- AUDIO = 'AUDIO'¶
The Part contains audio.
- DOCUMENT = 'DOCUMENT'¶
The Part contains a document, such as a PDF.
- IMAGE = 'IMAGE'¶
The Part contains an image.
- MODALITY_UNSPECIFIED = 'MODALITY_UNSPECIFIED'¶
When a modality is not specified, it is treated as TEXT.
- TEXT = 'TEXT'¶
The Part contains plain text.
- VIDEO = 'VIDEO'¶
The Part contains a video.
- class genai.types.MediaProcessing(*values)¶
Bases:
CaseInSensitiveEnumHow the model processes input media for understanding.
- AGENTIC = 'AGENTIC'¶
Model-driven dynamic navigation. Recommended for most use cases.
- MEDIA_PROCESSING_UNSPECIFIED = 'MEDIA_PROCESSING_UNSPECIFIED'¶
Default. Uses model-specific processing
- STATIC = 'STATIC'¶
Fixed-rate frame extraction. All frames placed in context.
- class genai.types.MediaResolution(*values)¶
Bases:
CaseInSensitiveEnumThe media resolution to use.
- MEDIA_RESOLUTION_HIGH = 'MEDIA_RESOLUTION_HIGH'¶
Media resolution set to high (zoomed reframing with 256 tokens).
- MEDIA_RESOLUTION_LOW = 'MEDIA_RESOLUTION_LOW'¶
Media resolution set to low (64 tokens).
- MEDIA_RESOLUTION_MEDIUM = 'MEDIA_RESOLUTION_MEDIUM'¶
Media resolution set to medium (256 tokens).
- MEDIA_RESOLUTION_UNSPECIFIED = 'MEDIA_RESOLUTION_UNSPECIFIED'¶
Media resolution has not been set
- class genai.types.Metric(**data)¶
Bases:
BaseModelThe metric used for evaluation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- aggregate_summary_fn: Callable[[...], Any] | None¶
- custom_function: Callable[[...], Any] | None¶
- judge_model_system_instruction: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'allow', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(context, /)¶
This function is meant to behave like a BaseModel method to initialize private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Return type:
None- Parameters:
self – The BaseModel instance.
context – The context.
- name: str | None¶
- parse_and_reduce_fn: Callable[[...], Any] | None¶
- prompt_template: str | None¶
- return_raw_output: bool | None¶
- to_yaml_file(file_path, version=None)¶
Dumps the metric object to a YAML file.
- Return type:
None- Parameters:
file_path – The path to the YAML file.
version – Optional version string to include in the YAML output.
- Raises:
ImportError – If the pyyaml library is not installed.
- class genai.types.MetricDict¶
Bases:
TypedDictThe metric used for evaluation.
- aggregate_summary_fn: Callable[[...], Any] | None¶
The aggregate summary function for the judge model.
- custom_function: Callable[[...], Any] | None¶
The custom function that defines the end-to-end logic for metric computation.
- judge_model_system_instruction: str | None¶
The system instruction for the judge model.
- name: str | None¶
The name of the metric.
- parse_and_reduce_fn: Callable[[...], Any] | None¶
The parse and reduce function for the judge model.
- prompt_template: str | None¶
The prompt template for the metric.
- return_raw_output: bool | None¶
Whether to return the raw output from the judge model.
- class genai.types.Modality(*values)¶
Bases:
CaseInSensitiveEnumServer content modalities.
- AUDIO = 'AUDIO'¶
Indicates the model should return audio.
- IMAGE = 'IMAGE'¶
Indicates the model should return images.
- MODALITY_UNSPECIFIED = 'MODALITY_UNSPECIFIED'¶
The modality is unspecified.
- TEXT = 'TEXT'¶
Indicates the model should return text
- VIDEO = 'VIDEO'¶
Indicates the model should return video.
- class genai.types.ModalityTokenCount(**data)¶
Bases:
BaseModelRepresents a breakdown of token usage by modality.
This message is used in CountTokensResponse and GenerateContentResponse.UsageMetadata to provide a detailed view of how many tokens are used by each modality (e.g., text, image, video) in a request. This is particularly useful for multimodal models, allowing you to track and manage token consumption for billing and quota purposes.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- modality: MediaModality | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- token_count: int | None¶
- class genai.types.ModalityTokenCountDict¶
Bases:
TypedDictRepresents a breakdown of token usage by modality.
This message is used in CountTokensResponse and GenerateContentResponse.UsageMetadata to provide a detailed view of how many tokens are used by each modality (e.g., text, image, video) in a request. This is particularly useful for multimodal models, allowing you to track and manage token consumption for billing and quota purposes.
- modality: MediaModality | None¶
The modality that this token count applies to.
- token_count: int | None¶
The number of tokens counted for this modality.
- class genai.types.Model(**data)¶
Bases:
BaseModelA trained machine learning model.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- checkpoints: list[Checkpoint] | None¶
- default_checkpoint_id: str | None¶
- description: str | None¶
- display_name: str | None¶
- input_token_limit: int | None¶
- labels: dict[str, str] | None¶
- max_temperature: float | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str | None¶
- output_token_limit: int | None¶
- supported_actions: list[str] | None¶
- temperature: float | None¶
- thinking: bool | None¶
- top_k: int | None¶
- top_p: float | None¶
- tuned_model_info: TunedModelInfo | None¶
- version: str | None¶
- class genai.types.ModelArmorConfig(**data)¶
Bases:
BaseModelConfiguration for Model Armor.
Model Armor is a Google Cloud service that provides safety and security filtering for prompts and responses. It helps protect your AI applications from risks such as harmful content, sensitive data leakage, and prompt injection attacks. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- prompt_template_name: str | None¶
- response_template_name: str | None¶
- class genai.types.ModelArmorConfigDict¶
Bases:
TypedDictConfiguration for Model Armor.
Model Armor is a Google Cloud service that provides safety and security filtering for prompts and responses. It helps protect your AI applications from risks such as harmful content, sensitive data leakage, and prompt injection attacks. This data type is not supported in Gemini API.
- prompt_template_name: str | None¶
Optional. The resource name of the Model Armor template to use for prompt screening. A Model Armor template is a set of customized filters and thresholds that define how Model Armor screens content. If specified, Model Armor will use this template to check the user’s prompt for safety and security risks before it is sent to the model. The name must be in the format projects/{project}/locations/{location}/templates/{template}.
- response_template_name: str | None¶
Optional. The resource name of the Model Armor template to use for response screening. A Model Armor template is a set of customized filters and thresholds that define how Model Armor screens content. If specified, Model Armor will use this template to check the model’s response for safety and security risks before it is returned to the user. The name must be in the format projects/{project}/locations/{location}/templates/{template}.
- class genai.types.ModelContent(parts)¶
Bases:
ContentModelContent facilitates the creation of a Content object with a model role.
Example usages:
Create a model Content object with a string: model_content = ModelContent(“Why is the sky blue?”)
Create a model Content object with a file data Part object: model_content = ModelContent(Part.from_uri(file_uri=”gs://bucket/file.txt”, mime_type=”text/plain”))
Create a model Content object with byte data Part object: model_content = ModelContent(Part.from_bytes(data=b”Hello, World!”, mime_type=”text/plain”))
You can create a model Content object using other classmethods in the Part class as well. You can also create a model Content using a list of Part objects or strings.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- role: Literal['model']¶
- class genai.types.ModelDict¶
Bases:
TypedDictA trained machine learning model.
- checkpoints: list[CheckpointDict] | None¶
The checkpoints of the model.
- default_checkpoint_id: str | None¶
The default checkpoint id of a model version.
- description: str | None¶
Description of the model.
- display_name: str | None¶
Display name of the model.
- endpoints: list[EndpointDict] | None¶
List of deployed models created from this base model. Note that a model could have been deployed to endpoints in different locations.
- input_token_limit: int | None¶
The maximum number of input tokens that the model can handle.
- labels: dict[str, str] | None¶
Labels with user-defined metadata to organize your models.
- max_temperature: float | None¶
The maximum temperature value used for sampling set when the dataset was saved. This value is used to tune the degree of randomness.
- name: str | None¶
Resource name of the model.
- output_token_limit: int | None¶
The maximum number of output tokens that the model can generate.
- supported_actions: list[str] | None¶
List of actions that are supported by the model.
- temperature: float | None¶
Temperature value used for sampling set when the dataset was saved. This value is used to tune the degree of randomness.
- thinking: bool | None¶
Whether the model supports thinking features. If true, thoughts are returned only if the model supports thought and thoughts are available.
- top_k: int | None¶
Optional. Specifies the top-k sampling threshold. The model considers only the top k most probable tokens for the next token. This can be useful for generating more coherent and less random text. For example, a top_k of 40 means the model will choose the next word from the 40 most likely words.
- top_p: float | None¶
Optional. Specifies the nucleus sampling threshold. The model considers only the smallest set of tokens whose cumulative probability is at least top_p. This helps generate more diverse and less repetitive responses. For example, a top_p of 0.9 means the model considers tokens until the cumulative probability of the tokens to select from reaches 0.9. It’s recommended to adjust either temperature or top_p, but not both.
- tuned_model_info: TunedModelInfoDict | None¶
Information about the tuned model from the base model.
- version: str | None¶
Version ID of the model. A new version is committed when a new model version is uploaded or trained under an existing model ID. The version ID is an auto-incrementing decimal number in string representation.
- class genai.types.ModelSelectionConfig(**data)¶
Bases:
BaseModelConfig for model selection.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- feature_selection_preference: FeatureSelectionPreference | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ModelSelectionConfigDict¶
Bases:
TypedDictConfig for model selection.
- feature_selection_preference: FeatureSelectionPreference | None¶
Options for feature selection preference.
- class genai.types.ModelStage(*values)¶
Bases:
CaseInSensitiveEnumThe stage of the underlying model.
This enum is not supported in Vertex AI.
- DEPRECATED = 'DEPRECATED'¶
Models in this stage are deprecated. These models cannot be used.
- EXPERIMENTAL = 'EXPERIMENTAL'¶
Models in this stage are for experimental purposes only.
- LEGACY = 'LEGACY'¶
If the model is on this stage, it means that this model is on the path to deprecation in near future. Only existing customers can use this model.
- MODEL_STAGE_UNSPECIFIED = 'MODEL_STAGE_UNSPECIFIED'¶
Unspecified model stage.
- PREVIEW = 'PREVIEW'¶
Models in this stage are more mature than experimental models.
- RETIRED = 'RETIRED'¶
Models in this stage are retired. These models cannot be used.
- STABLE = 'STABLE'¶
Models in this stage are considered stable and ready for production use.
- UNSTABLE_EXPERIMENTAL = 'UNSTABLE_EXPERIMENTAL'¶
The underlying model is subject to lots of tunings.
- class genai.types.ModelStatus(**data)¶
Bases:
BaseModelThe status of the underlying model.
This is used to indicate the stage of the underlying model and the retirement time if applicable. This data type is not supported in Vertex AI.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- message: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_stage: ModelStage | None¶
- retirement_time: datetime | None¶
- class genai.types.ModelStatusDict¶
Bases:
TypedDictThe status of the underlying model.
This is used to indicate the stage of the underlying model and the retirement time if applicable. This data type is not supported in Vertex AI.
- message: str | None¶
A message explaining the model status.
- model_stage: ModelStage | None¶
The stage of the underlying model.
- retirement_time: datetime | None¶
The time at which the model will be retired.
- class genai.types.MultiSpeakerVoiceConfig(**data)¶
Bases:
BaseModelConfiguration for a multi-speaker text-to-speech request.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- speaker_voice_configs: list[SpeakerVoiceConfig] | None¶
- class genai.types.MultiSpeakerVoiceConfigDict¶
Bases:
TypedDictConfiguration for a multi-speaker text-to-speech request.
- speaker_voice_configs: list[SpeakerVoiceConfigDict] | None¶
Required. A list of configurations for the voices of the speakers. Exactly two speaker voice configurations must be provided.
- class genai.types.MusicGenerationMode(*values)¶
Bases:
CaseInSensitiveEnumThe mode of music generation.
- DIVERSITY = 'DIVERSITY'¶
Steer text prompts to regions of latent space with a larger diversity of music.
- MUSIC_GENERATION_MODE_UNSPECIFIED = 'MUSIC_GENERATION_MODE_UNSPECIFIED'¶
Rely on the server default generation mode.
- QUALITY = 'QUALITY'¶
Steer text prompts to regions of latent space with higher quality music.
- VOCALIZATION = 'VOCALIZATION'¶
Steer text prompts to regions of latent space more likely to generate music with vocals.
- class genai.types.Operation¶
Bases:
ABCA long-running operation.
- done: bool | None = FieldInfo(annotation=NoneType, required=False, default=None, description='If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.')¶
- error: dict[str, Any] | None = FieldInfo(annotation=NoneType, required=False, default=None, description='The error result of the operation in case of failure or cancellation.')¶
- abstractmethod classmethod from_api_response(api_response, is_vertex_ai=False)¶
Creates an Operation from an API response.
- Return type:
Self
- metadata: dict[str, Any] | None = FieldInfo(annotation=NoneType, required=False, default=None, description='Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.')¶
- name: str | None = FieldInfo(annotation=NoneType, required=False, default=None, description='The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.')¶
- class genai.types.Outcome(*values)¶
Bases:
CaseInSensitiveEnumOutcome of the code execution.
- OUTCOME_DEADLINE_EXCEEDED = 'OUTCOME_DEADLINE_EXCEEDED'¶
Code execution ran for too long, and was cancelled. There may or may not be a partial output present.
- OUTCOME_FAILED = 'OUTCOME_FAILED'¶
Code execution failed. output contains the stderr and stdout, if any.
- OUTCOME_OK = 'OUTCOME_OK'¶
Code execution completed successfully. output contains the stdout, if any.
- OUTCOME_UNSPECIFIED = 'OUTCOME_UNSPECIFIED'¶
Unspecified status. This value should not be used.
- class genai.types.OutputConfig(**data)¶
Bases:
BaseModelConfig for evaluation output.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- gcs_destination: GcsDestination | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.OutputConfigDict¶
Bases:
TypedDictConfig for evaluation output.
- gcs_destination: GcsDestinationDict | None¶
Cloud storage destination for evaluation output.
- class genai.types.OutputInfo(**data)¶
Bases:
BaseModelDescribes the info for output of EvaluationService.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- gcs_output_directory: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.OutputInfoDict¶
Bases:
TypedDictDescribes the info for output of EvaluationService.
This data type is not supported in Gemini API.
- gcs_output_directory: str | None¶
Output only. The full path of the Cloud Storage directory created, into which the evaluation results and aggregation results are written.
- class genai.types.PairwiseChoice(*values)¶
Bases:
CaseInSensitiveEnumOutput only.
Pairwise metric choice. This enum is not supported in Gemini API.
- BASELINE = 'BASELINE'¶
Baseline prediction wins
- CANDIDATE = 'CANDIDATE'¶
Candidate prediction wins
- PAIRWISE_CHOICE_UNSPECIFIED = 'PAIRWISE_CHOICE_UNSPECIFIED'¶
Unspecified prediction choice.
- TIE = 'TIE'¶
Winner cannot be determined
- class genai.types.PairwiseMetricResult(**data)¶
Bases:
BaseModelSpec for pairwise metric result.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- custom_output: CustomOutput | None¶
- explanation: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- pairwise_choice: PairwiseChoice | None¶
- class genai.types.PairwiseMetricResultDict¶
Bases:
TypedDictSpec for pairwise metric result.
This data type is not supported in Gemini API.
- custom_output: CustomOutputDict | None¶
Output only. Spec for custom output.
- explanation: str | None¶
Output only. Explanation for pairwise metric score.
- pairwise_choice: PairwiseChoice | None¶
Output only. Pairwise metric choice.
- class genai.types.PairwiseMetricSpec(**data)¶
Bases:
BaseModelSpec for pairwise metric.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- baseline_response_field_name: str | None¶
- candidate_response_field_name: str | None¶
- custom_output_format_config: CustomOutputFormatConfig | None¶
- metric_prompt_template: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- system_instruction: str | None¶
- class genai.types.PairwiseMetricSpecDict¶
Bases:
TypedDictSpec for pairwise metric.
- baseline_response_field_name: str | None¶
Optional. The field name of the baseline response.
- candidate_response_field_name: str | None¶
Optional. The field name of the candidate response.
- custom_output_format_config: CustomOutputFormatConfigDict | None¶
Optional. CustomOutputFormatConfig allows customization of metric output. When this config is set, the default output is replaced with the raw output string. If a custom format is chosen, the pairwise_choice and explanation fields in the corresponding metric result will be empty.
- metric_prompt_template: str | None¶
Required. Metric prompt template for pairwise metric.
- system_instruction: str | None¶
Optional. System instructions for pairwise metric.
- class genai.types.Part(value=None, /, *, video_metadata=None, thought=None, inline_data=None, file_data=None, thought_signature=None, function_call=None, code_execution_result=None, executable_code=None, function_response=None, text=None, **kwargs)¶
Bases:
BaseModelA datatype containing media content.
Exactly one field within a Part should be set, representing the specific type of content being conveyed. Using multiple fields within the same Part instance is considered invalid.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- as_image()¶
Returns the part as a PIL Image, or None if the part is not an image.
- Return type:
Optional[Image]
- audio_transcription: Transcription | None¶
- code_execution_result: CodeExecutionResult | None¶
- executable_code: ExecutableCode | None¶
- classmethod from_uri(*, file_uri, mime_type=None, media_resolution=None)¶
Creates a Part from a file uri.
- Return type:
- Parameters:
file_uri (str) – The uri of the file
mime_type (str) – mime_type: The MIME type of the file. If not provided, the MIME type will be automatically determined.
- function_call: FunctionCall | None¶
- function_response: FunctionResponse | None¶
- media_processing: MediaProcessing | None¶
- media_resolution: PartMediaResolution | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- part_metadata: dict[str, Any] | None¶
- speech_metadata: SpeechMetadata | None¶
- text: str | None¶
- thought: bool | None¶
- thought_signature: bytes | None¶
- tool_response: ToolResponse | None¶
- video_metadata: VideoMetadata | None¶
- class genai.types.PartDict¶
Bases:
TypedDictA datatype containing media content.
Exactly one field within a Part should be set, representing the specific type of content being conveyed. Using multiple fields within the same Part instance is considered invalid.
- audio_transcription: TranscriptionDict | None¶
Output only. The transcription of the audio part.
- code_execution_result: CodeExecutionResultDict | None¶
Optional. The result of executing the ExecutableCode.
- executable_code: ExecutableCodeDict | None¶
Optional. Code generated by the model that is intended to be executed.
- file_data: FileDataDict | None¶
Optional. The URI-based data of the part. This can be used to include files from Google Cloud Storage.
- function_call: FunctionCallDict | None¶
Optional. A predicted function call returned from the model. This contains the name of the function to call and the arguments to pass to the function.
- function_response: FunctionResponseDict | None¶
Optional. The result of a function call. This is used to provide the model with the result of a function call that it predicted.
- inline_data: BlobDict | None¶
Optional. The inline data content of the part. This can be used to include images, audio, or video in a request.
- media_processing: MediaProcessing | None¶
How the model processes this part’s media for understanding.
- media_resolution: PartMediaResolutionDict | None¶
Media resolution for the input media.
- part_metadata: dict[str, Any] | None¶
Custom metadata associated with the Part. Agents using genai.Part as content representation may need to keep track of the additional information. For example it can be name of a file/source from which the Part originates or a way to multiplex multiple Part streams. This field is not supported in Vertex AI.
- speech_metadata: SpeechMetadataDict | None¶
Extra metadata associated with the part for speech synthesis, such as speaker and style. Only valid when Part.data is set to text.
- text: str | None¶
Optional. The text content of the part. When sent from the VSCode Gemini Code Assist extension, references to @mentioned items will be converted to markdown boldface text. For example @my-repo will be converted to and sent as **my-repo** by the IDE agent.
- thought: bool | None¶
Optional. Indicates whether the part represents the model’s thought process or reasoning.
- thought_signature: bytes | None¶
Optional. An opaque signature for the thought so it can be reused in subsequent requests.
- tool_call: ToolCallDict | None¶
Server-side tool call. This field is populated when the model predicts a tool invocation that should be executed on the server. The client is expected to echo this message back to the API.
- tool_response: ToolResponseDict | None¶
The output from a server-side ToolCall execution. This field is populated by the client with the results of executing the corresponding ToolCall.
- video_metadata: VideoMetadataDict | None¶
Optional. Video metadata. The metadata should only be specified while the video data is presented in inline_data or file_data.
- class genai.types.PartMediaResolution(**data)¶
Bases:
BaseModelMedia resolution for the input media.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- level: PartMediaResolutionLevel | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- num_tokens: int | None¶
- class genai.types.PartMediaResolutionDict¶
Bases:
TypedDictMedia resolution for the input media.
- level: PartMediaResolutionLevel | None¶
The tokenization quality used for given media.
- num_tokens: int | None¶
Specifies the required sequence length for media tokenization.
- class genai.types.PartMediaResolutionLevel(*values)¶
Bases:
CaseInSensitiveEnumThe tokenization quality used for given media.
- MEDIA_RESOLUTION_HIGH = 'MEDIA_RESOLUTION_HIGH'¶
Media resolution set to high.
- MEDIA_RESOLUTION_LOW = 'MEDIA_RESOLUTION_LOW'¶
Media resolution set to low.
- MEDIA_RESOLUTION_MEDIUM = 'MEDIA_RESOLUTION_MEDIUM'¶
Media resolution set to medium.
- MEDIA_RESOLUTION_ULTRA_HIGH = 'MEDIA_RESOLUTION_ULTRA_HIGH'¶
Media resolution set to ultra high.
- MEDIA_RESOLUTION_UNSPECIFIED = 'MEDIA_RESOLUTION_UNSPECIFIED'¶
Media resolution has not been set.
- class genai.types.PartialArg(**data)¶
Bases:
BaseModelPartial argument value of the function call.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- bool_value: bool | None¶
- json_path: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- null_value: Literal['NULL_VALUE'] | None¶
- number_value: float | None¶
- string_value: str | None¶
- will_continue: bool | None¶
- class genai.types.PartialArgDict¶
Bases:
TypedDictPartial argument value of the function call.
This data type is not supported in Gemini API.
- bool_value: bool | None¶
Optional. Represents a boolean value.
- json_path: str | None¶
//datatracker.ietf.org/doc/html/rfc9535. e.g. “$.foo.bar[0].data”.
- Type:
Required. A JSON Path (RFC 9535) to the argument being streamed. https
- null_value: Literal['NULL_VALUE'] | None¶
Optional. Represents a null value.
- number_value: float | None¶
Optional. Represents a double value.
- string_value: str | None¶
Optional. Represents a string value.
- will_continue: bool | None¶
Optional. Whether this is not the last part of the same json_path. If true, another PartialArg message for the current json_path is expected to follow.
- class genai.types.PartnerModelTuningSpec(**data)¶
Bases:
BaseModelTuning spec for Partner models.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- hyper_parameters: dict[str, Any] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- training_dataset_uri: str | None¶
- validation_dataset_uri: str | None¶
- class genai.types.PartnerModelTuningSpecDict¶
Bases:
TypedDictTuning spec for Partner models.
This data type is not supported in Gemini API.
- hyper_parameters: dict[str, Any] | None¶
Hyperparameters for tuning. The accepted hyper_parameters and their valid range of values will differ depending on the base model.
- training_dataset_uri: str | None¶
Required. Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file.
- validation_dataset_uri: str | None¶
Optional. Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file.
- class genai.types.PersonGeneration(*values)¶
Bases:
CaseInSensitiveEnumEnum that controls the generation of people.
- ALLOW_ADULT = 'ALLOW_ADULT'¶
Generate images of adults, but not children.
- ALLOW_ALL = 'ALLOW_ALL'¶
Generate images that include adults and children.
- DONT_ALLOW = 'DONT_ALLOW'¶
Block generation of images of people.
- class genai.types.PhishBlockThreshold(*values)¶
Bases:
CaseInSensitiveEnumSites with confidence level chosen & above this value will be blocked from the search results.
This enum is not supported in Gemini API.
- BLOCK_HIGHER_AND_ABOVE = 'BLOCK_HIGHER_AND_ABOVE'¶
Blocks Higher and above confidence URL that is risky.
- BLOCK_HIGH_AND_ABOVE = 'BLOCK_HIGH_AND_ABOVE'¶
Blocks High and above confidence URL that is risky.
- BLOCK_LOW_AND_ABOVE = 'BLOCK_LOW_AND_ABOVE'¶
Blocks Low and above confidence URL that is risky.
- BLOCK_MEDIUM_AND_ABOVE = 'BLOCK_MEDIUM_AND_ABOVE'¶
Blocks Medium and above confidence URL that is risky.
- BLOCK_ONLY_EXTREMELY_HIGH = 'BLOCK_ONLY_EXTREMELY_HIGH'¶
Blocks Extremely high confidence URL that is risky.
- BLOCK_VERY_HIGH_AND_ABOVE = 'BLOCK_VERY_HIGH_AND_ABOVE'¶
Blocks Very high and above confidence URL that is risky.
- PHISH_BLOCK_THRESHOLD_UNSPECIFIED = 'PHISH_BLOCK_THRESHOLD_UNSPECIFIED'¶
Defaults to unspecified.
- class genai.types.PointwiseMetricResult(**data)¶
Bases:
BaseModelSpec for pointwise metric result.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- custom_output: CustomOutput | None¶
- explanation: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- score: float | None¶
- class genai.types.PointwiseMetricResultDict¶
Bases:
TypedDictSpec for pointwise metric result.
This data type is not supported in Gemini API.
- custom_output: CustomOutputDict | None¶
Output only. Spec for custom output.
- explanation: str | None¶
Output only. Explanation for pointwise metric score.
- score: float | None¶
Output only. Pointwise metric score.
- class genai.types.PointwiseMetricSpec(**data)¶
Bases:
BaseModelSpec for pointwise metric.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- custom_output_format_config: CustomOutputFormatConfig | None¶
- metric_prompt_template: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- system_instruction: str | None¶
- class genai.types.PointwiseMetricSpecDict¶
Bases:
TypedDictSpec for pointwise metric.
- custom_output_format_config: CustomOutputFormatConfigDict | None¶
The raw output string. - A parsed output based on a user-defined schema. If a custom format is chosen, the score and explanation fields in the corresponding metric result will be empty.
- Type:
Optional. CustomOutputFormatConfig allows customization of metric output. By default, metrics return a score and explanation. When this config is set, the default output is replaced with either
- metric_prompt_template: str | None¶
Required. Metric prompt template for pointwise metric.
- system_instruction: str | None¶
Optional. System instructions for pointwise metric.
- class genai.types.PreTunedModel(**data)¶
Bases:
BaseModelA pre-tuned model for continuous tuning.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- base_model: str | None¶
- checkpoint_id: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- tuned_model_name: str | None¶
- class genai.types.PreTunedModelDict¶
Bases:
TypedDictA pre-tuned model for continuous tuning.
This data type is not supported in Gemini API.
- base_model: str | None¶
Output only. The name of the base model this PreTunedModel was tuned from.
- checkpoint_id: str | None¶
Optional. The source checkpoint id. If not specified, the default checkpoint will be used.
- tuned_model_name: str | None¶
projects/{project}/locations/{location}/models/{model}
- Type:
The resource name of the Model. E.g., a model resource name with a specified version id or alias
- Type:
projects/{project}/locations/{location}/models/{model}@{version_id} projects/{project}/locations/{location}/models/{model}@{alias} Or, omit the version id to use the default version
- class genai.types.PrebuiltVoiceConfig(**data)¶
Bases:
BaseModelConfiguration for a prebuilt voice.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- voice_name: str | None¶
- class genai.types.PrebuiltVoiceConfigDict¶
Bases:
TypedDictConfiguration for a prebuilt voice.
- voice_name: str | None¶
The name of the prebuilt voice to use.
- class genai.types.PredefinedMetricSpec(**data)¶
Bases:
BaseModelSpec for predefined metric.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- metric_spec_name: str | None¶
- metric_spec_parameters: dict[str, Any] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.PredefinedMetricSpecDict¶
Bases:
TypedDictSpec for predefined metric.
- metric_spec_name: str | None¶
The name of a pre-defined metric, such as “instruction_following_v1” or “text_quality_v1”.
- metric_spec_parameters: dict[str, Any] | None¶
The parameters needed to run the pre-defined metric.
- class genai.types.PreferenceOptimizationDataStats(**data)¶
Bases:
BaseModelStatistics computed for datasets used for preference optimization.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- dropped_example_indices: list[int] | None¶
- dropped_example_reasons: list[str] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- score_variance_per_example_distribution: DatasetDistribution | None¶
- scores_distribution: DatasetDistribution | None¶
- total_billable_token_count: int | None¶
- tuning_dataset_example_count: int | None¶
- tuning_step_count: int | None¶
- user_dataset_examples: list[GeminiPreferenceExample] | None¶
- user_input_token_distribution: DatasetDistribution | None¶
- user_output_token_distribution: DatasetDistribution | None¶
- class genai.types.PreferenceOptimizationDataStatsDict¶
Bases:
TypedDictStatistics computed for datasets used for preference optimization.
This data type is not supported in Gemini API.
- dropped_example_indices: list[int] | None¶
Output only. A partial sample of the indices (starting from 1) of the dropped examples.
- dropped_example_reasons: list[str] | None¶
Output only. For each index in dropped_example_indices, the user-facing reason why the example was dropped.
- score_variance_per_example_distribution: DatasetDistributionDict | None¶
Output only. Dataset distributions for scores variance per example.
- scores_distribution: DatasetDistributionDict | None¶
Output only. Dataset distributions for scores.
- total_billable_token_count: int | None¶
Output only. Number of billable tokens in the tuning dataset.
- tuning_dataset_example_count: int | None¶
Output only. Number of examples in the tuning dataset.
- tuning_step_count: int | None¶
Output only. Number of tuning steps for this Tuning Job.
- user_dataset_examples: list[GeminiPreferenceExampleDict] | None¶
Output only. Sample user examples in the training dataset.
- user_input_token_distribution: DatasetDistributionDict | None¶
Output only. Dataset distributions for the user input tokens.
- user_output_token_distribution: DatasetDistributionDict | None¶
Output only. Dataset distributions for the user output tokens.
- class genai.types.PreferenceOptimizationHyperParameters(**data)¶
Bases:
BaseModelHyperparameters for Preference Optimization.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- adapter_size: AdapterSize | None¶
- beta: float | None¶
- epoch_count: int | None¶
- learning_rate_multiplier: float | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.PreferenceOptimizationHyperParametersDict¶
Bases:
TypedDictHyperparameters for Preference Optimization.
This data type is not supported in Gemini API.
- adapter_size: AdapterSize | None¶
Optional. Adapter size for preference optimization.
- beta: float | None¶
Optional. Weight for KL Divergence regularization.
- epoch_count: int | None¶
Optional. Number of complete passes the model makes over the entire training dataset during training.
- learning_rate_multiplier: float | None¶
Optional. Multiplier for adjusting the default learning rate.
- class genai.types.PreferenceOptimizationSpec(**data)¶
Bases:
BaseModelPreference optimization tuning spec for tuning.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- export_last_checkpoint_only: bool | None¶
- hyper_parameters: PreferenceOptimizationHyperParameters | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- training_dataset_uri: str | None¶
- validation_dataset_uri: str | None¶
- class genai.types.PreferenceOptimizationSpecDict¶
Bases:
TypedDictPreference optimization tuning spec for tuning.
- export_last_checkpoint_only: bool | None¶
Optional. If set to true, disable intermediate checkpoints for Preference Optimization and only the last checkpoint will be exported. Otherwise, enable intermediate checkpoints for Preference Optimization. Default is false.
- hyper_parameters: PreferenceOptimizationHyperParametersDict | None¶
Optional. Hyperparameters for Preference Optimization.
- training_dataset_uri: str | None¶
Required. Cloud Storage path to file containing training dataset for preference optimization tuning. The dataset must be formatted as a JSONL file.
- validation_dataset_uri: str | None¶
Optional. Cloud Storage path to file containing validation dataset for preference optimization tuning. The dataset must be formatted as a JSONL file.
- class genai.types.ProactivityConfig(**data)¶
Bases:
BaseModelConfig for proactivity features.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- proactive_audio: bool | None¶
- class genai.types.ProactivityConfigDict¶
Bases:
TypedDictConfig for proactivity features.
- proactive_audio: bool | None¶
If enabled, the model can reject responding to the last prompt. For example, this allows the model to ignore out of context speech or to stay silent if the user did not make a request, yet.
- class genai.types.ProductImage(**data)¶
Bases:
BaseModelAn image of the product.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ProductImageDict¶
Bases:
TypedDictAn image of the product.
- class genai.types.ProjectOperation(**data)¶
Bases:
BaseModelA project-level operation in Gemini Enterprise Agent Platform.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- done: bool | None¶
- error: dict[str, Any] | None¶
- metadata: dict[str, Any] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str | None¶
- class genai.types.ProjectOperationDict¶
Bases:
TypedDictA project-level operation in Gemini Enterprise Agent Platform.
- done: bool | None¶
If the value is false, it means the operation is still in progress. If true, the operation is completed, and either error or response is available.
- error: dict[str, Any] | None¶
The error result of the operation in case of failure or cancellation.
- metadata: dict[str, Any] | None¶
Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
- name: str | None¶
The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the name should be a resource name ending with operations/{unique_id}.
- class genai.types.ProminentPeople(*values)¶
Bases:
CaseInSensitiveEnumControls whether prominent people (celebrities) generation is allowed.
If used with personGeneration, personGeneration enum would take precedence. For instance, if ALLOW_NONE is set, all person generation would be blocked. If this field is unspecified, the default behavior is to allow prominent people. This enum is not supported in Gemini API.
- ALLOW_PROMINENT_PEOPLE = 'ALLOW_PROMINENT_PEOPLE'¶
Allows the model to generate images of prominent people.
- BLOCK_PROMINENT_PEOPLE = 'BLOCK_PROMINENT_PEOPLE'¶
Prevents the model from generating images of prominent people.
- PROMINENT_PEOPLE_UNSPECIFIED = 'PROMINENT_PEOPLE_UNSPECIFIED'¶
Unspecified value. The model will proceed with the default behavior, which is to allow generation of prominent people.
- class genai.types.RagChunk(**data)¶
Bases:
BaseModelA RagChunk includes the content of a chunk of a RagFile, and associated metadata.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- chunk_id: str | None¶
- file_id: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- page_span: RagChunkPageSpan | None¶
- text: str | None¶
- class genai.types.RagChunkDict¶
Bases:
TypedDictA RagChunk includes the content of a chunk of a RagFile, and associated metadata.
This data type is not supported in Gemini API.
- chunk_id: str | None¶
The ID of the chunk.
- file_id: str | None¶
The ID of the file that the chunk belongs to.
- page_span: RagChunkPageSpanDict | None¶
If populated, represents where the chunk starts and ends in the document.
- text: str | None¶
The content of the chunk.
- class genai.types.RagChunkPageSpan(**data)¶
Bases:
BaseModelRepresents where the chunk starts and ends in the document.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- first_page: int | None¶
- last_page: int | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.RagChunkPageSpanDict¶
Bases:
TypedDictRepresents where the chunk starts and ends in the document.
This data type is not supported in Gemini API.
- first_page: int | None¶
Page where chunk starts in the document. Inclusive. 1-indexed.
- last_page: int | None¶
Page where chunk ends in the document. Inclusive. 1-indexed.
- class genai.types.RagRetrievalConfig(**data)¶
Bases:
BaseModelSpecifies the context retrieval config.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- filter: RagRetrievalConfigFilter | None¶
- hybrid_search: RagRetrievalConfigHybridSearch | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- ranking: RagRetrievalConfigRanking | None¶
- top_k: int | None¶
- class genai.types.RagRetrievalConfigDict¶
Bases:
TypedDictSpecifies the context retrieval config.
This data type is not supported in Gemini API.
- filter: RagRetrievalConfigFilterDict | None¶
Optional. Config for filters.
- hybrid_search: RagRetrievalConfigHybridSearchDict | None¶
Optional. Config for Hybrid Search.
- ranking: RagRetrievalConfigRankingDict | None¶
Optional. Config for ranking and reranking.
- top_k: int | None¶
Optional. The number of contexts to retrieve.
- class genai.types.RagRetrievalConfigFilter(**data)¶
Bases:
BaseModelConfig for filters. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- metadata_filter: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- vector_distance_threshold: float | None¶
- vector_similarity_threshold: float | None¶
- class genai.types.RagRetrievalConfigFilterDict¶
Bases:
TypedDictConfig for filters. This data type is not supported in Gemini API.
- metadata_filter: str | None¶
Optional. String for metadata filtering.
- vector_distance_threshold: float | None¶
Optional. Only returns contexts with vector distance smaller than the threshold.
- vector_similarity_threshold: float | None¶
Optional. Only returns contexts with vector similarity larger than the threshold.
- class genai.types.RagRetrievalConfigHybridSearch(**data)¶
Bases:
BaseModelConfig for Hybrid Search. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- alpha: float | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.RagRetrievalConfigHybridSearchDict¶
Bases:
TypedDictConfig for Hybrid Search. This data type is not supported in Gemini API.
- alpha: float | None¶
Optional. Alpha value controls the weight between dense and sparse vector search results. The range is [0, 1], while 0 means sparse vector search only and 1 means dense vector search only. The default value is 0.5 which balances sparse and dense vector search equally.
- class genai.types.RagRetrievalConfigRanking(**data)¶
Bases:
BaseModelConfig for ranking and reranking.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- llm_ranker: RagRetrievalConfigRankingLlmRanker | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- rank_service: RagRetrievalConfigRankingRankService | None¶
- class genai.types.RagRetrievalConfigRankingDict¶
Bases:
TypedDictConfig for ranking and reranking.
This data type is not supported in Gemini API.
- llm_ranker: RagRetrievalConfigRankingLlmRankerDict | None¶
Optional. Config for LlmRanker.
- rank_service: RagRetrievalConfigRankingRankServiceDict | None¶
Optional. Config for Rank Service.
- class genai.types.RagRetrievalConfigRankingLlmRanker(**data)¶
Bases:
BaseModelConfig for LlmRanker. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_name: str | None¶
- class genai.types.RagRetrievalConfigRankingLlmRankerDict¶
Bases:
TypedDictConfig for LlmRanker. This data type is not supported in Gemini API.
- model_name: str | None¶
//cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#supported-models).
- Type:
Optional. The model name used for ranking. See [Supported models](https
- class genai.types.RagRetrievalConfigRankingRankService(**data)¶
Bases:
BaseModelConfig for Rank Service. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_name: str | None¶
- class genai.types.RagRetrievalConfigRankingRankServiceDict¶
Bases:
TypedDictConfig for Rank Service. This data type is not supported in Gemini API.
- model_name: str | None¶
semantic-ranker-512@latest
- Type:
Optional. The model name of the rank service. Format
- class genai.types.RawOutput(**data)¶
Bases:
BaseModelRaw output. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- raw_output: list[str] | None¶
- class genai.types.RawOutputDict¶
Bases:
TypedDictRaw output. This data type is not supported in Gemini API.
- raw_output: list[str] | None¶
Output only. Raw output string.
- class genai.types.RawReferenceImage(**data)¶
Bases:
BaseModelA raw reference image.
A raw reference image represents the base image to edit, provided by the user. It can optionally be provided in addition to a mask reference image or a style reference image.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- reference_id: int | None¶
- reference_type: str | None¶
- class genai.types.RawReferenceImageDict¶
Bases:
TypedDictA raw reference image.
A raw reference image represents the base image to edit, provided by the user. It can optionally be provided in addition to a mask reference image or a style reference image.
- reference_id: int | None¶
The id of the reference image.
- reference_type: str | None¶
The type of the reference image. Only set by the SDK.
- class genai.types.RealtimeInputConfig(**data)¶
Bases:
BaseModelMarks the end of user activity.
This can only be sent if automatic (i.e. server-side) activity detection is disabled.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- activity_handling: ActivityHandling | None¶
- automatic_activity_detection: AutomaticActivityDetection | None¶
- interim_transcript_timestamp_enabled: bool | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- turn_coverage: TurnCoverage | None¶
- class genai.types.RealtimeInputConfigDict¶
Bases:
TypedDictMarks the end of user activity.
This can only be sent if automatic (i.e. server-side) activity detection is disabled.
- activity_handling: ActivityHandling | None¶
Defines what effect activity has.
- automatic_activity_detection: AutomaticActivityDetectionDict | None¶
If not set, automatic activity detection is enabled by default. If automatic voice detection is disabled, the client must send activity signals.
- interim_transcript_timestamp_enabled: bool | None¶
If true, enables interim transcript timestamps.
- turn_coverage: TurnCoverage | None¶
Defines which input is included in the user’s turn.
- class genai.types.RecontextImageConfig(**data)¶
Bases:
BaseModelConfiguration for recontextualizing an image.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- add_watermark: bool | None¶
- base_steps: int | None¶
- enhance_prompt: bool | None¶
- http_options: HttpOptions | None¶
- labels: dict[str, str] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- number_of_images: int | None¶
- output_compression_quality: int | None¶
- output_gcs_uri: str | None¶
- output_mime_type: str | None¶
- person_generation: PersonGeneration | None¶
- safety_filter_level: SafetyFilterLevel | None¶
- seed: int | None¶
- class genai.types.RecontextImageConfigDict¶
Bases:
TypedDictConfiguration for recontextualizing an image.
- add_watermark: bool | None¶
Whether to add a SynthID watermark to the generated images.
- base_steps: int | None¶
The number of sampling steps. A higher value has better image quality, while a lower value has better latency.
- enhance_prompt: bool | None¶
Whether to use the prompt rewriting logic.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- labels: dict[str, str] | None¶
User specified labels to track billing usage.
- number_of_images: int | None¶
Number of images to generate.
- output_compression_quality: int | None¶
Compression quality of the generated image (for
image/jpegonly).
- output_gcs_uri: str | None¶
Cloud Storage URI used to store the generated images.
- output_mime_type: str | None¶
MIME type of the generated image.
- person_generation: PersonGeneration | None¶
Whether allow to generate person images, and restrict to specific ages.
- safety_filter_level: SafetyFilterLevel | None¶
Filter level for safety filtering.
- seed: int | None¶
Random seed for image generation.
- class genai.types.RecontextImageResponse(**data)¶
Bases:
BaseModelThe output images response.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- generated_images: list[GeneratedImage] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.RecontextImageResponseDict¶
Bases:
TypedDictThe output images response.
- generated_images: list[GeneratedImageDict] | None¶
List of generated images.
- class genai.types.RecontextImageSource(**data)¶
Bases:
BaseModelA set of source input(s) for image recontextualization.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- product_images: list[ProductImage] | None¶
- prompt: str | None¶
- class genai.types.RecontextImageSourceDict¶
Bases:
TypedDictA set of source input(s) for image recontextualization.
- product_images: list[ProductImageDict] | None¶
A list of product images.
- prompt: str | None¶
A text prompt for guiding the model during image recontextualization. Not supported for Virtual Try-On.
- class genai.types.RegisterFilesConfig(**data)¶
Bases:
BaseModelUsed to override the default configuration.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- should_return_http_response: bool | None¶
- class genai.types.RegisterFilesConfigDict¶
Bases:
TypedDictUsed to override the default configuration.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- should_return_http_response: bool | None¶
If true, the raw HTTP response will be returned in the ‘sdk_http_response’ field.
- class genai.types.RegisterFilesResponse(**data)¶
Bases:
BaseModelResponse for the _register file method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- sdk_http_response: HttpResponse | None¶
- class genai.types.RegisterFilesResponseDict¶
Bases:
TypedDictResponse for the _register file method.
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.ReinforcementTuningAutoraterScorer(**data)¶
Bases:
BaseModelReinforcement tuning autorater scorer.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- autorater_config: AutoraterConfig | None¶
- autorater_prompt: str | None¶
- autorater_response_parse_config: ReinforcementTuningParseResponseConfig | None¶
- exact_match_scorer: ReinforcementTuningAutoraterScorerExactMatchScorer | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- parsed_response_conversion_scorer: ReinforcementTuningAutoraterScorerParsedResponseConversionScorer | None¶
- class genai.types.ReinforcementTuningAutoraterScorerDict¶
Bases:
TypedDictReinforcement tuning autorater scorer.
- autorater_config: AutoraterConfigDict | None¶
Autorater config for evaluation.
- autorater_prompt: str | None¶
{{prompt}} - {{response}} - {{system_instruction}} - {{references.key}}
- Type:
The prompt for an autorater to scorer the parsed sample response. This field supports the following placeholders that will be replaced before scoring
- autorater_response_parse_config: ReinforcementTuningParseResponseConfigDict | None¶
Parses autorater returned response for scoring. For example, if the autorater response has reward stored in the 2.0 block, defining a parsing response config using regex “.*(.*?)” will return a score “2.0”.
- exact_match_scorer: ReinforcementTuningAutoraterScorerExactMatchScorerDict | None¶
Scores autorater responses by using string match reward scorer.
- parsed_response_conversion_scorer: ReinforcementTuningAutoraterScorerParsedResponseConversionScorerDict | None¶
Reward is clipped to be within [-1, 1], i.e., reward = max(min(reward, 1.0), -1.0).
- Type:
Scores autorater responses by directly converting parsed autorater response to a float reward. Note
- class genai.types.ReinforcementTuningAutoraterScorerExactMatchScorer(**data)¶
Bases:
BaseModelScores autorater responses by using exact string match reward scorer.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- correct_answer_reward: float | None¶
- expression: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- wrong_answer_reward: float | None¶
- class genai.types.ReinforcementTuningAutoraterScorerExactMatchScorerDict¶
Bases:
TypedDictScores autorater responses by using exact string match reward scorer.
This data type is not supported in Gemini API.
- correct_answer_reward: float | None¶
Assigns this reward score if the parsed response string equals the expression.
- expression: str | None¶
1.0, “wrongAnswerReward”: -1.0, “expression”: “{{references.concise_answer}}” } When evaluating the reward for each parsed autorater response, if the prompt references in the training/validation dataset has the following fields:
` { "example": ..., "references": { "concise_ansser": "Yes", "verbose_answer": "The answer is Yes" } } `The above ExactMatchScorer will be replaced as follows for scoring:` { "correctAnswerReward": 1.0, "wrongAnswerReward": -1.0, "expression": "Yes" } `If the parsed autorater response is equal to the string “Yes”, then the reward is 1.0, otherwise the reward is -1.0.- Type:
The string expression to match against for scoring. This field supports placeholders in the format of {{references.key}} that will be replaced before matching. Regex is not supported for this expression. For example, users can define an ExactMatchScorer as follows
- Type:
{ “correctAnswerReward”
- wrong_answer_reward: float | None¶
Assigns this reward score if the parsed reward value does not equal the expression.
- class genai.types.ReinforcementTuningAutoraterScorerParsedResponseConversionScorer(**data)¶
Bases:
BaseModelScores responses by directly converting the parsed autorater response to a float reward.
Note: Reward is clipped to be within [-1, 1], i.e., reward = max(min(reward, 1.0), -1.0). This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ReinforcementTuningAutoraterScorerParsedResponseConversionScorerDict¶
Bases:
TypedDictScores responses by directly converting the parsed autorater response to a float reward.
Note: Reward is clipped to be within [-1, 1], i.e., reward = max(min(reward, 1.0), -1.0). This data type is not supported in Gemini API.
- class genai.types.ReinforcementTuningCloudRunRewardScorer(**data)¶
Bases:
BaseModelReinforcementTuningCloudRunRewardScorer allows users to implement a reward function through GCP Cloud Run.
Comparing with ReinforcementTuningCodeExecutionRewardScorer that runs in a Sandbox and has no internet access, Cloud Run reward scorer is fully controlled by users. The Cloud Run service should implement the following HTTP API: HTTP method: POST HTTP request body:
` { "example": ReinforcementTuningExample, "response": Content, "metadata": { "step": int "tuning_job_id": int64 } } `* example is a ReinforcementTuningExample in ProtoJSON format, (i.e., the format is the same as as one line in the training/validation dataset except that the keys must be in camel case). System instructions (i.e., example.get(“systemInstruction”)) and references (i.e., example.get(“references”)) are also included in the example provided that they are set in the training/validation dataset. * response is a Content in ProtoJSON format (i.e., keys must be in camel case), which is the same as the Online Prediction response for Gemini models. HTTP response body: { “reward”: float, “user_requested_aux_info”: str // Optional } where the field “user_requested_aux_info” is any (optional) string provided by users for assisting debugging. It’s in snake case. This field is mostly useful when calling the GenAiTuningService.ValidateReinforcementTuningReward API, where the proto field (not Cloud Run HTTP response body) userRequestedAuxInfo will be populated if the Cloud Run reward function sets this field in the HTTP response. The following are examples for the HTTP request and response body. Example HTTP request body:` { "example": { "contents": [ { "role": "user", "parts": [ { "text": "What is the capital of France?" } ] } ], "references": { "answer": "Paris" } }, "response": { "parts": [ { "text": "London" } ] }, "metadata": { "step": 1, "tuning_job_id": 123456789 } } `Example HTTP response body:` { "reward": -1.0 } `Note: Reward output by Cloud Run reward function is clipped to be within [-1, 1], i.e., reward = max(min(reward, 1.0), -1.0). This data type is not supported in Gemini API.Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- cloud_run_uri: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ReinforcementTuningCloudRunRewardScorerDict¶
Bases:
TypedDictReinforcementTuningCloudRunRewardScorer allows users to implement a reward function through GCP Cloud Run.
Comparing with ReinforcementTuningCodeExecutionRewardScorer that runs in a Sandbox and has no internet access, Cloud Run reward scorer is fully controlled by users. The Cloud Run service should implement the following HTTP API: HTTP method: POST HTTP request body:
` { "example": ReinforcementTuningExample, "response": Content, "metadata": { "step": int "tuning_job_id": int64 } } `* example is a ReinforcementTuningExample in ProtoJSON format, (i.e., the format is the same as as one line in the training/validation dataset except that the keys must be in camel case). System instructions (i.e., example.get(“systemInstruction”)) and references (i.e., example.get(“references”)) are also included in the example provided that they are set in the training/validation dataset. * response is a Content in ProtoJSON format (i.e., keys must be in camel case), which is the same as the Online Prediction response for Gemini models. HTTP response body: { “reward”: float, “user_requested_aux_info”: str // Optional } where the field “user_requested_aux_info” is any (optional) string provided by users for assisting debugging. It’s in snake case. This field is mostly useful when calling the GenAiTuningService.ValidateReinforcementTuningReward API, where the proto field (not Cloud Run HTTP response body) userRequestedAuxInfo will be populated if the Cloud Run reward function sets this field in the HTTP response. The following are examples for the HTTP request and response body. Example HTTP request body:` { "example": { "contents": [ { "role": "user", "parts": [ { "text": "What is the capital of France?" } ] } ], "references": { "answer": "Paris" } }, "response": { "parts": [ { "text": "London" } ] }, "metadata": { "step": 1, "tuning_job_id": 123456789 } } `Example HTTP response body:` { "reward": -1.0 } `Note: Reward output by Cloud Run reward function is clipped to be within [-1, 1], i.e., reward = max(min(reward, 1.0), -1.0). This data type is not supported in Gemini API.- cloud_run_uri: str | None¶
//docs.cloud.google.com/iam/docs/service-agents#vertex-ai-secure-fine-tuning-service-agent) (service-@gcp-sa-vertex-tune.iam.gserviceaccount.com) must be granted the permission (e.g. by granting roles/run.invoker in IAM) to invoke the Cloud Run service.
- Type:
URI of the Cloud Run service that will be used to compute the reward. The [Vertex AI Secure Fine Tuning Service Agent](https
- class genai.types.ReinforcementTuningCodeExecutionRewardScorer(**data)¶
Bases:
BaseModelReinforcementTuningCodeExecutionRewardScorer allows users to implement a function to evaluate rewards for the sample response.
The function signature is as follows:
` def evaluate(example: dict[str, Any], response: dict[str, Any]) -> float: ... `example is a ReinforcementTuningExample in ProtoJSON format, (i.e., the format is the same as as one line in the training/validation dataset except that the keys must be in camel case). System instructions (i.e., example.get(“systemInstruction”)) and references (i.e., example.get(“references”)) are also included in the example provided that they are set in the training/validation dataset. response is a Content in ProtoJSON format (i.e., keys must be in camel case), which is the same as the Online Prediction response for Gemini models. Note: Reward output by the evaluate function is clipped to be within [-1, 1], i.e., reward = max(min(reward, 1.0), -1.0). This data type is not supported in Gemini API.Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- python_code_snippet: str | None¶
- class genai.types.ReinforcementTuningCodeExecutionRewardScorerDict¶
Bases:
TypedDictReinforcementTuningCodeExecutionRewardScorer allows users to implement a function to evaluate rewards for the sample response.
The function signature is as follows:
` def evaluate(example: dict[str, Any], response: dict[str, Any]) -> float: ... `example is a ReinforcementTuningExample in ProtoJSON format, (i.e., the format is the same as as one line in the training/validation dataset except that the keys must be in camel case). System instructions (i.e., example.get(“systemInstruction”)) and references (i.e., example.get(“references”)) are also included in the example provided that they are set in the training/validation dataset. response is a Content in ProtoJSON format (i.e., keys must be in camel case), which is the same as the Online Prediction response for Gemini models. Note: Reward output by the evaluate function is clipped to be within [-1, 1], i.e., reward = max(min(reward, 1.0), -1.0). This data type is not supported in Gemini API.- python_code_snippet: str | None¶
Reward output by the evaluate function is clipped to be within [-1, 1], i.e., reward = max(min(reward, 1.0), -1.0).
- Type:
The python code snippet as a string for evaluating rewards. The following is an example python code snippet that returns a reward 1.0 for a parsed response matching the user-provided reference answer in per prompt references map.
` def evaluate(example, response) -> float: response_str = response.get("parts", [])0 references = example.get("references", {}) if response_str == references.get("concise_answer"): return 1.0 return -1.0 `Note
- class genai.types.ReinforcementTuningExample(**data)¶
Bases:
BaseModelUser-facing format for Gemini Reinforcement Tuning examples on Vertex.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- references: dict[str, str] | None¶
- class genai.types.ReinforcementTuningExampleDict¶
Bases:
TypedDictUser-facing format for Gemini Reinforcement Tuning examples on Vertex.
- contents: list[ContentDict] | None¶
Multi-turn contents that represents the Prompt.
- references: dict[str, str] | None¶
References for the given prompt. The key is the name of the reference, and the value is the reference itself.
- system_instruction: ContentDict | None¶
Corresponds to system_instruction in user-facing GenerateContentRequest.
- class genai.types.ReinforcementTuningHyperParameters(**data)¶
Bases:
BaseModelHyperparameters for Reinforcement Tuning.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- adapter_size: AdapterSize | None¶
- batch_size: int | None¶
- checkpoint_interval: int | None¶
- epoch_count: int | None¶
- evaluate_interval: int | None¶
- learning_rate_multiplier: float | None¶
- max_output_tokens: int | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- samples_per_prompt: int | None¶
- step_count: int | None¶
- thinking_budget: int | None¶
- thinking_level: ReinforcementTuningThinkingLevel | None¶
- class genai.types.ReinforcementTuningHyperParametersDict¶
Bases:
TypedDictHyperparameters for Reinforcement Tuning.
- adapter_size: AdapterSize | None¶
Optional. Adapter size for Reinforcement Tuning.
- batch_size: int | None¶
Optional. Batch size for the tuning job. How many prompts to process at a train step. If not set, the batch size will be determined automatically.
- checkpoint_interval: int | None¶
Optional. How often at steps to save checkpoints during training. If not set, one checkpoint per epoch will be set.
`total_steps = epoch_count * samples_per_prompt / total_prompts_in_dataset`
- epoch_count: int | None¶
Optional. Number of training epoches for the tuning job.
- evaluate_interval: int | None¶
Optional. How often at steps to evaluate the tuning job during training. If not set, evel will be run per epoch. total_steps = epoch_count * samples_per_prompt / total_prompts_in_dataset
- learning_rate_multiplier: float | None¶
Learning rate multiplier for Reinforcement Learning.
- max_output_tokens: int | None¶
Optional. The maximum number of tokens to generate per prompt. Default to 32768.
- samples_per_prompt: int | None¶
Optional. Number of different responses to generate per prompt during tuning.
- step_count: int | None¶
Optional. Number of steps for the tuning job (mutually exclusive with epoch_count).
- thinking_budget: int | None¶
Optional. The thinking budget for the tuning job to optimize for (Gemini 2.5 only). * -1 means dynamic thinking * 0 means no thinking * > 0 means thinking budget in tokens If not set, default to -1 (dynamic thinking).
- thinking_level: ReinforcementTuningThinkingLevel | None¶
Indicates the maximum thinking depth during tuning. Starting from Gemini 3.5 models, the old thinking_budget will no longer be supported and will result in a user error if set. Instead, users should use the thinking_level parameter to control the maximum thinking depth.
- class genai.types.ReinforcementTuningParseResponseConfig(**data)¶
Bases:
BaseModelDefines how to parse sample response config for reinforcement tuning.
The parsed response (i.e., substring) will be passed to the reward functions. For example, the input prompt might be: > “Perform step-by-step thoughts first to problem A, finally output answer in the <ans> </ans> block.” The sample response from the model under tuning might look like: > “<ans>Yes</ans>” Here, users can define the following parse config:
` { "parseType": "REGEX_EXTRACT", "regexExtractExpression": ".*(.*?)" } `The resulting parsed response would be “Yes” and will be passed to the reward functions for evaluating rewards. This data type is not supported in Gemini API.Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- parse_type: ResponseParseType | None¶
- regex_extract_expression: str | None¶
- class genai.types.ReinforcementTuningParseResponseConfigDict¶
Bases:
TypedDictDefines how to parse sample response config for reinforcement tuning.
The parsed response (i.e., substring) will be passed to the reward functions. For example, the input prompt might be: > “Perform step-by-step thoughts first to problem A, finally output answer in the <ans> </ans> block.” The sample response from the model under tuning might look like: > “<ans>Yes</ans>” Here, users can define the following parse config:
` { "parseType": "REGEX_EXTRACT", "regexExtractExpression": ".*(.*?)" } `The resulting parsed response would be “Yes” and will be passed to the reward functions for evaluating rewards. This data type is not supported in Gemini API.- parse_type: ResponseParseType | None¶
Defines the type for parsing sample response.
- regex_extract_expression: str | None¶
Defines the regex for extracting the important part of sample response. This field is only used when parse_type is ResponseParseType.REGEX_EXTRACT.
- class genai.types.ReinforcementTuningRewardInfo(**data)¶
Bases:
BaseModelThe reward info for a reward function.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- error_status: GoogleRpcStatus | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- reward: float | None¶
- user_requested_aux_info: str | None¶
- class genai.types.ReinforcementTuningRewardInfoDict¶
Bases:
TypedDictThe reward info for a reward function.
- error_status: GoogleRpcStatusDict | None¶
Output only. In case of an error for this reward, this field will be populated with a detailed error status.
- reward: float | None¶
Output only. The calculated reward for the reward function.
- user_requested_aux_info: str | None¶
Output only. The user-requested auxiliary info for the reward function. This field is set only if the Cloud Run reward function configured by user returns a “user_requested_aux_info”. Refer to ReinforcementTuningCloudRunRewardScorer for more details.
- class genai.types.ReinforcementTuningSpec(**data)¶
Bases:
BaseModelReinforcement tuning spec for tuning.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- composite_reward_config: CompositeReinforcementTuningRewardConfig | None¶
- hyper_parameters: ReinforcementTuningHyperParameters | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- single_reward_config: SingleReinforcementTuningRewardConfig | None¶
- training_dataset_uri: str | None¶
- validation_dataset_uri: str | None¶
- class genai.types.ReinforcementTuningSpecDict¶
Bases:
TypedDictReinforcement tuning spec for tuning.
- composite_reward_config: CompositeReinforcementTuningRewardConfigDict | None¶
Composite reward function configuration for reinforcement tuning.
- hyper_parameters: ReinforcementTuningHyperParametersDict | None¶
Additional hyper-parameters to use during tuning.
- single_reward_config: SingleReinforcementTuningRewardConfigDict | None¶
Single reward function configuration for reinforcement tuning.
- training_dataset_uri: str | None¶
Cloud Storage path to the file containing training dataset for tuning. The dataset must be formatted as a JSONL file.
- validation_dataset_uri: str | None¶
Cloud Storage path to the file containing validation dataset for tuning. The dataset must be formatted as a JSONL file.
- class genai.types.ReinforcementTuningStringMatchRewardScorer(**data)¶
Bases:
BaseModelReinforcementTuningStringMatchRewardScorer is used to score parsed responses for string matching use cases.
For example, for math problems, users can use string match scorer to check if the correct exact answer is generated. Note: Reward returned by the string match reward function is clipped to be within [-1, 1] if wrongAnswerReward or correctAnswerReward are beyond the range, i.e., reward = max(min(reward, 1.0), -1.0). This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- correct_answer_reward: float | None¶
- json_match_expression: ReinforcementTuningStringMatchRewardScorerJsonMatchExpression | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- string_match_expression: ReinforcementTuningStringMatchRewardScorerStringMatchExpression | None¶
- wrong_answer_reward: float | None¶
- class genai.types.ReinforcementTuningStringMatchRewardScorerDict¶
Bases:
TypedDictReinforcementTuningStringMatchRewardScorer is used to score parsed responses for string matching use cases.
For example, for math problems, users can use string match scorer to check if the correct exact answer is generated. Note: Reward returned by the string match reward function is clipped to be within [-1, 1] if wrongAnswerReward or correctAnswerReward are beyond the range, i.e., reward = max(min(reward, 1.0), -1.0). This data type is not supported in Gemini API.
- correct_answer_reward: float | None¶
Correct answer rewawrd is returned if the parsed response is evaluated as true. All correct answers get the same reward.
- json_match_expression: ReinforcementTuningStringMatchRewardScorerJsonMatchExpressionDict | None¶
Uses json match expression to evaluate parsed response.
- string_match_expression: ReinforcementTuningStringMatchRewardScorerStringMatchExpressionDict | None¶
Uses string match expression to evaluate parsed response.
- wrong_answer_reward: float | None¶
Wrong answer reward is returned if the parsed response is evaluated as false. All wrong answers get the same reward.
- class genai.types.ReinforcementTuningStringMatchRewardScorerJsonMatchExpression(**data)¶
Bases:
BaseModelJsonMatchExpression supports converting the parsed responses to JSON format, finding the value in the JSON response that matches the key_name in the first level, and performing StringMatchExpression operation on the matched JSON value.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- key_name: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- value_string_match_expression: ReinforcementTuningStringMatchRewardScorerStringMatchExpression | None¶
- class genai.types.ReinforcementTuningStringMatchRewardScorerJsonMatchExpressionDict¶
Bases:
TypedDictJsonMatchExpression supports converting the parsed responses to JSON format, finding the value in the JSON response that matches the key_name in the first level, and performing StringMatchExpression operation on the matched JSON value.
This data type is not supported in Gemini API.
- key_name: str | None¶
The key name to find the value in the parsed response that’s in JSON format. Only first-level key matching is supported.
- value_string_match_expression: ReinforcementTuningStringMatchRewardScorerStringMatchExpressionDict | None¶
String match expression to match against the extracted value from the JSON representation of the parsed response.
- class genai.types.ReinforcementTuningStringMatchRewardScorerStringMatchExpression(**data)¶
Bases:
BaseModelEvaluates parsed response using match type against the expression.
Returns true if MatchOperation(target, expression) evaluates to true, and false otherwise. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- expression: str | None¶
- match_operation: MatchOperation | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ReinforcementTuningStringMatchRewardScorerStringMatchExpressionDict¶
Bases:
TypedDictEvaluates parsed response using match type against the expression.
Returns true if MatchOperation(target, expression) evaluates to true, and false otherwise. This data type is not supported in Gemini API.
- expression: str | None¶
` { "systemInstruction": ..., "contents": ..., "references": { "concise_answer": "Yes", "verbose_answer": "The answer is Yes" } } `and if users define the following StringMatchExpression: { “matchOperation”: “REGEX_CONTAINS”, “expression”: “.*{{references.concise_answer}}.*” } On evaluating the reward for each sample response, this StringMatchExpression will be substituted as:` { "matchOperation": "REGEX_CONTAINS", "expression": ".*Yes.*" } `- Type:
A string or a regular expression to match against for evaluating rewards. Users can also provide a references map of `{key
- Type:
value}` whose value will be used to replace the placeholder {{references.key}} in the expression. For example, if the following references are defined in the training / validation dataset
- match_operation: MatchOperation | None¶
Match operation to use for evaluating rewards.
- class genai.types.ReinforcementTuningThinkingLevel(*values)¶
Bases:
CaseInSensitiveEnumRepresents how much to think for the tuning job.
- HIGH = 'HIGH'¶
High thinking level.
- MINIMAL = 'MINIMAL'¶
Little to no thinking.
- REINFORCEMENT_TUNING_THINKING_LEVEL_UNSPECIFIED = 'REINFORCEMENT_TUNING_THINKING_LEVEL_UNSPECIFIED'¶
Unspecified thinking level.
- class genai.types.ReinforcementTuningUserDatasetExamples(**data)¶
Bases:
BaseModelSample reinforcement tuning user data in the training dataset.
The contents are truncated for better UI showing. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- user_dataset_examples: list[ReinforcementTuningExample] | None¶
- class genai.types.ReinforcementTuningUserDatasetExamplesDict¶
Bases:
TypedDictSample reinforcement tuning user data in the training dataset.
The contents are truncated for better UI showing. This data type is not supported in Gemini API.
- user_dataset_examples: list[ReinforcementTuningExampleDict] | None¶
List of user datasset examples showing to user.
- class genai.types.ReplayFile(**data)¶
Bases:
BaseModelRepresents a recorded session.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- interactions: list[ReplayInteraction] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- replay_id: str | None¶
- class genai.types.ReplayFileDict¶
Bases:
TypedDictRepresents a recorded session.
- interactions: list[ReplayInteractionDict] | None¶
- replay_id: str | None¶
- class genai.types.ReplayInteraction(**data)¶
Bases:
BaseModelRepresents a single interaction, request and response in a replay.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- request: ReplayRequest | None¶
- response: ReplayResponse | None¶
- class genai.types.ReplayInteractionDict¶
Bases:
TypedDictRepresents a single interaction, request and response in a replay.
- request: ReplayRequestDict | None¶
- response: ReplayResponseDict | None¶
- class genai.types.ReplayRequest(**data)¶
Bases:
BaseModelRepresents a single request in a replay.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- body_segments: list[dict[str, Any]] | None¶
- headers: dict[str, str] | None¶
- method: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- url: str | None¶
- class genai.types.ReplayRequestDict¶
Bases:
TypedDictRepresents a single request in a replay.
- body_segments: list[dict[str, Any]] | None¶
- headers: dict[str, str] | None¶
- method: str | None¶
- url: str | None¶
- class genai.types.ReplayResponse(**data)¶
Bases:
BaseModelRepresents a single response in a replay.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- body_segments: list[dict[str, Any]] | None¶
- headers: dict[str, str] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- sdk_response_segments: list[dict[str, Any]] | None¶
- status_code: int | None¶
- class genai.types.ReplayResponseDict¶
Bases:
TypedDictRepresents a single response in a replay.
- body_segments: list[dict[str, Any]] | None¶
- headers: dict[str, str] | None¶
- sdk_response_segments: list[dict[str, Any]] | None¶
- status_code: int | None¶
- class genai.types.ReplicatedVoiceConfig(**data)¶
Bases:
BaseModelThe configuration for the replicated voice to use.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- consent_audio: bytes | None¶
- mime_type: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- voice_consent_signature: VoiceConsentSignature | None¶
- voice_sample_audio: bytes | None¶
- class genai.types.ReplicatedVoiceConfigDict¶
Bases:
TypedDictThe configuration for the replicated voice to use.
- consent_audio: bytes | None¶
Recorded consent verifying ownership of the voice. This represents 16-bit signed little-endian wav data, with a 24kHz sampling rate.
- mime_type: str | None¶
The mimetype of the voice sample. The only currently supported value is audio/wav. This represents 16-bit signed little-endian wav data, with a 24kHz sampling rate.
- voice_consent_signature: VoiceConsentSignatureDict | None¶
Signature of a previously verified consent audio. This should be populated with a signature generated by the server for a previous request containing the consent_audio field. When provided, the signature is verified instead of the consent_audio field to reduce latency. Requests will fail if the signature is invalid or expired.
- voice_sample_audio: bytes | None¶
The sample of the custom voice.
- class genai.types.ResourceScope(*values)¶
Bases:
CaseInSensitiveEnumResource scope.
- COLLECTION = 'COLLECTION'¶
When setting base_url, this value configures resource scope to be the collection. The resource name will not include api version, project, or location. For example, if base_url is set to “https://aiplatform.googleapis.com”, then the resource name for a Model would be “https://aiplatform.googleapis.com/publishers/google/models/gemini-3-pro-preview
- class genai.types.ResponseFormat(**data)¶
Bases:
BaseModelConfiguration for the model to configure output formatting and delivery.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- audio: AudioResponseFormat | None¶
- image: ImageResponseFormat | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- text: TextResponseFormat | None¶
- video: VideoResponseFormat | None¶
- class genai.types.ResponseFormatDict¶
Bases:
TypedDictConfiguration for the model to configure output formatting and delivery.
This data type is not supported in Gemini API.
- audio: AudioResponseFormatDict | None¶
Audio output format.
- image: ImageResponseFormatDict | None¶
Image output format.
- text: TextResponseFormatDict | None¶
Text output format.
- video: VideoResponseFormatDict | None¶
Video output format.
- class genai.types.ResponseParseType(*values)¶
Bases:
CaseInSensitiveEnumDefines the type for parsing sample response.
This enum is not supported in Gemini API.
- IDENTITY = 'IDENTITY'¶
Returns the sample response as is.
- REGEX_EXTRACT = 'REGEX_EXTRACT'¶
//cloud.google.com/bigquery/docs/reference/standard-sql/string_functions#regexp_extract) REGEX_EXTRACT(response, regex_extract_expression), but different in that if there are multiple matches, the last match will be returned.
- Type:
Uses regex to extract the important part of sample response. Similar to [GoogleSQL](https
- RESPONSE_PARSE_TYPE_UNSPECIFIED = 'RESPONSE_PARSE_TYPE_UNSPECIFIED'¶
Default value. Fallback to IDENTITY
- class genai.types.Retrieval(**data)¶
Bases:
BaseModelDefines a retrieval tool that model can call to access external knowledge.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- disable_attribution: bool | None¶
- external_api: ExternalApi | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- vertex_ai_search: VertexAISearch | None¶
- vertex_rag_store: VertexRagStore | None¶
- class genai.types.RetrievalConfig(**data)¶
Bases:
BaseModelRetrieval config.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- language_code: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.RetrievalConfigDict¶
Bases:
TypedDictRetrieval config.
- language_code: str | None¶
The language code of the user.
- lat_lng: LatLngDict | None¶
The location of the user.
- class genai.types.RetrievalDict¶
Bases:
TypedDictDefines a retrieval tool that model can call to access external knowledge.
This data type is not supported in Gemini API.
- disable_attribution: bool | None¶
Optional. Deprecated. This option is no longer supported.
- external_api: ExternalApiDict | None¶
Use data source powered by external API for grounding.
- vertex_ai_search: VertexAISearchDict | None¶
Set to use data source powered by Vertex AI Search.
- vertex_rag_store: VertexRagStoreDict | None¶
Set to use data source powered by Vertex RAG store. User data is uploaded via the VertexRagDataService.
- class genai.types.RetrievalMetadata(**data)¶
Bases:
BaseModelMetadata returned to client when grounding is enabled.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- google_search_dynamic_retrieval_score: float | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.RetrievalMetadataDict¶
Bases:
TypedDictMetadata returned to client when grounding is enabled.
- google_search_dynamic_retrieval_score: float | None¶
Optional. Score indicating how likely information from google search could help answer the prompt. The score is in the range [0, 1], where 0 is the least likely and 1 is the most likely. This score is only populated when google search grounding and dynamic retrieval is enabled. It will be compared to the threshold to determine whether to trigger Google search.
- class genai.types.RougeMetricValue(**data)¶
Bases:
BaseModelRouge metric value for an instance.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- score: float | None¶
- class genai.types.RougeMetricValueDict¶
Bases:
TypedDictRouge metric value for an instance.
This data type is not supported in Gemini API.
- score: float | None¶
Output only. Rouge score.
- class genai.types.RougeSpec(**data)¶
Bases:
BaseModelSpec for rouge metric.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- rouge_type: str | None¶
- split_summaries: bool | None¶
- use_stemmer: bool | None¶
- class genai.types.RougeSpecDict¶
Bases:
TypedDictSpec for rouge metric.
- rouge_type: str | None¶
Optional. Supported rouge types are rougen[1-9], rougeL, and rougeLsum.
- split_summaries: bool | None¶
Optional. Whether to split summaries while using rougeLsum.
- use_stemmer: bool | None¶
Optional. Whether to use stemmer to compute rouge score.
- class genai.types.RubricContentType(*values)¶
Bases:
CaseInSensitiveEnumRepresents the rubric content type.
- NL_QUESTION_ANSWER = 'NL_QUESTION_ANSWER'¶
Generate rubrics in an NL question answer format.
- PROPERTY = 'PROPERTY'¶
Generate rubrics based on properties.
- PYTHON_CODE_ASSERTION = 'PYTHON_CODE_ASSERTION'¶
Generate rubrics in a unit test format.
- RUBRIC_CONTENT_TYPE_UNSPECIFIED = 'RUBRIC_CONTENT_TYPE_UNSPECIFIED'¶
Rubric content type is unspecified.
- class genai.types.RubricGenerationSpec(**data)¶
Bases:
BaseModelSpecification for how rubrics should be generated.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- prompt_template: str | None¶
- rubric_content_type: RubricContentType | None¶
- rubric_type_ontology: list[str] | None¶
- class genai.types.RubricGenerationSpecDict¶
Bases:
TypedDictSpecification for how rubrics should be generated.
- prompt_template: str | None¶
Template for the prompt used to generate rubrics.
- rubric_content_type: RubricContentType | None¶
The type of rubric content to be generated.
- rubric_type_ontology: list[str] | None¶
An optional, pre-defined list of allowed types for generated rubrics. If this field is provided, it implies include_rubric_type should be true, and the generated rubric types should be chosen from this ontology.
- class genai.types.SafetyAttributes(**data)¶
Bases:
BaseModelSafety attributes of a GeneratedImage or the user-provided prompt.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- categories: list[str] | None¶
- content_type: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- scores: list[float] | None¶
- class genai.types.SafetyAttributesDict¶
Bases:
TypedDictSafety attributes of a GeneratedImage or the user-provided prompt.
- categories: list[str] | None¶
List of RAI categories.
- content_type: str | None¶
Internal use only.
- scores: list[float] | None¶
List of scores of each categories.
- class genai.types.SafetyFilterLevel(*values)¶
Bases:
CaseInSensitiveEnumEnum that controls the safety filter level for objectionable content.
- BLOCK_LOW_AND_ABOVE = 'BLOCK_LOW_AND_ABOVE'¶
- BLOCK_MEDIUM_AND_ABOVE = 'BLOCK_MEDIUM_AND_ABOVE'¶
- BLOCK_NONE = 'BLOCK_NONE'¶
- BLOCK_ONLY_HIGH = 'BLOCK_ONLY_HIGH'¶
- class genai.types.SafetyPolicy¶
Bases:
CaseInSensitiveEnum- ACCOUNT_CREATION = 'ACCOUNT_CREATION'¶
Account creation safety policy.
- COMMUNICATION_TOOL = 'COMMUNICATION_TOOL'¶
Communication tool safety policy.
- DATA_MODIFICATION = 'DATA_MODIFICATION'¶
Data modification safety policy.
- FINANCIAL_TRANSACTIONS = 'FINANCIAL_TRANSACTIONS'¶
Financial transactions safety policy.
- LEGAL_TERMS_AND_AGREEMENTS = 'LEGAL_TERMS_AND_AGREEMENTS'¶
Legal terms and agreements safety policy.
- SAFETY_POLICY_UNSPECIFIED = 'SAFETY_POLICY_UNSPECIFIED'¶
Unspecified safety policy. This value should not be used.
- SENSITIVE_DATA_MODIFICATION = 'SENSITIVE_DATA_MODIFICATION'¶
Sensitive data modification safety policy.
- USER_CONSENT_MANAGEMENT = 'USER_CONSENT_MANAGEMENT'¶
User consent management safety policy.
- class genai.types.SafetyRating(**data)¶
Bases:
BaseModelA safety rating for a piece of content.
The safety rating contains the harm category and the harm probability level.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- blocked: bool | None¶
- category: HarmCategory | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- overwritten_threshold: HarmBlockThreshold | None¶
- probability: HarmProbability | None¶
- probability_score: float | None¶
- severity: HarmSeverity | None¶
- severity_score: float | None¶
- class genai.types.SafetyRatingDict¶
Bases:
TypedDictA safety rating for a piece of content.
The safety rating contains the harm category and the harm probability level.
- blocked: bool | None¶
Output only. Indicates whether the content was blocked because of this rating.
- category: HarmCategory | None¶
Output only. The harm category of this rating.
- overwritten_threshold: HarmBlockThreshold | None¶
Output only. The overwritten threshold for the safety category of Gemini 2.0 image out. If minors are detected in the output image, the threshold of each safety category will be overwritten if user sets a lower threshold. This field is not supported in Gemini API.
- probability: HarmProbability | None¶
Output only. The probability of harm for this category.
- probability_score: float | None¶
Output only. The probability score of harm for this category. This field is not supported in Gemini API.
- severity: HarmSeverity | None¶
Output only. The severity of harm for this category. This field is not supported in Gemini API.
- severity_score: float | None¶
Output only. The severity score of harm for this category. This field is not supported in Gemini API.
- class genai.types.SafetySetting(**data)¶
Bases:
BaseModelA safety setting that affects the safety-blocking behavior.
A SafetySetting consists of a harm category and a threshold for that category.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- category: HarmCategory | None¶
- method: HarmBlockMethod | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- threshold: HarmBlockThreshold | None¶
- class genai.types.SafetySettingDict¶
Bases:
TypedDictA safety setting that affects the safety-blocking behavior.
A SafetySetting consists of a harm category and a threshold for that category.
- category: HarmCategory | None¶
Required. The harm category to be blocked.
- method: HarmBlockMethod | None¶
Optional. The method for blocking content. If not specified, the default behavior is to use the probability score. This field is not supported in Gemini API.
- threshold: HarmBlockThreshold | None¶
Required. The threshold for blocking content. If the harm probability exceeds this threshold, the content will be blocked.
- class genai.types.Scale(*values)¶
Bases:
CaseInSensitiveEnumScale of the generated music.
- A_FLAT_MAJOR_F_MINOR = 'A_FLAT_MAJOR_F_MINOR'¶
Ab major or F minor.
- A_MAJOR_G_FLAT_MINOR = 'A_MAJOR_G_FLAT_MINOR'¶
A major or Gb minor.
- B_FLAT_MAJOR_G_MINOR = 'B_FLAT_MAJOR_G_MINOR'¶
Bb major or G minor.
- B_MAJOR_A_FLAT_MINOR = 'B_MAJOR_A_FLAT_MINOR'¶
B major or Ab minor.
- C_MAJOR_A_MINOR = 'C_MAJOR_A_MINOR'¶
C major or A minor.
- D_FLAT_MAJOR_B_FLAT_MINOR = 'D_FLAT_MAJOR_B_FLAT_MINOR'¶
Db major or Bb minor.
- D_MAJOR_B_MINOR = 'D_MAJOR_B_MINOR'¶
D major or B minor.
- E_FLAT_MAJOR_C_MINOR = 'E_FLAT_MAJOR_C_MINOR'¶
Eb major or C minor
- E_MAJOR_D_FLAT_MINOR = 'E_MAJOR_D_FLAT_MINOR'¶
E major or Db minor.
- F_MAJOR_D_MINOR = 'F_MAJOR_D_MINOR'¶
F major or D minor.
- G_FLAT_MAJOR_E_FLAT_MINOR = 'G_FLAT_MAJOR_E_FLAT_MINOR'¶
Gb major or Eb minor.
- G_MAJOR_E_MINOR = 'G_MAJOR_E_MINOR'¶
G major or E minor.
- SCALE_UNSPECIFIED = 'SCALE_UNSPECIFIED'¶
Default value. This value is unused.
- class genai.types.Schema(**data)¶
Bases:
BaseModelSchema is used to define the format of input/output data.
Represents a select subset of an [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema-object). More fields may be added in the future as needed.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- additional_properties: Any | None¶
- default: Any | None¶
- description: str | None¶
- enum: list[str] | None¶
- example: Any | None¶
- format: str | None¶
- classmethod from_json_schema(*, json_schema, api_option='GEMINI_API', raise_error_on_unsupported_field=False)¶
Converts a JSONSchema object to a Schema object.
Note: Conversion of fields that are not included in the JSONSchema class are ignored. Json Schema is now supported natively by both Gemini Enterprise Agent Platform and Gemini API. Users are recommended to pass/receive Json Schema directly to/from the API. For example: 1. the counter part of GenerateContentConfig.response_schema is
GenerateContentConfig.response_json_schema, which accepts [JSON
Schema](https://json-schema.org/)
the counter part of FunctionDeclaration.parameters is FunctionDeclaration.parameters_json_schema, which accepts [JSON Schema](https://json-schema.org/)
the counter part of FunctionDeclaration.response is FunctionDeclaration.response_json_schema, which accepts [JSON
- Schema](https://json-schema.org/)
The JSONSchema is compatible with 2020-12 JSON Schema draft, specified by OpenAPI 3.1.
- Args:
json_schema: JSONSchema object to be converted. api_option: API option to be used. If set to ‘VERTEX_AI’, the
JSONSchema will be converted to a Schema object that is compatible with Gemini Enterprise Agent Platform API. If set to ‘GEMINI_API’, the JSONSchema will be converted to a Schema object that is compatible with Gemini API. Default is ‘GEMINI_API’.
- raise_error_on_unsupported_field: If set to True, an error will be
raised if the JSONSchema contains any unsupported fields. Default is False.
- Returns:
Schema object that is compatible with the specified API option.
- Raises:
- ValueError: If the JSONSchema contains any unsupported fields and
raise_error_on_unsupported_field is set to True. Or if the JSONSchema is not compatible with the specified API option.
- Return type:
- property json_schema: JSONSchema¶
Converts the Schema object to a JSONSchema object, that is compatible with 2020-12 JSON Schema draft.
Note: Conversion of fields that are not included in the JSONSchema class are ignored. Json Schema is now supported natively by both Gemini Enterprise Agent Platform and Gemini API. Users are recommended to pass/receive Json Schema directly to/from the API. For example: 1. the counter part of GenerateContentConfig.response_schema is
GenerateContentConfig.response_json_schema, which accepts [JSON
Schema](https://json-schema.org/)
the counter part of FunctionDeclaration.parameters is FunctionDeclaration.parameters_json_schema, which accepts [JSON Schema](https://json-schema.org/)
the counter part of FunctionDeclaration.response is FunctionDeclaration.response_json_schema, which accepts [JSON
Schema](https://json-schema.org/)
- max_items: int | None¶
- max_length: int | None¶
- max_properties: int | None¶
- maximum: float | None¶
- min_items: int | None¶
- min_length: int | None¶
- min_properties: int | None¶
- minimum: float | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- nullable: bool | None¶
- pattern: str | None¶
- property_ordering: list[str] | None¶
- ref: str | None¶
- required: list[str] | None¶
- title: str | None¶
- class genai.types.SchemaDict¶
Bases:
TypedDictSchema is used to define the format of input/output data.
Represents a select subset of an [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema-object). More fields may be added in the future as needed.
- additional_properties: Any | None¶
Optional. Can either be a boolean or an object; controls the presence of additional properties.
- any_of: list[SchemaDict] | None¶
Optional. The instance must be valid against any (one or more) of the subschemas listed in any_of.
- default: Any | None¶
Optional. Default value to use if the field is not specified.
- defs: dict[str, SchemaDict] | None¶
Optional. A map of definitions for use by ref Only allowed at the root of the schema.
- description: str | None¶
Optional. Describes the data. The model uses this field to understand the purpose of the schema and how to use it. It is a best practice to provide a clear and descriptive explanation for the schema and its properties here, rather than in the prompt.
- enum: list[str] | None¶
{type:STRING, format:enum, enum:[“EAST”, “NORTH”, “SOUTH”, “WEST”]} 2. To define apartment numbers: {type:INTEGER, format:enum, enum:[“101”, “201”, “301”]}
- Type:
Optional. Possible values of the field. This field can be used to restrict a value to a fixed set of values. To mark a field as an enum, set format to enum and provide the list of possible values in enum. For example
- Type:
To define directions
- example: Any | None¶
Optional. Example of an instance of this schema.
- format: str | None¶
Optional. The format of the data. For NUMBER type, format can be float or double. For INTEGER type, format can be int32 or int64. For STRING type, format can be email, byte, date, date-time, password, and other formats to further refine the data type.
- max_items: int | None¶
Optional. If type is ARRAY, max_items specifies the maximum number of items in an array.
- max_length: int | None¶
Optional. If type is STRING, max_length specifies the maximum length of the string.
- max_properties: int | None¶
Optional. If type is OBJECT, max_properties specifies the maximum number of properties that can be provided.
- maximum: float | None¶
Optional. If type is INTEGER or NUMBER, maximum specifies the maximum allowed value.
- min_items: int | None¶
Optional. If type is ARRAY, min_items specifies the minimum number of items in an array.
- min_length: int | None¶
Optional. If type is STRING, min_length specifies the minimum length of the string.
- min_properties: int | None¶
Optional. If type is OBJECT, min_properties specifies the minimum number of properties that can be provided.
- minimum: float | None¶
Optional. If type is INTEGER or NUMBER, minimum specifies the minimum allowed value.
- nullable: bool | None¶
Optional. Indicates if the value of this field can be null.
- pattern: str | None¶
Optional. If type is STRING, pattern specifies a regular expression that the string must match.
- properties: dict[str, SchemaDict] | None¶
Optional. If type is OBJECT, properties is a map of property names to schema definitions for each property of the object.
- property_ordering: list[str] | None¶
Optional. Order of properties displayed or used where order matters. This is not a standard field in OpenAPI specification, but can be used to control the order of properties.
- ref: str | None¶
object properties: pet: ref: #/defs/Pet defs: Pet: type: object properties: name: type: string The value of the “pet” property is a reference to the schema node named “Pet”. See details in https://json-schema.org/understanding-json-schema/structuring
- Type:
Optional. Allows indirect references between schema nodes. The value should be a valid reference to a child of the root defs. For example, the following schema defines a reference to a schema node named “Pet”
- Type:
- required: list[str] | None¶
Optional. If type is OBJECT, required lists the names of properties that must be present.
- title: str | None¶
Optional. Title for the schema.
- class genai.types.ScribbleImage(**data)¶
Bases:
BaseModelAn image mask representing a brush scribble.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ScribbleImageDict¶
Bases:
TypedDictAn image mask representing a brush scribble.
- class genai.types.SearchEntryPoint(**data)¶
Bases:
BaseModelThe entry point used to search for grounding sources.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- rendered_content: str | None¶
- sdk_blob: bytes | None¶
- class genai.types.SearchEntryPointDict¶
Bases:
TypedDictThe entry point used to search for grounding sources.
- rendered_content: str | None¶
Optional. Web content snippet that can be embedded in a web page or an app webview.
- sdk_blob: bytes | None¶
Optional. JSON representing array of tuples.
- class genai.types.SearchTypes(**data)¶
Bases:
BaseModelDifferent types of search that can be enabled on the GoogleSearch tool.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- image_search: ImageSearch | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.SearchTypesDict¶
Bases:
TypedDictDifferent types of search that can be enabled on the GoogleSearch tool.
- image_search: ImageSearchDict | None¶
Optional. Setting this field enables image search. Image bytes are returned.
- web_search: WebSearchDict | None¶
Optional. Setting this field enables web search. Only text results are returned.
- class genai.types.Segment(**data)¶
Bases:
BaseModelSegment of the content this support belongs to.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- end_index: int | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- part_index: int | None¶
- start_index: int | None¶
- text: str | None¶
- class genai.types.SegmentDict¶
Bases:
TypedDictSegment of the content this support belongs to.
- end_index: int | None¶
Output only. End index in the given Part, measured in bytes.
Offset from the start of the Part, exclusive, starting at zero.
- part_index: int | None¶
Output only. The index of a Part object within its parent Content object.
- start_index: int | None¶
Output only. Start index in the given Part, measured in bytes.
Offset from the start of the Part, inclusive, starting at zero.
- text: str | None¶
Output only. The text corresponding to the segment from the response.
- class genai.types.SegmentImageConfig(**data)¶
Bases:
BaseModelConfiguration for segmenting an image.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- binary_color_threshold: float | None¶
- confidence_threshold: float | None¶
- http_options: HttpOptions | None¶
- labels: dict[str, str] | None¶
- mask_dilation: float | None¶
- max_predictions: int | None¶
- mode: SegmentMode | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.SegmentImageConfigDict¶
Bases:
TypedDictConfiguration for segmenting an image.
- binary_color_threshold: float | None¶
The binary color threshold to apply to the masks. The threshold can be set to a decimal value between 0 and 255 non-inclusive. Set to -1 for no binary color thresholding.
- confidence_threshold: float | None¶
The confidence score threshold for the detections as a decimal value. Only predictions with a confidence score higher than this threshold will be returned.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- labels: dict[str, str] | None¶
User specified labels to track billing usage.
- mask_dilation: float | None¶
A decimal value representing how much dilation to apply to the masks. 0 for no dilation. 1.0 means the masked area covers the whole image.
- max_predictions: int | None¶
The maximum number of predictions to return up to, by top confidence score.
- mode: SegmentMode | None¶
The segmentation mode to use.
- class genai.types.SegmentImageResponse(**data)¶
Bases:
BaseModelThe output images response.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- generated_masks: list[GeneratedImageMask] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.SegmentImageResponseDict¶
Bases:
TypedDictThe output images response.
- generated_masks: list[GeneratedImageMaskDict] | None¶
List of generated image masks.
- class genai.types.SegmentImageSource(**data)¶
Bases:
BaseModelA set of source input(s) for image segmentation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- prompt: str | None¶
- scribble_image: ScribbleImage | None¶
- class genai.types.SegmentImageSourceDict¶
Bases:
TypedDictA set of source input(s) for image segmentation.
- prompt: str | None¶
A text prompt for guiding the model during image segmentation. Required for prompt mode and semantic mode, disallowed for other modes.
- scribble_image: ScribbleImageDict | None¶
The brush scribble to guide segmentation. Required for the interactive mode, disallowed for other modes.
- class genai.types.SegmentMode(*values)¶
Bases:
CaseInSensitiveEnumEnum that represents the segmentation mode.
- BACKGROUND = 'BACKGROUND'¶
- FOREGROUND = 'FOREGROUND'¶
- INTERACTIVE = 'INTERACTIVE'¶
- PROMPT = 'PROMPT'¶
- SEMANTIC = 'SEMANTIC'¶
- class genai.types.ServiceTier(*values)¶
Bases:
CaseInSensitiveEnumPricing and performance service tier.
- FLEX = 'flex'¶
Flex service tier.
- PRIORITY = 'priority'¶
Priority service tier.
- STANDARD = 'standard'¶
Standard service tier.
- UNSPECIFIED = 'unspecified'¶
Default service tier, which is standard.
- class genai.types.SessionResumptionConfig(**data)¶
Bases:
BaseModelConfiguration of session resumption mechanism.
Included in LiveConnectConfig.session_resumption. If included server will send LiveServerSessionResumptionUpdate messages.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- handle: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- transparent: bool | None¶
- class genai.types.SessionResumptionConfigDict¶
Bases:
TypedDictConfiguration of session resumption mechanism.
Included in LiveConnectConfig.session_resumption. If included server will send LiveServerSessionResumptionUpdate messages.
- handle: str | None¶
Session resumption handle of previous session (session to restore).
If not present new session will be started.
- transparent: bool | None¶
If set the server will send last_consumed_client_message_index in the session_resumption_update messages to allow for transparent reconnections.
- class genai.types.SingleEmbedContentResponse(**data)¶
Bases:
BaseModelConfig for response parameter.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- embedding: ContentEmbedding | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- token_count: int | None¶
- class genai.types.SingleEmbedContentResponseDict¶
Bases:
TypedDictConfig for response parameter.
- embedding: ContentEmbeddingDict | None¶
The response to the request.
- token_count: int | None¶
The error encountered while processing the request.
- class genai.types.SingleReinforcementTuningRewardConfig(**data)¶
Bases:
BaseModelSingle reinforcement tuning reward config.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- autorater_scorer: ReinforcementTuningAutoraterScorer | None¶
- cloud_run_reward_scorer: ReinforcementTuningCloudRunRewardScorer | None¶
- code_execution_reward_scorer: ReinforcementTuningCodeExecutionRewardScorer | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- parse_response_config: ReinforcementTuningParseResponseConfig | None¶
- reward_name: str | None¶
- string_match_reward_scorer: ReinforcementTuningStringMatchRewardScorer | None¶
- class genai.types.SingleReinforcementTuningRewardConfigDict¶
Bases:
TypedDictSingle reinforcement tuning reward config.
- autorater_scorer: ReinforcementTuningAutoraterScorerDict | None¶
Scores parsed responses for autorater use cases by using a model to compute the reward.
- cloud_run_reward_scorer: ReinforcementTuningCloudRunRewardScorerDict | None¶
ReinforcementTuningCloudRunRewardScorer is used to score parsed responses by calling a Cloud Run service.
- code_execution_reward_scorer: ReinforcementTuningCodeExecutionRewardScorerDict | None¶
ReinforcementTuningCodeExecutionRewardScorer is used to score parsed responses for code execution use cases.
- parse_response_config: ReinforcementTuningParseResponseConfigDict | None¶
Defines how to parse sample response. For example, given a sample response for evaluating the reward, users might want to extract the text only between `` and `` in the sample response, and keeps only the last one in case there are multiple such tags. To achieve such a purpose, they can define a regex “.*(.*?)” using the ReinforcementTuningParseResponseConfig.ResponseParseType.REGEX_EXTRACT parse type.
- reward_name: str | None¶
A unique reward name for identifying each single reinforcement tuning reward.
- string_match_reward_scorer: ReinforcementTuningStringMatchRewardScorerDict | None¶
ReinforcementTuningStringMatchRewardScorer is used to score parsed responses for simple string matching use cases against reference answers.
- class genai.types.SlidingWindow(**data)¶
Bases:
BaseModelContext window will be truncated by keeping only suffix of it.
Context window will always be cut at start of USER role turn. System instructions and BidiGenerateContentSetup.prefix_turns will not be subject to the sliding window mechanism, they will always stay at the beginning of context window.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- target_tokens: int | None¶
- class genai.types.SlidingWindowDict¶
Bases:
TypedDictContext window will be truncated by keeping only suffix of it.
Context window will always be cut at start of USER role turn. System instructions and BidiGenerateContentSetup.prefix_turns will not be subject to the sliding window mechanism, they will always stay at the beginning of context window.
- target_tokens: int | None¶
Session reduction target – how many tokens we should keep. Window shortening operation has some latency costs, so we should avoid running it on every turn. Should be < trigger_tokens. If not set, trigger_tokens/2 is assumed.
- class genai.types.SpeakerVoiceConfig(**data)¶
Bases:
BaseModelConfiguration for a single speaker in a multi-speaker setup.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- speaker: str | None¶
- voice_config: VoiceConfig | None¶
- class genai.types.SpeakerVoiceConfigDict¶
Bases:
TypedDictConfiguration for a single speaker in a multi-speaker setup.
- speaker: str | None¶
Required. The name of the speaker. This should be the same as the speaker name used in the prompt.
- voice_config: VoiceConfigDict | None¶
Required. The configuration for the voice of this speaker.
- class genai.types.SpeechConfig(**data)¶
Bases:
BaseModelConfig for speech generation and transcription.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- language_code: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- multi_speaker_voice_config: MultiSpeakerVoiceConfig | None¶
- voice_config: VoiceConfig | None¶
- class genai.types.SpeechConfigDict¶
Bases:
TypedDictConfig for speech generation and transcription.
- language_code: str | None¶
Optional. The language code (ISO 639-1) for the speech synthesis.
- multi_speaker_voice_config: MultiSpeakerVoiceConfigDict | None¶
The configuration for a multi-speaker text-to-speech request. This field is mutually exclusive with voice_config.
- voice_config: VoiceConfigDict | None¶
The configuration in case of single-voice output.
- class genai.types.SpeechMetadata(**data)¶
Bases:
BaseModelExtra metadata associated with the part for speech synthesis.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- speaker: str | None¶
- style: str | None¶
- class genai.types.SpeechMetadataDict¶
Bases:
TypedDictExtra metadata associated with the part for speech synthesis.
- speaker: str | None¶
The speaker for this part, which must match a speaker name in MultiSpeakerVoiceConfig.speaker_voice_configs.
- style: str | None¶
The style instruction for how the voice should be synthesized (e.g. “excited, fast-paced”).
- class genai.types.StartSensitivity(*values)¶
Bases:
CaseInSensitiveEnumStart of speech sensitivity.
- START_SENSITIVITY_HIGH = 'START_SENSITIVITY_HIGH'¶
Automatic detection will detect the start of speech more often.
- START_SENSITIVITY_LOW = 'START_SENSITIVITY_LOW'¶
Automatic detection will detect the start of speech less often.
- START_SENSITIVITY_UNSPECIFIED = 'START_SENSITIVITY_UNSPECIFIED'¶
The default is START_SENSITIVITY_LOW for Gemini Enterprise Agent Platform and START_SENSITIVITY_HIGH for Gemini Live.
- class genai.types.StreamableHttpTransport(**data)¶
Bases:
BaseModelA transport that can stream HTTP requests and responses.
Next ID: 6. This data type is not supported in Vertex AI.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- headers: dict[str, str] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- sse_read_timeout: str | None¶
- terminate_on_close: bool | None¶
- timeout: str | None¶
- url: str | None¶
- class genai.types.StreamableHttpTransportDict¶
Bases:
TypedDictA transport that can stream HTTP requests and responses.
Next ID: 6. This data type is not supported in Vertex AI.
- headers: dict[str, str] | None¶
Fields for authentication headers, timeouts, etc., if needed.
- Type:
Optional
- sse_read_timeout: str | None¶
Timeout for SSE read operations.
- terminate_on_close: bool | None¶
Whether to close the client session when the transport closes.
- timeout: str | None¶
HTTP timeout for regular operations.
- url: str | None¶
//api.example.com/mcp”.
- Type:
The full URL for the MCPServer endpoint. Example
- Type:
“https
- class genai.types.StringList(**data)¶
Bases:
BaseModelUser provided string values assigned to a single metadata key.
This data type is not supported in Vertex AI.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- values: list[str] | None¶
- class genai.types.StringListDict¶
Bases:
TypedDictUser provided string values assigned to a single metadata key.
This data type is not supported in Vertex AI.
- class genai.types.StyleReferenceConfig(**data)¶
Bases:
BaseModelConfiguration for a Style reference image.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- style_description: str | None¶
- class genai.types.StyleReferenceConfigDict¶
Bases:
TypedDictConfiguration for a Style reference image.
- style_description: str | None¶
A text description of the style to use for the generated image.
- class genai.types.StyleReferenceImage(**data)¶
Bases:
BaseModelA style reference image.
This encapsulates a style reference image provided by the user, and additionally optional config parameters for the style reference image.
A raw reference image can also be provided as a destination for the style to be applied to.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- config: StyleReferenceConfig | None¶
Re-map config to style_reference_config to send to API.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- reference_id: int | None¶
- reference_type: str | None¶
- style_image_config: StyleReferenceConfig | None¶
- class genai.types.StyleReferenceImageDict¶
Bases:
TypedDictA style reference image.
This encapsulates a style reference image provided by the user, and additionally optional config parameters for the style reference image.
A raw reference image can also be provided as a destination for the style to be applied to.
- config: StyleReferenceConfigDict | None¶
Configuration for the style reference image.
- reference_id: int | None¶
The id of the reference image.
- reference_type: str | None¶
The type of the reference image. Only set by the SDK.
- class genai.types.SubjectReferenceConfig(**data)¶
Bases:
BaseModelConfiguration for a Subject reference image.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- subject_description: str | None¶
- subject_type: SubjectReferenceType | None¶
- class genai.types.SubjectReferenceConfigDict¶
Bases:
TypedDictConfiguration for a Subject reference image.
- subject_description: str | None¶
Subject description for the image.
- subject_type: SubjectReferenceType | None¶
The subject type of a subject reference image.
- class genai.types.SubjectReferenceImage(**data)¶
Bases:
BaseModelA subject reference image.
This encapsulates a subject reference image provided by the user, and additionally optional config parameters for the subject reference image.
A raw reference image can also be provided as a destination for the subject to be applied to.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- config: SubjectReferenceConfig | None¶
Re-map config to subject_reference_config to send to API.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- reference_id: int | None¶
- reference_type: str | None¶
- subject_image_config: SubjectReferenceConfig | None¶
- class genai.types.SubjectReferenceImageDict¶
Bases:
TypedDictA subject reference image.
This encapsulates a subject reference image provided by the user, and additionally optional config parameters for the subject reference image.
A raw reference image can also be provided as a destination for the subject to be applied to.
- config: SubjectReferenceConfigDict | None¶
Configuration for the subject reference image.
- reference_id: int | None¶
The id of the reference image.
- reference_type: str | None¶
The type of the reference image. Only set by the SDK.
- class genai.types.SubjectReferenceType(*values)¶
Bases:
CaseInSensitiveEnumEnum representing the subject type of a subject reference image.
- SUBJECT_TYPE_ANIMAL = 'SUBJECT_TYPE_ANIMAL'¶
- SUBJECT_TYPE_DEFAULT = 'SUBJECT_TYPE_DEFAULT'¶
- SUBJECT_TYPE_PERSON = 'SUBJECT_TYPE_PERSON'¶
- SUBJECT_TYPE_PRODUCT = 'SUBJECT_TYPE_PRODUCT'¶
- class genai.types.SupervisedHyperParameters(**data)¶
Bases:
BaseModelHyperparameters for SFT. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- adapter_size: AdapterSize | None¶
- batch_size: int | None¶
- epoch_count: int | None¶
- learning_rate: float | None¶
- learning_rate_multiplier: float | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.SupervisedHyperParametersDict¶
Bases:
TypedDictHyperparameters for SFT. This data type is not supported in Gemini API.
- adapter_size: AdapterSize | None¶
Optional. Adapter size for tuning.
- batch_size: int | None¶
Optional. Batch size for tuning. This feature is only available for open source models.
- epoch_count: int | None¶
Optional. Number of complete passes the model makes over the entire training dataset during training.
- learning_rate: float | None¶
Optional. Learning rate for tuning. Mutually exclusive with learning_rate_multiplier. This feature is only available for open source models.
- learning_rate_multiplier: float | None¶
Optional. Multiplier for adjusting the default learning rate. Mutually exclusive with learning_rate. This feature is only available for 1P models.
- class genai.types.SupervisedTuningDataStats(**data)¶
Bases:
BaseModelTuning data statistics for Supervised Tuning.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- dropped_example_reasons: list[str] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- total_billable_character_count: int | None¶
- total_billable_token_count: int | None¶
- total_truncated_example_count: int | None¶
- total_tuning_character_count: int | None¶
- truncated_example_indices: list[int] | None¶
- tuning_dataset_example_count: int | None¶
- tuning_step_count: int | None¶
- user_input_token_distribution: SupervisedTuningDatasetDistribution | None¶
- user_message_per_example_distribution: SupervisedTuningDatasetDistribution | None¶
- user_output_token_distribution: SupervisedTuningDatasetDistribution | None¶
- class genai.types.SupervisedTuningDataStatsDict¶
Bases:
TypedDictTuning data statistics for Supervised Tuning.
This data type is not supported in Gemini API.
- dropped_example_reasons: list[str] | None¶
Output only. For each index in truncated_example_indices, the user-facing reason why the example was dropped.
- total_billable_character_count: int | None¶
Output only. Number of billable characters in the tuning dataset.
- total_billable_token_count: int | None¶
Output only. Number of billable tokens in the tuning dataset.
- total_truncated_example_count: int | None¶
too many tokens, contains an invalid image, contains too many images, etc.
- Type:
Output only. The number of examples in the dataset that have been dropped. An example can be dropped for reasons including
- total_tuning_character_count: int | None¶
Output only. Number of tuning characters in the tuning dataset.
- truncated_example_indices: list[int] | None¶
Output only. A partial sample of the indices (starting from 1) of the dropped examples.
- tuning_dataset_example_count: int | None¶
Output only. Number of examples in the tuning dataset.
- tuning_step_count: int | None¶
Output only. Number of tuning steps for this Tuning Job.
- user_dataset_examples: list[ContentDict] | None¶
Output only. Sample user messages in the training dataset uri.
- user_input_token_distribution: SupervisedTuningDatasetDistributionDict | None¶
Output only. Dataset distributions for the user input tokens.
- user_message_per_example_distribution: SupervisedTuningDatasetDistributionDict | None¶
Output only. Dataset distributions for the messages per example.
- user_output_token_distribution: SupervisedTuningDatasetDistributionDict | None¶
Output only. Dataset distributions for the user output tokens.
- class genai.types.SupervisedTuningDatasetDistribution(**data)¶
Bases:
BaseModelDataset distribution for Supervised Tuning.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- billable_sum: int | None¶
- buckets: list[SupervisedTuningDatasetDistributionDatasetBucket] | None¶
- max: float | None¶
- mean: float | None¶
- median: float | None¶
- min: float | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- p5: float | None¶
- p95: float | None¶
- sum: int | None¶
- class genai.types.SupervisedTuningDatasetDistributionDatasetBucket(**data)¶
Bases:
BaseModelDataset bucket used to create a histogram for the distribution given a population of values.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- count: float | None¶
- left: float | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- right: float | None¶
- class genai.types.SupervisedTuningDatasetDistributionDatasetBucketDict¶
Bases:
TypedDictDataset bucket used to create a histogram for the distribution given a population of values.
This data type is not supported in Gemini API.
- count: float | None¶
Output only. Number of values in the bucket.
- left: float | None¶
Output only. Left bound of the bucket.
- right: float | None¶
Output only. Right bound of the bucket.
- class genai.types.SupervisedTuningDatasetDistributionDict¶
Bases:
TypedDictDataset distribution for Supervised Tuning.
This data type is not supported in Gemini API.
- billable_sum: int | None¶
Output only. Sum of a given population of values that are billable.
- buckets: list[SupervisedTuningDatasetDistributionDatasetBucketDict] | None¶
Output only. Defines the histogram bucket.
- max: float | None¶
Output only. The maximum of the population values.
- mean: float | None¶
Output only. The arithmetic mean of the values in the population.
- median: float | None¶
Output only. The median of the values in the population.
- min: float | None¶
Output only. The minimum of the population values.
- p5: float | None¶
Output only. The 5th percentile of the values in the population.
- p95: float | None¶
Output only. The 95th percentile of the values in the population.
- sum: int | None¶
Output only. Sum of a given population of values.
- class genai.types.SupervisedTuningSpec(**data)¶
Bases:
BaseModelSupervised tuning spec for tuning.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- export_last_checkpoint_only: bool | None¶
- hyper_parameters: SupervisedHyperParameters | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- training_dataset_uri: str | None¶
- tuning_mode: TuningMode | None¶
- validation_dataset_uri: str | None¶
- class genai.types.SupervisedTuningSpecDict¶
Bases:
TypedDictSupervised tuning spec for tuning.
- export_last_checkpoint_only: bool | None¶
Optional. If set to true, disable intermediate checkpoints for SFT and only the last checkpoint will be exported. Otherwise, enable intermediate checkpoints for SFT. Default is false.
- hyper_parameters: SupervisedHyperParametersDict | None¶
Optional. Hyperparameters for SFT.
- training_dataset_uri: str | None¶
Required. Training dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.
- tuning_mode: TuningMode | None¶
Tuning mode.
- validation_dataset_uri: str | None¶
Optional. Validation dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.
- class genai.types.TestTableFile(**data)¶
Bases:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- comment: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- parameter_names: list[str] | None¶
- test_method: str | None¶
- test_table: list[TestTableItem] | None¶
- class genai.types.TestTableFileDict¶
Bases:
TypedDict- comment: str | None¶
- parameter_names: list[str] | None¶
- test_method: str | None¶
- test_table: list[TestTableItemDict] | None¶
- class genai.types.TestTableItem(**data)¶
Bases:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- exception_if_mldev: str | None¶
- exception_if_vertex: str | None¶
- has_union: bool | None¶
- ignore_keys: list[str] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str | None¶
- override_replay_id: str | None¶
- parameters: dict[str, Any] | None¶
- skip_in_api_mode: str | None¶
- class genai.types.TestTableItemDict¶
Bases:
TypedDict- exception_if_mldev: str | None¶
Expects an exception for MLDev matching the string.
- exception_if_vertex: str | None¶
Expects an exception for Vertex matching the string.
- has_union: bool | None¶
True if the parameters contain an unsupported union type. This test will be skipped for languages that do not support the union type.
- ignore_keys: list[str] | None¶
Keys to ignore when comparing the request and response. This is useful for tests that are not deterministic.
- name: str | None¶
The name of the test. This is used to derive the replay id.
- override_replay_id: str | None¶
Use if you don’t want to use the default replay id which is derived from the test name.
- parameters: dict[str, Any] | None¶
The parameters to the test. Use pydantic models.
- skip_in_api_mode: str | None¶
When set to a reason string, this test will be skipped in the API mode. Use this flag for tests that can not be reproduced with the real API. E.g. a test that deletes a resource.
- class genai.types.TextResponseFormat(**data)¶
Bases:
BaseModelConfiguration for text-specific output formatting.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- jsonSchema: Any | None¶
- mime_type: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.TextResponseFormatDict¶
Bases:
TypedDictConfiguration for text-specific output formatting.
- mime_type: str | None¶
Optional. The IANA standard MIME type of the response.
- schema: Any | None¶
Optional. The JSON schema that the output should conform to. Only applicable when mime_type is APPLICATION_JSON.
- class genai.types.ThinkingConfig(**data)¶
Bases:
BaseModelThe thinking features configuration.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- include_thoughts: bool | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- thinking_budget: int | None¶
- thinking_level: ThinkingLevel | None¶
- class genai.types.ThinkingConfigDict¶
Bases:
TypedDictThe thinking features configuration.
- include_thoughts: bool | None¶
Indicates whether to include thoughts in the response. If true, thoughts are returned only if the model supports thought and thoughts are available.
- thinking_budget: int | None¶
Indicates the thinking budget in tokens. 0 is DISABLED. -1 is AUTOMATIC. The default values and allowed ranges are model dependent.
- thinking_level: ThinkingLevel | None¶
Optional. The number of thoughts tokens that the model should generate.
- class genai.types.ThinkingLevel(*values)¶
Bases:
CaseInSensitiveEnumThe number of thoughts tokens that the model should generate.
- HIGH = 'HIGH'¶
High thinking level.
- LOW = 'LOW'¶
Low thinking level.
- MEDIUM = 'MEDIUM'¶
Medium thinking level.
- MINIMAL = 'MINIMAL'¶
MINIMAL thinking level.
- THINKING_LEVEL_UNSPECIFIED = 'THINKING_LEVEL_UNSPECIFIED'¶
Unspecified thinking level.
- class genai.types.TokensInfo(**data)¶
Bases:
BaseModelTokens info with a list of tokens and the corresponding list of token ids.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- role: str | None¶
- token_ids: list[int] | None¶
- tokens: list[bytes] | None¶
- class genai.types.TokensInfoDict¶
Bases:
TypedDictTokens info with a list of tokens and the corresponding list of token ids.
- role: str | None¶
Optional fields for the role from the corresponding Content.
- token_ids: list[int] | None¶
A list of token ids from the input.
- tokens: list[bytes] | None¶
A list of tokens from the input.
- class genai.types.Tool(**data)¶
Bases:
BaseModelTool details of a tool that the model may use to generate a response.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- code_execution: ToolCodeExecution | None¶
- computer_use: ComputerUse | None¶
- enterprise_web_search: EnterpriseWebSearch | None¶
- exa_ai_search: ToolExaAiSearch | None¶
- file_search: FileSearch | None¶
- function_declarations: list[FunctionDeclaration] | None¶
- google_maps: GoogleMaps | None¶
- google_search: GoogleSearch | None¶
- google_search_retrieval: GoogleSearchRetrieval | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- parallel_ai_search: ToolParallelAiSearch | None¶
- url_context: UrlContext | None¶
- class genai.types.ToolCall(**data)¶
Bases:
BaseModelA predicted server-side ToolCall returned from the model.
This message contains information about a tool that the model wants to invoke. The client is NOT expected to execute this ToolCall. Instead, the client should pass this ToolCall back to the API in a subsequent turn within a Content message, along with the corresponding ToolResponse.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- args: dict[str, Any] | None¶
- id: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ToolCallDict¶
Bases:
TypedDictA predicted server-side ToolCall returned from the model.
This message contains information about a tool that the model wants to invoke. The client is NOT expected to execute this ToolCall. Instead, the client should pass this ToolCall back to the API in a subsequent turn within a Content message, along with the corresponding ToolResponse.
- args: dict[str, Any] | None¶
“value1”, “arg2”: “value2”}.
- Type:
The tool call arguments. Example
- Type:
{“arg1”
- id: str | None¶
Unique identifier of the tool call. The server returns the tool response with the matching id.
- class genai.types.ToolCodeExecution(**data)¶
Bases:
BaseModelTool that executes code generated by the model, and automatically returns the result to the model.
See also ExecutableCode and CodeExecutionResult, which are input and output to this tool. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ToolCodeExecutionDict¶
Bases:
TypedDictTool that executes code generated by the model, and automatically returns the result to the model.
See also ExecutableCode and CodeExecutionResult, which are input and output to this tool. This data type is not supported in Gemini API.
- class genai.types.ToolConfig(**data)¶
Bases:
BaseModelTool config.
This config is shared for all tools provided in the request.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- function_calling_config: FunctionCallingConfig | None¶
- include_server_side_tool_invocations: bool | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- retrieval_config: RetrievalConfig | None¶
- class genai.types.ToolConfigDict¶
Bases:
TypedDictTool config.
This config is shared for all tools provided in the request.
- function_calling_config: FunctionCallingConfigDict | None¶
Optional. Function calling config.
- include_server_side_tool_invocations: bool | None¶
Optional. If true, the API response will include the server-side tool calls and responses within the Content message. This allows clients to observe the server’s tool interactions. This field is not supported in Vertex AI.
- retrieval_config: RetrievalConfigDict | None¶
Optional. Retrieval config.
- class genai.types.ToolDict¶
Bases:
TypedDictTool details of a tool that the model may use to generate a response.
- code_execution: ToolCodeExecutionDict | None¶
Optional. CodeExecution tool type. Enables the model to execute code as part of generation.
- computer_use: ComputerUseDict | None¶
Optional. Tool to support the model interacting directly with the computer. If enabled, it automatically populates computer-use specific Function Declarations.
- enterprise_web_search: EnterpriseWebSearchDict | None¶
Optional. Tool to support searching public web data, powered by Vertex AI Search and Sec4 compliance. This field is not supported in Gemini API.
- exa_ai_search: ToolExaAiSearchDict | None¶
Optional. Uses Exa.ai to search for information to answer user queries. The search results will be grounded on Exa.ai and presented to the model for response generation. This field is not supported in Gemini API.
- file_search: FileSearchDict | None¶
Optional. FileSearch tool type. Tool to retrieve knowledge from Semantic Retrieval corpora. This field is not supported in Vertex AI.
- function_declarations: list[FunctionDeclarationDict] | None¶
Optional. Function tool type. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating FunctionCall in the response. User should provide a FunctionResponse for each function call in the next turn. Based on the function responses, Model will generate the final response back to the user. Maximum 512 function declarations can be provided.
- google_maps: GoogleMapsDict | None¶
Optional. Tool that allows grounding the model’s response with geospatial context related to the user’s query.
- google_search: GoogleSearchDict | None¶
Optional. GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google.
- google_search_retrieval: GoogleSearchRetrievalDict | None¶
Optional. Specialized retrieval tool that is powered by Google Search.
- mcp_servers: list[McpServerDict] | None¶
Optional. MCP Servers to connect to. This field is not supported in Vertex AI.
- parallel_ai_search: ToolParallelAiSearchDict | None¶
Optional. If specified, Vertex AI will use Parallel.ai to search for information to answer user queries. The search results will be grounded on Parallel.ai and presented to the model for response generation. This field is not supported in Gemini API.
- retrieval: RetrievalDict | None¶
Optional. Retrieval tool type. System will always execute the provided retrieval tool(s) to get external knowledge to answer the prompt. Retrieval results are presented to the model for generation. This field is not supported in Gemini API.
- url_context: UrlContextDict | None¶
Optional. Tool to support URL context retrieval.
- class genai.types.ToolExaAiSearch(**data)¶
Bases:
BaseModelExaAiSearch tool type.
A tool that uses the Exa.ai search engine for grounding. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- api_key: str | None¶
- custom_configs: dict[str, Any] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ToolExaAiSearchDict¶
Bases:
TypedDictExaAiSearch tool type.
A tool that uses the Exa.ai search engine for grounding. This data type is not supported in Gemini API.
- api_key: str | None¶
Required. The API key for ExaAiSearch.
- custom_configs: dict[str, Any] | None¶
Optional. This field can be used to pass any parameter from the Exa.ai Search API.
- class genai.types.ToolParallelAiSearch(**data)¶
Bases:
BaseModelParallelAiSearch tool type.
A tool that uses the Parallel.ai search engine for grounding. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- api_key: str | None¶
- custom_configs: dict[str, Any] | None¶
- enable_data_retention: bool | None¶
- enable_zero_data_retention: bool | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ToolParallelAiSearchDict¶
Bases:
TypedDictParallelAiSearch tool type.
A tool that uses the Parallel.ai search engine for grounding. This data type is not supported in Gemini API.
- api_key: str | None¶
//docs.parallel.ai/search/search-quickstart for more details.
- Type:
Optional. The API key for ParallelAiSearch. If an API key is not provided, the system will attempt to verify access by checking for an active Parallel.ai subscription through the Google Cloud Marketplace. See https
- custom_configs: dict[str, Any] | None¶
//docs.parallel.ai/api-reference/search-beta/search Currently only source_policy, excerpts, max_results, mode, fetch_policy can be set via this field. For example: { “source_policy”: { “include_domains”: [“google.com”, “wikipedia.org”], “exclude_domains”: [“example.com”] }, “fetch_policy”: { “max_age_seconds”: 3600 } }
- Type:
Optional. Custom configs for ParallelAiSearch. This field can be used to pass any parameter from the Parallel.ai Search API. See the Parallel.ai documentation for the full list of available parameters and their usage
- Type:
https
- enable_data_retention: bool | None¶
Use enable_zero_data_retention instead. Instructs Vertex Grounding to use Parallel’s Zero Data Retention Marketplace product. If this value is “false” or omitted, the Parallel Web Search for Grounding standard subscription will be used. If this value is “true”, the Parallel Web Search for Grounding - ZDR subscription will be used.
- Type:
Optional. Deprecated
- enable_zero_data_retention: bool | None¶
Optional. Instructs Vertex Grounding to use Parallel’s Zero Data Retention Marketplace product. If this value is “false” or omitted, the Parallel Web Search for Grounding standard subscription will be used. If this value is “true”, the Parallel Web Search for Grounding - ZDR subscription will be used.
- class genai.types.ToolResponse(**data)¶
Bases:
BaseModelThe output from a server-side ToolCall execution.
This message contains the results of a tool invocation that was initiated by a ToolCall from the model. The client should pass this ToolResponse back to the API in a subsequent turn within a Content message, along with the corresponding ToolCall.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- id: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- response: dict[str, Any] | None¶
- class genai.types.ToolResponseDict¶
Bases:
TypedDictThe output from a server-side ToolCall execution.
This message contains the results of a tool invocation that was initiated by a ToolCall from the model. The client should pass this ToolResponse back to the API in a subsequent turn within a Content message, along with the corresponding ToolCall.
- id: str | None¶
The identifier of the tool call this response is for.
- response: dict[str, Any] | None¶
The tool response.
- class genai.types.ToolType(*values)¶
Bases:
CaseInSensitiveEnumThe type of tool in the function call.
- FILE_SEARCH = 'FILE_SEARCH'¶
File search tool, maps to Tool.file_search.
- GOOGLE_MAPS = 'GOOGLE_MAPS'¶
Google maps tool, maps to Tool.google_maps.
- GOOGLE_SEARCH_IMAGE = 'GOOGLE_SEARCH_IMAGE'¶
Image search tool, maps to Tool.google_search.search_types.image_search.
- GOOGLE_SEARCH_WEB = 'GOOGLE_SEARCH_WEB'¶
Google search tool, maps to Tool.google_search.search_types.web_search.
- MEDIA_PROCESSING = 'MEDIA_PROCESSING'¶
Media processing tool.
- TOOL_TYPE_UNSPECIFIED = 'TOOL_TYPE_UNSPECIFIED'¶
Unspecified tool type.
- URL_CONTEXT = 'URL_CONTEXT'¶
URL context tool, maps to Tool.url_context.
- class genai.types.TrafficType(*values)¶
Bases:
CaseInSensitiveEnumOutput only.
The traffic type for this request. This enum is not supported in Gemini API.
- ON_DEMAND = 'ON_DEMAND'¶
The request was processed using Pay-As-You-Go quota.
- ON_DEMAND_FLEX = 'ON_DEMAND_FLEX'¶
Type for Flex traffic.
- ON_DEMAND_OFFPEAK = 'ON_DEMAND_OFFPEAK'¶
Type for Off-Peak Pay-As-You-Go traffic.
- ON_DEMAND_PRIORITY = 'ON_DEMAND_PRIORITY'¶
Type for Priority Pay-As-You-Go traffic.
- PROVISIONED_THROUGHPUT = 'PROVISIONED_THROUGHPUT'¶
Type for Provisioned Throughput traffic.
- TRAFFIC_TYPE_UNSPECIFIED = 'TRAFFIC_TYPE_UNSPECIFIED'¶
Unspecified request traffic type.
- class genai.types.Transcription(**data)¶
Bases:
BaseModelAudio transcription in Server Content.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- end_offset: str | None¶
- finished: bool | None¶
- language_code: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- speaker_label: str | None¶
- start_offset: str | None¶
- text: str | None¶
- class genai.types.TranscriptionDict¶
Bases:
TypedDictAudio transcription in Server Content.
- end_offset: str | None¶
End offset in time of the transcription relative to the start of the audio.
- finished: bool | None¶
Optional. The bool indicates the end of the transcription.
- language_code: str | None¶
The BCP-47 language code of the transcription.
- speaker_label: str | None¶
A label identifying the speaker of this audio segment (e.g. “spk_1”, “spk_2”).
- start_offset: str | None¶
Start offset in time of the transcription relative to the start of the audio.
- text: str | None¶
Optional. Transcription text.
- words: list[WordInfoDict] | None¶
Detailed word-level transcriptions and timing details.
- class genai.types.TranslationConfig(**data)¶
Bases:
BaseModelConfig for stream translation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- echo_target_language: bool | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- target_language_code: str | None¶
- class genai.types.TranslationConfigDict¶
Bases:
TypedDictConfig for stream translation.
- echo_target_language: bool | None¶
If true, the model will generate audio when the target language is spoken, essentially it will parrot the input. If false, we will not produce audio for the target language.
- target_language_code: str | None¶
The target language for translation. Supported values are BCP-47 language codes (e.g. “en”, “es”, “fr”).
- class genai.types.TunedModel(**data)¶
Bases:
BaseModelTunedModel for the Tuned Model of a Tuning Job.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- checkpoints: list[TunedModelCheckpoint] | None¶
- endpoint: str | None¶
- model: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.TunedModelCheckpoint(**data)¶
Bases:
BaseModelTunedModelCheckpoint for the Tuned Model of a Tuning Job.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- checkpoint_id: str | None¶
- endpoint: str | None¶
- epoch: int | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- step: int | None¶
- class genai.types.TunedModelCheckpointDict¶
Bases:
TypedDictTunedModelCheckpoint for the Tuned Model of a Tuning Job.
- checkpoint_id: str | None¶
The ID of the checkpoint.
- endpoint: str | None¶
The Endpoint resource name that the checkpoint is deployed to. Format: projects/{project}/locations/{location}/endpoints/{endpoint}.
- epoch: int | None¶
The epoch of the checkpoint.
- step: int | None¶
The step of the checkpoint.
- class genai.types.TunedModelDict¶
Bases:
TypedDictTunedModel for the Tuned Model of a Tuning Job.
- checkpoints: list[TunedModelCheckpointDict] | None¶
The checkpoints associated with this TunedModel. This field is only populated for tuning jobs that enable intermediate checkpoints.
- endpoint: str | None¶
Output only. A resource name of an Endpoint. Format: projects/{project}/locations/{location}/endpoints/{endpoint}.
- model: str | None¶
Output only. The resource name of the TunedModel. Format: projects/{project}/locations/{location}/models/{model}@{version_id} When tuning from a base model, the version_id will be 1. For continuous tuning, the version id will be incremented by 1 from the last version id in the parent model. E.g., projects/{project}/locations/{location}/models/{model}@{last_version_id + 1}
- class genai.types.TunedModelInfo(**data)¶
Bases:
BaseModelA tuned machine learning model.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- base_model: str | None¶
- create_time: datetime | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- update_time: datetime | None¶
- class genai.types.TunedModelInfoDict¶
Bases:
TypedDictA tuned machine learning model.
- base_model: str | None¶
ID of the base model that you want to tune.
- create_time: datetime | None¶
Date and time when the base model was created.
- update_time: datetime | None¶
Date and time when the base model was last updated.
- class genai.types.TuningDataStats(**data)¶
Bases:
BaseModelThe tuning data statistic values for TuningJob.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- distillation_data_stats: DistillationDataStats | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- preference_optimization_data_stats: PreferenceOptimizationDataStats | None¶
- reinforcement_tuning_data_stats: DatasetStats | None¶
- supervised_tuning_data_stats: SupervisedTuningDataStats | None¶
- class genai.types.TuningDataStatsDict¶
Bases:
TypedDictThe tuning data statistic values for TuningJob.
This data type is not supported in Gemini API.
- distillation_data_stats: DistillationDataStatsDict | None¶
Output only. Statistics for distillation prompt dataset. These statistics do not include the responses sampled from the teacher model.
- preference_optimization_data_stats: PreferenceOptimizationDataStatsDict | None¶
Output only. Statistics for preference optimization.
- reinforcement_tuning_data_stats: DatasetStatsDict | None¶
Output only. Statistics for reinforcement tuning.
- supervised_tuning_data_stats: SupervisedTuningDataStatsDict | None¶
The SFT Tuning data stats.
- class genai.types.TuningDataset(**data)¶
Bases:
BaseModelSupervised fine-tuning training dataset.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- examples: list[TuningExample] | None¶
- gcs_uri: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- vertex_dataset_resource: str | None¶
- class genai.types.TuningDatasetDict¶
Bases:
TypedDictSupervised fine-tuning training dataset.
- examples: list[TuningExampleDict] | None¶
Inline examples with simple input/output text.
- gcs_uri: str | None¶
GCS URI of the file containing training dataset in JSONL format.
- vertex_dataset_resource: str | None¶
‘projects/my-project-id-or-number/locations/my-location/datasets/my-dataset-id’.
- Type:
The resource name of the Gemini Enterprise Agent Platform (previously known as Vertex AI) Multimodal Dataset that is used as training dataset. Example
- class genai.types.TuningExample(**data)¶
Bases:
BaseModelA single example for tuning.
This data type is not supported in Vertex AI.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- output: str | None¶
- text_input: str | None¶
- class genai.types.TuningExampleDict¶
Bases:
TypedDictA single example for tuning.
This data type is not supported in Vertex AI.
- output: str | None¶
Required. The expected model output.
- text_input: str | None¶
Optional. Text model input.
- class genai.types.TuningJob(**data)¶
Bases:
BaseModelA tuning job.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- base_model: str | None¶
- create_time: datetime | None¶
- custom_base_model: str | None¶
- description: str | None¶
- distillation_sampling_spec: DistillationSamplingSpec | None¶
- distillation_spec: DistillationSpec | None¶
- encryption_spec: EncryptionSpec | None¶
- end_time: datetime | None¶
- error: GoogleRpcStatus | None¶
- evaluate_dataset_runs: list[EvaluateDatasetRun] | None¶
- evaluation_config: EvaluationConfig | None¶
- experiment: str | None¶
- full_fine_tuning_spec: FullFineTuningSpec | None¶
- gcs_metrics_uri: str | None¶
- property has_ended: bool¶
Whether the tuning job has ended.
- property has_succeeded: bool¶
Whether the tuning job has succeeded.
- labels: dict[str, str] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str | None¶
- output_uri: str | None¶
- partner_model_tuning_spec: PartnerModelTuningSpec | None¶
- pipeline_job: str | None¶
- pre_tuned_model: PreTunedModel | None¶
- preference_optimization_spec: PreferenceOptimizationSpec | None¶
- reinforcement_tuning_spec: ReinforcementTuningSpec | None¶
- sdk_http_response: HttpResponse | None¶
- service_account: str | None¶
- start_time: datetime | None¶
- supervised_tuning_spec: SupervisedTuningSpec | None¶
- tuned_model: TunedModel | None¶
- tuned_model_display_name: str | None¶
- tuning_data_stats: TuningDataStats | None¶
- tuning_job_metadata: TuningJobMetadata | None¶
- tuning_job_state: TuningJobState | None¶
- update_time: datetime | None¶
- veo_lora_tuning_spec: VeoLoraTuningSpec | None¶
- veo_tuning_spec: VeoTuningSpec | None¶
- class genai.types.TuningJobDict¶
Bases:
TypedDictA tuning job.
- base_model: str | None¶
//cloud.google.com/vertex-ai/generative-ai/docs/model-reference/tuning#supported_models).
- Type:
The base model that is being tuned. See [Supported models](https
- create_time: datetime | None¶
Output only. Time when the TuningJob was created.
- custom_base_model: str | None¶
Optional. The user-provided path to custom model weights. Set this field to tune a custom model. The path must be a Cloud Storage directory that contains the model weights in .safetensors format along with associated model metadata files. If this field is set, the base_model field must still be set to indicate which base model the custom model is derived from. This feature is only available for open source models.
- description: str | None¶
Optional. The description of the TuningJob.
- distillation_sampling_spec: DistillationSamplingSpecDict | None¶
- distillation_spec: DistillationSpecDict | None¶
Tuning Spec for Distillation.
- encryption_spec: EncryptionSpecDict | None¶
Customer-managed encryption key options for a TuningJob. If this is set, then all resources created by the TuningJob will be encrypted with the provided encryption key.
- end_time: datetime | None¶
JOB_STATE_SUCCEEDED, JOB_STATE_FAILED, JOB_STATE_CANCELLED, JOB_STATE_EXPIRED.
- Type:
Output only. Time when the TuningJob entered any of the following JobStates
- error: GoogleRpcStatusDict | None¶
Output only. Only populated when job’s state is JOB_STATE_FAILED or JOB_STATE_CANCELLED.
- evaluate_dataset_runs: list[EvaluateDatasetRunDict] | None¶
Output only. Evaluation runs for the Tuning Job.
- evaluation_config: EvaluationConfigDict | None¶
Evaluation config for the tuning job.
- experiment: str | None¶
Output only. The Experiment associated with this TuningJob.
- full_fine_tuning_spec: FullFineTuningSpecDict | None¶
Tuning Spec for Full Fine Tuning.
- gcs_metrics_uri: str | None¶
Output only. The Cloud Storage metrics URI associated with this TuningJob.
- labels: dict[str, str] | None¶
//goo.gl/xmQnxf for more information and examples of labels.
- Type:
Optional. The labels with user-defined metadata to organize TuningJob and generated resources such as Model and Endpoint. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https
- name: str | None¶
projects/{project}/locations/{location}/tuningJobs/{tuning_job}
- Type:
Output only. Identifier. Resource name of a TuningJob. Format
- output_uri: str | None¶
Optional. Cloud Storage path to the directory where tuning job outputs are written to. This field is only available and required for open source models.
- partner_model_tuning_spec: PartnerModelTuningSpecDict | None¶
Tuning Spec for open sourced and third party Partner models.
- pipeline_job: str | None¶
projects/{project}/locations/{location}/pipelineJobs/{pipeline_job}.
- Type:
Output only. The resource name of the PipelineJob associated with the TuningJob. Format
- pre_tuned_model: PreTunedModelDict | None¶
The pre-tuned model for continuous tuning.
- preference_optimization_spec: PreferenceOptimizationSpecDict | None¶
Tuning Spec for Preference Optimization.
- reinforcement_tuning_spec: ReinforcementTuningSpecDict | None¶
Tuning Spec for Reinforcement Tuning.
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- service_account: str | None¶
//cloud.google.com/iam/docs/service-agents#vertex-ai-secure-fine-tuning-service-agent Users starting the pipeline must have the iam.serviceAccounts.actAs permission on this service account.
- Type:
The service account that the tuningJob workload runs as. If not specified, the Vertex AI Secure Fine-Tuned Service Agent in the project will be used. See https
- start_time: datetime | None¶
Output only. Time when the TuningJob for the first time entered the JOB_STATE_RUNNING state.
- supervised_tuning_spec: SupervisedTuningSpecDict | None¶
Tuning Spec for Supervised Fine Tuning.
- tuned_model: TunedModelDict | None¶
Output only. The tuned model resources associated with this TuningJob.
- tuned_model_display_name: str | None¶
Optional. The display name of the TunedModel. The name can be up to 128 characters long and can consist of any UTF-8 characters. For continuous tuning, tuned_model_display_name will by default use the same display name as the pre-tuned model. If a new display name is provided, the tuning job will create a new model instead of a new version.
- tuning_data_stats: TuningDataStatsDict | None¶
Output only. The tuning data statistics associated with this TuningJob.
- tuning_job_metadata: TuningJobMetadataDict | None¶
Output only. Tuning Job metadata.
- tuning_job_state: TuningJobState | None¶
Output only. The detail state of the tuning job (while the overall JobState is running).
- update_time: datetime | None¶
Output only. Time when the TuningJob was most recently updated.
- veo_lora_tuning_spec: VeoLoraTuningSpecDict | None¶
Tuning Spec for Veo LoRA Tuning.
- veo_tuning_spec: VeoTuningSpecDict | None¶
Tuning Spec for Veo Tuning.
- class genai.types.TuningJobMetadata(**data)¶
Bases:
BaseModelTuning job metadata. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- completed_epoch_count: int | None¶
- completed_step_count: int | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.TuningJobMetadataDict¶
Bases:
TypedDictTuning job metadata. This data type is not supported in Gemini API.
- completed_epoch_count: int | None¶
Output only. The number of epochs that have been completed.
- completed_step_count: int | None¶
Output only. The number of steps that have been completed. Set for Multi-Step RL.
- class genai.types.TuningJobState(*values)¶
Bases:
CaseInSensitiveEnumOutput only.
The detail state of the tuning job (while the overall JobState is running). This enum is not supported in Gemini API.
- TUNING_JOB_STATE_POST_PROCESSING = 'TUNING_JOB_STATE_POST_PROCESSING'¶
Tuning job is doing some post processing steps.
- TUNING_JOB_STATE_PROCESSING_DATASET = 'TUNING_JOB_STATE_PROCESSING_DATASET'¶
Tuning job is validating the dataset.
- TUNING_JOB_STATE_TUNING = 'TUNING_JOB_STATE_TUNING'¶
Tuning job is running.
- TUNING_JOB_STATE_UNSPECIFIED = 'TUNING_JOB_STATE_UNSPECIFIED'¶
Default tuning job state.
- TUNING_JOB_STATE_WAITING_FOR_CAPACITY = 'TUNING_JOB_STATE_WAITING_FOR_CAPACITY'¶
Tuning job is waiting for hardware capacity.
- TUNING_JOB_STATE_WAITING_FOR_QUOTA = 'TUNING_JOB_STATE_WAITING_FOR_QUOTA'¶
Tuning job is waiting for job quota.
- class genai.types.TuningMethod(*values)¶
Bases:
CaseInSensitiveEnumEnum representing the tuning method.
- DISTILLATION = 'DISTILLATION'¶
Distillation tuning.
- PREFERENCE_TUNING = 'PREFERENCE_TUNING'¶
Preference optimization tuning.
- REINFORCEMENT_TUNING = 'REINFORCEMENT_TUNING'¶
Reinforcement tuning.
- SUPERVISED_FINE_TUNING = 'SUPERVISED_FINE_TUNING'¶
Supervised fine tuning.
- class genai.types.TuningMode(*values)¶
Bases:
CaseInSensitiveEnumTuning mode. This enum is not supported in Gemini API.
- TUNING_MODE_FULL = 'TUNING_MODE_FULL'¶
Full fine-tuning mode.
- TUNING_MODE_PEFT_ADAPTER = 'TUNING_MODE_PEFT_ADAPTER'¶
PEFT adapter tuning mode.
- TUNING_MODE_UNSPECIFIED = 'TUNING_MODE_UNSPECIFIED'¶
Tuning mode is unspecified.
- class genai.types.TuningOperation(**data)¶
Bases:
BaseModelA long-running operation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- done: bool | None¶
- error: dict[str, Any] | None¶
- metadata: dict[str, Any] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str | None¶
- sdk_http_response: HttpResponse | None¶
- class genai.types.TuningOperationDict¶
Bases:
TypedDictA long-running operation.
- done: bool | None¶
If the value is false, it means the operation is still in progress. If true, the operation is completed, and either error or response is available.
- error: dict[str, Any] | None¶
The error result of the operation in case of failure or cancellation.
- metadata: dict[str, Any] | None¶
Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
- name: str | None¶
The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the name should be a resource name ending with operations/{unique_id}.
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.TuningSpeed(*values)¶
Bases:
CaseInSensitiveEnumThe speed of the tuning job.
Only supported for Veo 3.0 models. This enum is not supported in Gemini API.
- FAST = 'FAST'¶
Fast tuning speed.
- REGULAR = 'REGULAR'¶
Regular tuning speed.
- TUNING_SPEED_UNSPECIFIED = 'TUNING_SPEED_UNSPECIFIED'¶
The default / unset value. For Veo 3.0 models, this defaults to FAST.
- class genai.types.TuningTask(*values)¶
Bases:
CaseInSensitiveEnumThe tuning task for Veo. This enum is not supported in Gemini API.
- TUNING_TASK_I2V = 'TUNING_TASK_I2V'¶
Tuning task for image to video.
- TUNING_TASK_R2V = 'TUNING_TASK_R2V'¶
Tuning task for reference to video.
- TUNING_TASK_T2V = 'TUNING_TASK_T2V'¶
Tuning task for text to video.
- TUNING_TASK_UNSPECIFIED = 'TUNING_TASK_UNSPECIFIED'¶
Default value. This value is unused.
- class genai.types.TuningValidationDataset(**data)¶
Bases:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- gcs_uri: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- vertex_dataset_resource: str | None¶
- class genai.types.TuningValidationDatasetDict¶
Bases:
TypedDict- gcs_uri: str | None¶
GCS URI of the file containing validation dataset in JSONL format.
- vertex_dataset_resource: str | None¶
‘projects/my-project-id-or-number/locations/my-location/datasets/my-dataset-id’.
- Type:
The resource name of the Gemini Enterprise Agent Platform (previously known as Vertex AI) Multimodal Dataset that is used as validation dataset. Example
- class genai.types.TurnCompleteReason(*values)¶
Bases:
CaseInSensitiveEnumThe reason why the turn is complete.
- BLOCKLIST = 'BLOCKLIST'¶
Input matched blocklist.
- GENERATED_AUDIO_SAFETY = 'GENERATED_AUDIO_SAFETY'¶
Generated audio failed safety check.
- GENERATED_CONTENT_BLOCKLIST = 'GENERATED_CONTENT_BLOCKLIST'¶
Generated content matched blocklist.
- GENERATED_CONTENT_PROHIBITED = 'GENERATED_CONTENT_PROHIBITED'¶
Generated content is prohibited.
- GENERATED_CONTENT_SAFETY = 'GENERATED_CONTENT_SAFETY'¶
Generated content failed safety check.
- GENERATED_IMAGE_CELEBRITY = 'GENERATED_IMAGE_CELEBRITY'¶
Generated image contains celebrity.
- GENERATED_IMAGE_IDENTIFIABLE_PEOPLE = 'GENERATED_IMAGE_IDENTIFIABLE_PEOPLE'¶
Generated image contains identifiable people.
- GENERATED_IMAGE_MINORS = 'GENERATED_IMAGE_MINORS'¶
Generated image contains minors.
- GENERATED_IMAGE_PROHIBITED = 'GENERATED_IMAGE_PROHIBITED'¶
Generated image is prohibited.
- GENERATED_IMAGE_PROMINENT_PEOPLE_DETECTED_BY_REWRITER = 'GENERATED_IMAGE_PROMINENT_PEOPLE_DETECTED_BY_REWRITER'¶
Generated image contains prominent people detected by rewriter.
- GENERATED_IMAGE_SAFETY = 'GENERATED_IMAGE_SAFETY'¶
Generated image failed safety check.
- GENERATED_OTHER = 'GENERATED_OTHER'¶
Other generated content issue.
- GENERATED_VIDEO_SAFETY = 'GENERATED_VIDEO_SAFETY'¶
Generated video failed safety check.
- IMAGE_PROHIBITED_INPUT_CONTENT = 'IMAGE_PROHIBITED_INPUT_CONTENT'¶
Input image contains prohibited content.
- INPUT_IMAGE_CELEBRITY = 'INPUT_IMAGE_CELEBRITY'¶
Input image contains celebrity.
- INPUT_IMAGE_PHOTO_REALISTIC_CHILD_PROHIBITED = 'INPUT_IMAGE_PHOTO_REALISTIC_CHILD_PROHIBITED'¶
Input image contains photo realistic child.
- INPUT_IP_PROHIBITED = 'INPUT_IP_PROHIBITED'¶
Input contains IP violation.
- INPUT_OTHER = 'INPUT_OTHER'¶
Other input safety issue.
- INPUT_TEXT_CONTAIN_PROMINENT_PERSON_PROHIBITED = 'INPUT_TEXT_CONTAIN_PROMINENT_PERSON_PROHIBITED'¶
Input text contains prominent person reference.
- INPUT_TEXT_NCII_PROHIBITED = 'INPUT_TEXT_NCII_PROHIBITED'¶
Input text contains NCII content.
- MALFORMED_FUNCTION_CALL = 'MALFORMED_FUNCTION_CALL'¶
The function call generated by the model is invalid.
- MAX_REGENERATION_REACHED = 'MAX_REGENERATION_REACHED'¶
Max regeneration attempts reached.
- NEED_MORE_INPUT = 'NEED_MORE_INPUT'¶
Needs more input from the user.
- OUTPUT_IMAGE_IP_PROHIBITED = 'OUTPUT_IMAGE_IP_PROHIBITED'¶
Generated image contains IP violation.
- PROHIBITED_INPUT_CONTENT = 'PROHIBITED_INPUT_CONTENT'¶
Input content is prohibited.
- RESPONSE_REJECTED = 'RESPONSE_REJECTED'¶
The response is rejected by the model.
- TURN_COMPLETE_REASON_UNSPECIFIED = 'TURN_COMPLETE_REASON_UNSPECIFIED'¶
Default value. Reason is unspecified.
- UNSAFE_PROMPT_FOR_IMAGE_GENERATION = 'UNSAFE_PROMPT_FOR_IMAGE_GENERATION'¶
Input is unsafe for image generation.
- class genai.types.TurnCoverage(*values)¶
Bases:
CaseInSensitiveEnumOptions about which input is included in the user’s turn.
- TURN_COVERAGE_UNSPECIFIED = 'TURN_COVERAGE_UNSPECIFIED'¶
If unspecified, the default behavior is TURN_INCLUDES_ONLY_ACTIVITY.
- TURN_INCLUDES_ALL_INPUT = 'TURN_INCLUDES_ALL_INPUT'¶
The users turn includes all realtime input since the last turn, including inactivity (e.g. silence on the audio stream).
- TURN_INCLUDES_AUDIO_ACTIVITY_AND_ALL_VIDEO = 'TURN_INCLUDES_AUDIO_ACTIVITY_AND_ALL_VIDEO'¶
Includes audio activity and all video since the last turn. With automatic activity detection, audio activity means speech and excludes silence.
- TURN_INCLUDES_ONLY_ACTIVITY = 'TURN_INCLUDES_ONLY_ACTIVITY'¶
The users turn only includes activity since the last turn, excluding inactivity (e.g. silence on the audio stream). This is the default behavior.
- class genai.types.Type(*values)¶
Bases:
CaseInSensitiveEnumData type of the schema field.
- ARRAY = 'ARRAY'¶
OpenAPI array type
- BOOLEAN = 'BOOLEAN'¶
OpenAPI boolean type
- INTEGER = 'INTEGER'¶
OpenAPI integer type
- NULL = 'NULL'¶
Null type
- NUMBER = 'NUMBER'¶
OpenAPI number type
- OBJECT = 'OBJECT'¶
OpenAPI object type
- STRING = 'STRING'¶
OpenAPI string type
- TYPE_UNSPECIFIED = 'TYPE_UNSPECIFIED'¶
Not specified, should not be used.
- class genai.types.UnifiedMetric(**data)¶
Bases:
BaseModelThe unified metric used for evaluation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- computation_based_metric_spec: ComputationBasedMetricSpec | None¶
- custom_code_execution_spec: CustomCodeExecutionSpec | None¶
- llm_based_metric_spec: LLMBasedMetricSpec | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- pointwise_metric_spec: PointwiseMetricSpec | None¶
- predefined_metric_spec: PredefinedMetricSpec | None¶
- class genai.types.UnifiedMetricDict¶
Bases:
TypedDictThe unified metric used for evaluation.
- bleu_spec: BleuSpecDict | None¶
The Bleu metric spec.
- computation_based_metric_spec: ComputationBasedMetricSpecDict | None¶
The spec for a computation based metric.
- custom_code_execution_spec: CustomCodeExecutionSpecDict | None¶
The spec for a custom code execution metric.
- llm_based_metric_spec: LLMBasedMetricSpecDict | None¶
The spec for an LLM based metric.
- pointwise_metric_spec: PointwiseMetricSpecDict | None¶
The pointwise metric spec.
- predefined_metric_spec: PredefinedMetricSpecDict | None¶
The spec for a pre-defined metric.
- rouge_spec: RougeSpecDict | None¶
The rouge metric spec.
- class genai.types.UpdateCachedContentConfig(**data)¶
Bases:
BaseModelOptional parameters for caches.update method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- expire_time: datetime | None¶
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- ttl: str | None¶
- class genai.types.UpdateCachedContentConfigDict¶
Bases:
TypedDictOptional parameters for caches.update method.
- expire_time: datetime | None¶
01:23Z.
- Type:
Timestamp of when this resource is considered expired. Uses RFC 3339 format, Example
- Type:
2014-10-02T15
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- ttl: str | None¶
“3.5s”.
- Type:
The TTL for this resource. The expiration time is computed
- Type:
now + TTL. It is a duration string, with up to nine fractional digits, terminated by ‘s’. Example
- class genai.types.UpdateModelConfig(**data)¶
Bases:
BaseModelConfiguration for updating a tuned model.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- default_checkpoint_id: str | None¶
- description: str | None¶
- display_name: str | None¶
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.UpdateModelConfigDict¶
Bases:
TypedDictConfiguration for updating a tuned model.
- default_checkpoint_id: str | None¶
- description: str | None¶
- display_name: str | None¶
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.UploadFileConfig(**data)¶
Bases:
BaseModelUsed to override the default configuration.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- display_name: str | None¶
- http_options: HttpOptions | None¶
- mime_type: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str | None¶
- class genai.types.UploadFileConfigDict¶
Bases:
TypedDictUsed to override the default configuration.
- display_name: str | None¶
Optional display name of the file.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- mime_type: str | None¶
The MIME type of the file. If not provided, it will be inferred from the file extension.
- Type:
- name: str | None¶
The name of the file in the destination (e.g., ‘files/sample-image’. If not provided one will be generated.
- class genai.types.UploadToFileSearchStoreConfig(**data)¶
Bases:
BaseModelOptional parameters for uploading a file to a FileSearchStore.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- chunking_config: ChunkingConfig | None¶
- custom_metadata: list[CustomMetadata] | None¶
- display_name: str | None¶
- http_options: HttpOptions | None¶
- mime_type: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- should_return_http_response: bool | None¶
- class genai.types.UploadToFileSearchStoreConfigDict¶
Bases:
TypedDictOptional parameters for uploading a file to a FileSearchStore.
- chunking_config: ChunkingConfigDict | None¶
Config for telling the service how to chunk the file.
- custom_metadata: list[CustomMetadataDict] | None¶
User provided custom metadata stored as key-value pairs used for querying.
- display_name: str | None¶
Display name of the created document.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- mime_type: str | None¶
MIME type of the file to be uploaded. If not provided, it will be inferred from the file extension.
- should_return_http_response: bool | None¶
If true, the raw HTTP response will be returned in the ‘sdk_http_response’ field.
- class genai.types.UploadToFileSearchStoreOperation(**data)¶
Bases:
BaseModel,OperationLong-running operation for uploading a file to a FileSearchStore.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- classmethod from_api_response(api_response, is_vertex_ai=False)¶
Instantiates a UploadToFileSearchStoreOperation from an API response.
- Return type:
Self
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- response: UploadToFileSearchStoreResponse | None¶
- class genai.types.UploadToFileSearchStoreResponse(**data)¶
Bases:
BaseModelThe response when long-running operation for uploading a file to a FileSearchStore complete.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- document_name: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- parent: str | None¶
- sdk_http_response: HttpResponse | None¶
- class genai.types.UploadToFileSearchStoreResponseDict¶
Bases:
TypedDictThe response when long-running operation for uploading a file to a FileSearchStore complete.
- document_name: str | None¶
The identifier for the Document imported.
- parent: str | None¶
The name of the FileSearchStore containing Documents.
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.UploadToFileSearchStoreResumableResponse(**data)¶
Bases:
BaseModelResponse for the resumable upload method.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- sdk_http_response: HttpResponse | None¶
- class genai.types.UploadToFileSearchStoreResumableResponseDict¶
Bases:
TypedDictResponse for the resumable upload method.
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.UpscaleImageConfig(**data)¶
Bases:
BaseModelConfiguration for upscaling an image.
For more information on this configuration, refer to the Imagen API reference documentation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- enhance_input_image: bool | None¶
- http_options: HttpOptions | None¶
- image_preservation_factor: float | None¶
- include_rai_reason: bool | None¶
- labels: dict[str, str] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- output_compression_quality: int | None¶
- output_gcs_uri: str | None¶
- output_mime_type: str | None¶
- person_generation: PersonGeneration | None¶
- safety_filter_level: SafetyFilterLevel | None¶
- class genai.types.UpscaleImageConfigDict¶
Bases:
TypedDictConfiguration for upscaling an image.
For more information on this configuration, refer to the Imagen API reference documentation.
- enhance_input_image: bool | None¶
Whether to add an image enhancing step before upscaling. It is expected to suppress the noise and JPEG compression artifacts from the input image.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- image_preservation_factor: float | None¶
With a higher image preservation factor, the original image pixels are more respected. With a lower image preservation factor, the output image will have be more different from the input image, but with finer details and less noise.
- include_rai_reason: bool | None¶
Whether to include a reason for filtered-out images in the response.
- labels: dict[str, str] | None¶
User specified labels to track billing usage.
- output_compression_quality: int | None¶
The level of compression. Only applicable if the
output_mime_typeisimage/jpeg.
- output_gcs_uri: str | None¶
Cloud Storage URI used to store the generated images.
- output_mime_type: str | None¶
The image format that the output should be saved as.
- person_generation: PersonGeneration | None¶
Allows generation of people by the model.
- safety_filter_level: SafetyFilterLevel | None¶
Filter level for safety filtering.
- class genai.types.UpscaleImageParameters(**data)¶
Bases:
BaseModelUser-facing config UpscaleImageParameters.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- config: UpscaleImageConfig | None¶
- model: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- upscale_factor: str | None¶
- class genai.types.UpscaleImageParametersDict¶
Bases:
TypedDictUser-facing config UpscaleImageParameters.
- config: UpscaleImageConfigDict | None¶
Configuration for upscaling.
- model: str | None¶
The model to use.
- upscale_factor: str | None¶
The factor to upscale the image (x2 or x4).
- class genai.types.UpscaleImageResponse(**data)¶
Bases:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- generated_images: list[GeneratedImage] | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- sdk_http_response: HttpResponse | None¶
- class genai.types.UpscaleImageResponseDict¶
Bases:
TypedDict- generated_images: list[GeneratedImageDict] | None¶
Generated images.
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.UrlContext(**data)¶
Bases:
BaseModelTool to support URL context.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.UrlContextDict¶
Bases:
TypedDictTool to support URL context.
- class genai.types.UrlContextMetadata(**data)¶
Bases:
BaseModelMetadata returned when the model uses the url_context tool to get information from a user-provided URL.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- url_metadata: list[UrlMetadata] | None¶
- class genai.types.UrlContextMetadataDict¶
Bases:
TypedDictMetadata returned when the model uses the url_context tool to get information from a user-provided URL.
- url_metadata: list[UrlMetadataDict] | None¶
Output only. A list of URL metadata, with one entry for each URL retrieved by the tool.
- class genai.types.UrlMetadata(**data)¶
Bases:
BaseModelThe metadata for a single URL retrieval.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- retrieved_url: str | None¶
- url_retrieval_status: UrlRetrievalStatus | None¶
- class genai.types.UrlMetadataDict¶
Bases:
TypedDictThe metadata for a single URL retrieval.
- retrieved_url: str | None¶
The URL retrieved by the tool.
- url_retrieval_status: UrlRetrievalStatus | None¶
The status of the URL retrieval.
- class genai.types.UrlRetrievalStatus(*values)¶
Bases:
CaseInSensitiveEnumThe status of the URL retrieval.
- URL_RETRIEVAL_STATUS_ERROR = 'URL_RETRIEVAL_STATUS_ERROR'¶
The URL retrieval failed.
- URL_RETRIEVAL_STATUS_PAYWALL = 'URL_RETRIEVAL_STATUS_PAYWALL'¶
Url retrieval is failed because the content is behind paywall. This enum value is not supported in Vertex AI.
- URL_RETRIEVAL_STATUS_SUCCESS = 'URL_RETRIEVAL_STATUS_SUCCESS'¶
The URL was retrieved successfully.
- URL_RETRIEVAL_STATUS_UNSAFE = 'URL_RETRIEVAL_STATUS_UNSAFE'¶
Url retrieval is failed because the content is unsafe. This enum value is not supported in Vertex AI.
- URL_RETRIEVAL_STATUS_UNSPECIFIED = 'URL_RETRIEVAL_STATUS_UNSPECIFIED'¶
Default value. This value is unused.
- class genai.types.UsageMetadata(**data)¶
Bases:
BaseModelUsage metadata about response(s).
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- cache_tokens_details: list[ModalityTokenCount] | None¶
- cached_content_token_count: int | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- prompt_token_count: int | None¶
- prompt_tokens_details: list[ModalityTokenCount] | None¶
- response_token_count: int | None¶
- response_tokens_details: list[ModalityTokenCount] | None¶
- service_tier: ServiceTier | None¶
- thoughts_token_count: int | None¶
- tool_use_prompt_token_count: int | None¶
- tool_use_prompt_tokens_details: list[ModalityTokenCount] | None¶
- total_token_count: int | None¶
- traffic_type: TrafficType | None¶
- class genai.types.UsageMetadataDict¶
Bases:
TypedDictUsage metadata about response(s).
- cache_tokens_details: list[ModalityTokenCountDict] | None¶
Output only. A detailed breakdown of the token count for each modality in the cached content.
- cached_content_token_count: int | None¶
Output only. The number of tokens in the cached content that was used for this request.
- prompt_token_count: int | None¶
The total number of tokens in the prompt. This includes any text, images, or other media provided in the request. When cached_content is set, this also includes the number of tokens in the cached content.
- prompt_tokens_details: list[ModalityTokenCountDict] | None¶
Output only. A detailed breakdown of the token count for each modality in the prompt.
- response_token_count: int | None¶
Total number of tokens across all the generated response candidates.
- response_tokens_details: list[ModalityTokenCountDict] | None¶
List of modalities that were returned in the response.
- service_tier: ServiceTier | None¶
Output only. Service tier of the request. This field is not supported in Vertex AI.
- thoughts_token_count: int | None¶
Output only. The number of tokens that were part of the model’s generated “thoughts” output, if applicable.
- tool_use_prompt_token_count: int | None¶
Output only. The number of tokens in the results from tool executions, which are provided back to the model as input, if applicable.
- tool_use_prompt_tokens_details: list[ModalityTokenCountDict] | None¶
Output only. A detailed breakdown by modality of the token counts from the results of tool executions, which are provided back to the model as input.
- total_token_count: int | None¶
The total number of tokens for the entire request. This is the sum of prompt_token_count, candidates_token_count, tool_use_prompt_token_count, and thoughts_token_count.
- traffic_type: TrafficType | None¶
Output only. The traffic type for this request. This field is not supported in Gemini API.
- class genai.types.UserContent(parts)¶
Bases:
ContentUserContent facilitates the creation of a Content object with a user role.
Example usages:
Create a user Content object with a string: user_content = UserContent(“Why is the sky blue?”)
Create a user Content object with a file data Part object: user_content = UserContent(Part.from_uri(file_uri=”gs://bucket/file.txt”, mime_type=”text/plain”))
Create a user Content object with byte data Part object: user_content = UserContent(Part.from_bytes(data=b”Hello, World!”, mime_type=”text/plain”))
You can create a user Content object using other classmethods in the Part class as well. You can also create a user Content using a list of Part objects or strings.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- role: Literal['user']¶
- class genai.types.VadSignalType(*values)¶
Bases:
CaseInSensitiveEnumThe type of the VAD signal.
- VAD_SIGNAL_TYPE_EOS = 'VAD_SIGNAL_TYPE_EOS'¶
End of sentence signal.
- VAD_SIGNAL_TYPE_SOS = 'VAD_SIGNAL_TYPE_SOS'¶
Start of sentence signal.
- VAD_SIGNAL_TYPE_UNSPECIFIED = 'VAD_SIGNAL_TYPE_UNSPECIFIED'¶
The default is VAD_SIGNAL_TYPE_UNSPECIFIED.
- class genai.types.ValidateRewardConfig(**data)¶
Bases:
BaseModelOptional parameters for tunings.validate_reward.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- http_options: HttpOptions | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.ValidateRewardConfigDict¶
Bases:
TypedDictOptional parameters for tunings.validate_reward.
- http_options: HttpOptionsDict | None¶
Used to override HTTP request options.
- class genai.types.ValidateRewardResponse(**data)¶
Bases:
BaseModelResponse for the validate_reward method.
Contains the computed reward for a reinforcement tuning reward configuration.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- error: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- overall_reward: float | None¶
- reward_info_details: dict[str, ReinforcementTuningRewardInfo] | None¶
- sdk_http_response: HttpResponse | None¶
- class genai.types.ValidateRewardResponseDict¶
Bases:
TypedDictResponse for the validate_reward method.
Contains the computed reward for a reinforcement tuning reward configuration.
- error: str | None¶
Output only. In case of an error, this field will be populated with a detailed error message to help with debugging.
- overall_reward: float | None¶
Output only. The overall weighted reward. For a CompositeReinforcementTuningRewardConfig, this is the weighted average of all rewards. For a SingleReinforcementTuningRewardConfig, this will be the value of the single reward.
- reward_info_details: dict[str, ReinforcementTuningRewardInfoDict] | None¶
A map from reward name to reward info.
- sdk_http_response: HttpResponseDict | None¶
Used to retain the full HTTP response.
- class genai.types.VeoHyperParameters(**data)¶
Bases:
BaseModelHyperparameters for Veo. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- adapter_size: AdapterSize | None¶
- epoch_count: int | None¶
- learning_rate_multiplier: float | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- tuning_speed: TuningSpeed | None¶
- tuning_task: TuningTask | None¶
- veo_data_mixture_ratio: float | None¶
- class genai.types.VeoHyperParametersDict¶
Bases:
TypedDictHyperparameters for Veo. This data type is not supported in Gemini API.
- adapter_size: AdapterSize | None¶
Optional. The adapter size for LoRA tuning.
- epoch_count: int | None¶
Optional. Number of complete passes the model makes over the entire training dataset during training.
- learning_rate_multiplier: float | None¶
Optional. Multiplier for adjusting the default learning rate.
- tuning_speed: TuningSpeed | None¶
The speed of the tuning job. Only supported for Veo 3.0 models.
- tuning_task: TuningTask | None¶
The tuning task for Veo.
- veo_data_mixture_ratio: float | None¶
Optional. The ratio of Google internal dataset to use in the training mixture, in range of [0, 1). If 0.2, it means 20% of Google internal dataset and 80% of user dataset will be used for training. If not set, the default value is 0.1.
- class genai.types.VeoLoraTuningSpec(**data)¶
Bases:
BaseModelTuning Spec for Veo LoRA Model Tuning.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- hyper_parameters: VeoHyperParameters | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- training_dataset_uri: str | None¶
- validation_dataset_uri: str | None¶
- video_orientation: VideoOrientation | None¶
- class genai.types.VeoLoraTuningSpecDict¶
Bases:
TypedDictTuning Spec for Veo LoRA Model Tuning.
This data type is not supported in Gemini API.
- hyper_parameters: VeoHyperParametersDict | None¶
Optional. Hyperparameters for Veo LoRA.
- training_dataset_uri: str | None¶
Required. Training dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.
- validation_dataset_uri: str | None¶
Optional. Validation dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.
- video_orientation: VideoOrientation | None¶
Optional. The orientation of the video. Defaults to LANDSCAPE.
- class genai.types.VeoTuningSpec(**data)¶
Bases:
BaseModelTuning Spec for Veo Model Tuning.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- hyper_parameters: VeoHyperParameters | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- training_dataset_uri: str | None¶
- validation_dataset_uri: str | None¶
- class genai.types.VeoTuningSpecDict¶
Bases:
TypedDictTuning Spec for Veo Model Tuning.
This data type is not supported in Gemini API.
- hyper_parameters: VeoHyperParametersDict | None¶
Optional. Hyperparameters for Veo.
- training_dataset_uri: str | None¶
Required. Training dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.
- validation_dataset_uri: str | None¶
Optional. Validation dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.
- class genai.types.VertexAISearch(**data)¶
Bases:
BaseModelRetrieve from Vertex AI Search datastore or engine for grounding.
datastore and engine are mutually exclusive. See https://cloud.google.com/products/agent-builder. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- data_store_specs: list[VertexAISearchDataStoreSpec] | None¶
- datastore: str | None¶
- engine: str | None¶
- filter: str | None¶
- max_results: int | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.VertexAISearchDataStoreSpec(**data)¶
Bases:
BaseModelDefine data stores within engine to filter on in a search call and configurations for those data stores.
For more information, see https://cloud.google.com/generative-ai-app-builder/docs/reference/rpc/google.cloud.discoveryengine.v1#datastorespec. This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- data_store: str | None¶
- filter: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.VertexAISearchDataStoreSpecDict¶
Bases:
TypedDictDefine data stores within engine to filter on in a search call and configurations for those data stores.
For more information, see https://cloud.google.com/generative-ai-app-builder/docs/reference/rpc/google.cloud.discoveryengine.v1#datastorespec. This data type is not supported in Gemini API.
- data_store: str | None¶
projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}
- Type:
Full resource name of DataStore, such as Format
- filter: str | None¶
//cloud.google.com/generative-ai-app-builder/docs/filter-search-metadata)
- Type:
Optional. Filter specification to filter documents in the data store specified by data_store field. For more information on filtering, see [Filtering](https
- class genai.types.VertexAISearchDict¶
Bases:
TypedDictRetrieve from Vertex AI Search datastore or engine for grounding.
datastore and engine are mutually exclusive. See https://cloud.google.com/products/agent-builder. This data type is not supported in Gemini API.
- data_store_specs: list[VertexAISearchDataStoreSpecDict] | None¶
Specifications that define the specific DataStores to be searched, along with configurations for those data stores. This is only considered for Engines with multiple data stores. It should only be set if engine is used.
- datastore: str | None¶
projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}
- Type:
Optional. Fully-qualified Vertex AI Search data store resource ID. Format
- engine: str | None¶
projects/{project}/locations/{location}/collections/{collection}/engines/{engine}
- Type:
Optional. Fully-qualified Vertex AI Search engine resource ID. Format
- filter: str | None¶
Optional. Filter strings to be passed to the search API.
- max_results: int | None¶
Optional. Number of search results to return per query. The default value is 10. The maximumm allowed value is 10.
- class genai.types.VertexMultimodalDatasetDestination(**data)¶
Bases:
BaseModelThis class is experimental and may change in future versions.
The specification for an output Vertex AI multimodal dataset.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- bigquery_destination: str | None¶
- display_name: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.VertexMultimodalDatasetDestinationDict¶
Bases:
TypedDictThis class is experimental and may change in future versions.
The specification for an output Vertex AI multimodal dataset.
- bigquery_destination: str | None¶
The BigQuery destination for the multimodal dataset.
- display_name: str | None¶
The display name of the multimodal dataset.
- class genai.types.VertexRagStore(**data)¶
Bases:
BaseModelRetrieve from Vertex RAG Store for grounding.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- rag_corpora: list[str] | None¶
- rag_resources: list[VertexRagStoreRagResource] | None¶
- rag_retrieval_config: RagRetrievalConfig | None¶
- similarity_top_k: int | None¶
- store_context: bool | None¶
- vector_distance_threshold: float | None¶
- class genai.types.VertexRagStoreDict¶
Bases:
TypedDictRetrieve from Vertex RAG Store for grounding.
This data type is not supported in Gemini API.
- rag_corpora: list[str] | None¶
Optional. Deprecated. Please use rag_resources instead.
- rag_resources: list[VertexRagStoreRagResourceDict] | None¶
Optional. The representation of the rag source. It can be used to specify corpus only or ragfiles. Currently only support one corpus or multiple files from one corpus. In the future we may open up multiple corpora support.
- rag_retrieval_config: RagRetrievalConfigDict | None¶
Optional. The retrieval config for the Rag query.
- similarity_top_k: int | None¶
Optional. Number of top k results to return from the selected corpora.
- store_context: bool | None¶
Optional. Currently only supported for Gemini Multimodal Live API. In Gemini Multimodal Live API, if store_context bool is specified, Gemini will leverage it to automatically memorize the interactions between the client and Gemini, and retrieve context when needed to augment the response generation for users’ ongoing and future interactions.
- vector_distance_threshold: float | None¶
Optional. Only return results with vector distance smaller than the threshold.
- class genai.types.VertexRagStoreRagResource(**data)¶
Bases:
BaseModelThe definition of the Rag resource.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- rag_corpus: str | None¶
- rag_file_ids: list[str] | None¶
- class genai.types.VertexRagStoreRagResourceDict¶
Bases:
TypedDictThe definition of the Rag resource.
This data type is not supported in Gemini API.
- rag_corpus: str | None¶
projects/{project}/locations/{location}/ragCorpora/{rag_corpus}
- Type:
Optional. RagCorpora resource name. Format
- rag_file_ids: list[str] | None¶
Optional. rag_file_id. The files should be in the same rag_corpus set in rag_corpus field.
- class genai.types.Video(**data)¶
Bases:
BaseModelA generated video.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- classmethod from_file(*, location, mime_type=None)¶
Loads a video from a local file.
- Return type:
- Parameters:
location – The local path to load the video from.
mime_type – The MIME type of the video. If not provided, the MIME type will be automatically determined.
- Returns:
A loaded video as an Video object.
- mime_type: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- save(path)¶
Saves the video to a file.
- Return type:
None- Parameters:
path – Local path where to save the video.
- show()¶
Shows the video.
If the video has no mime_type, it is assumed to be video/mp4.
This method only works in a notebook environment.
- Return type:
None
- uri: str | None¶
- video_bytes: bytes | None¶
- class genai.types.VideoCompressionQuality(*values)¶
Bases:
CaseInSensitiveEnumEnum that controls the compression quality of the generated videos.
- LOSSLESS = 'LOSSLESS'¶
Lossless video compression quality. This will produce videos with a larger file size.
- OPTIMIZED = 'OPTIMIZED'¶
Optimized video compression quality. This will produce videos with a compressed, smaller file size.
- class genai.types.VideoDict¶
Bases:
TypedDictA generated video.
- mime_type: str | None¶
Video encoding, for example
video/mp4.
- uri: str | None¶
Path to another storage.
- video_bytes: bytes | None¶
Video bytes.
- class genai.types.VideoGenerationMask(**data)¶
Bases:
BaseModelA mask for video generation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- mask_mode: VideoGenerationMaskMode | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.VideoGenerationMaskDict¶
Bases:
TypedDictA mask for video generation.
- mask_mode: VideoGenerationMaskMode | None¶
Describes how the mask will be used. Inpainting masks must match the aspect ratio of the input video. Outpainting masks can be either 9:16 or 16:9.
- class genai.types.VideoGenerationMaskMode(*values)¶
Bases:
CaseInSensitiveEnumEnum for the mask mode of a video generation mask.
- INSERT = 'INSERT'¶
The image mask contains a masked rectangular region which is applied on the first frame of the input video. The object described in the prompt is inserted into this region and will appear in subsequent frames.
- OUTPAINT = 'OUTPAINT'¶
The image mask contains a masked rectangular region where the input video will go. The remaining area will be generated. Video masks are not supported.
- REMOVE = 'REMOVE'¶
The image mask is used to determine an object in the first video frame to track. This object is removed from the video.
- REMOVE_STATIC = 'REMOVE_STATIC'¶
The image mask is used to determine a region in the video. Objects in this region will be removed.
- class genai.types.VideoGenerationReferenceImage(**data)¶
Bases:
BaseModelA reference image for video generation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- reference_type: VideoGenerationReferenceType | None¶
- class genai.types.VideoGenerationReferenceImageDict¶
Bases:
TypedDictA reference image for video generation.
- reference_type: VideoGenerationReferenceType | None¶
The type of the reference image, which defines how the reference image will be used to generate the video.
- class genai.types.VideoGenerationReferenceType(*values)¶
Bases:
CaseInSensitiveEnumEnum for the reference type of a video generation reference image.
- ASSET = 'ASSET'¶
A reference image that provides assets to the generated video, such as the scene, an object, a character, etc.
- STYLE = 'STYLE'¶
A reference image that provides aesthetics including colors, lighting, texture, etc., to be used as the style of the generated video, such as ‘anime’, ‘photography’, ‘origami’, etc.
- class genai.types.VideoMetadata(**data)¶
Bases:
BaseModelProvides metadata for a video, including the start and end offsets for clipping and the frame rate.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- end_offset: str | None¶
- fps: float | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- start_offset: str | None¶
- class genai.types.VideoMetadataDict¶
Bases:
TypedDictProvides metadata for a video, including the start and end offsets for clipping and the frame rate.
- end_offset: str | None¶
Optional. The end offset of the video.
- fps: float | None¶
Optional. The frame rate of the video sent to the model. If not specified, the default value is 1.0. The valid range is (0.0, 24.0].
- start_offset: str | None¶
Optional. The start offset of the video.
- class genai.types.VideoOrientation(*values)¶
Bases:
CaseInSensitiveEnumThe orientation of the video.
Defaults to LANDSCAPE. This enum is not supported in Gemini API.
- LANDSCAPE = 'LANDSCAPE'¶
9, 1280x720).
- Type:
Landscape orientation (e.g. 16
- PORTRAIT = 'PORTRAIT'¶
16, 720x1280).
- Type:
Portrait orientation (e.g. 9
- VIDEO_ORIENTATION_UNSPECIFIED = 'VIDEO_ORIENTATION_UNSPECIFIED'¶
Unspecified video orientation. Defaults to landscape.
- class genai.types.VideoResponseFormat(**data)¶
Bases:
BaseModelConfiguration for video-specific output formatting.
This data type is not supported in Gemini API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- aspect_ratio: AspectRatio | None¶
- duration: str | None¶
- gcs_uri: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- resolution: str | None¶
- class genai.types.VideoResponseFormatDict¶
Bases:
TypedDictConfiguration for video-specific output formatting.
This data type is not supported in Gemini API.
- aspect_ratio: AspectRatio | None¶
The aspect ratio for the video output.
- duration: str | None¶
Optional. The duration for the video output.
- gcs_uri: str | None¶
Optional. The Google Cloud Storage URI to store the video output. Required for Vertex if delivery is URI.
- resolution: str | None¶
“360p”, “720p”, “1080p”, “4k”.
- Type:
Optional. The video output resolution. Supported values
- class genai.types.VoiceActivity(**data)¶
Bases:
BaseModelVoice activity signal.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- audio_offset: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- voice_activity_type: VoiceActivityType | None¶
- class genai.types.VoiceActivityDetectionSignal(**data)¶
Bases:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- vad_signal_type: VadSignalType | None¶
- class genai.types.VoiceActivityDetectionSignalDict¶
Bases:
TypedDict- vad_signal_type: VadSignalType | None¶
The type of the VAD signal.
- class genai.types.VoiceActivityDict¶
Bases:
TypedDictVoice activity signal.
- audio_offset: str | None¶
The time voice activity detected in audio time, relative to the start of the audio stream.
- voice_activity_type: VoiceActivityType | None¶
The type of the voice activity signal.
- class genai.types.VoiceActivityType(*values)¶
Bases:
CaseInSensitiveEnumThe type of the voice activity signal.
- ACTIVITY_END = 'ACTIVITY_END'¶
End of sentence signal.
- ACTIVITY_START = 'ACTIVITY_START'¶
Start of sentence signal.
- TYPE_UNSPECIFIED = 'TYPE_UNSPECIFIED'¶
The default is VOICE_ACTIVITY_TYPE_UNSPECIFIED.
- class genai.types.VoiceConfig(**data)¶
Bases:
BaseModelThe configuration for the voice to use.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- prebuilt_voice_config: PrebuiltVoiceConfig | None¶
- replicated_voice_config: ReplicatedVoiceConfig | None¶
- voice: str | None¶
- class genai.types.VoiceConfigDict¶
Bases:
TypedDictThe configuration for the voice to use.
- prebuilt_voice_config: PrebuiltVoiceConfigDict | None¶
The configuration for a prebuilt voice.
- replicated_voice_config: ReplicatedVoiceConfigDict | None¶
The configuration for a replicated voice, which is a clone of a user’s voice that can be used for speech synthesis. If this is unset, a default voice is used.
- voice: str | None¶
The speaker identifier for synthesis.
- class genai.types.VoiceConsentSignature(**data)¶
Bases:
BaseModelThe signature of the voice consent check.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- signature: str | None¶
- class genai.types.VoiceConsentSignatureDict¶
Bases:
TypedDictThe signature of the voice consent check.
- signature: str | None¶
The signature string.
- class genai.types.WebSearch(**data)¶
Bases:
BaseModelStandard web search for grounding and related configurations.
Only text results are returned.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.WebSearchDict¶
Bases:
TypedDictStandard web search for grounding and related configurations.
Only text results are returned.
- class genai.types.WebhookConfig(**data)¶
Bases:
BaseModelConfiguration for webhook notifications.
Used to configure webhook endpoints that will receive notifications when long-running operations (e.g., batch jobs, video generation) complete.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- uris: list[str] | None¶
- user_metadata: dict[str, Any] | None¶
- class genai.types.WebhookConfigDict¶
Bases:
TypedDictConfiguration for webhook notifications.
Used to configure webhook endpoints that will receive notifications when long-running operations (e.g., batch jobs, video generation) complete.
- uris: list[str] | None¶
The webhook URIs to receive notifications. If set, these webhook URIs will be used instead of the registered webhooks.
- user_metadata: dict[str, Any] | None¶
User metadata that will be included in each webhook event notification. Use this to attach custom key-value data to correlate webhook events with your internal systems.
- class genai.types.WeightedPrompt(**data)¶
Bases:
BaseModelMaps a prompt to a relative weight to steer music generation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- text: str | None¶
- weight: float | None¶
- class genai.types.WeightedPromptDict¶
Bases:
TypedDictMaps a prompt to a relative weight to steer music generation.
- text: str | None¶
Text prompt.
- weight: float | None¶
Weight of the prompt. The weight is used to control the relative importance of the prompt. Higher weights are more important than lower weights.
Weight must not be 0. Weights of all weighted_prompts in this LiveMusicClientContent message will be normalized.
- class genai.types.WhiteSpaceConfig(**data)¶
Bases:
BaseModelConfiguration for a white space chunking algorithm.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- max_overlap_tokens: int | None¶
- max_tokens_per_chunk: int | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class genai.types.WhiteSpaceConfigDict¶
Bases:
TypedDictConfiguration for a white space chunking algorithm.
- max_overlap_tokens: int | None¶
Maximum number of overlapping tokens between two adjacent chunks.
- max_tokens_per_chunk: int | None¶
Maximum number of tokens per chunk.
- class genai.types.WordInfo(**data)¶
Bases:
BaseModelInformation about a single recognized word.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- end_offset: str | None¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'defer_build': True, 'extra': 'forbid', 'from_attributes': True, 'ignored_types': (<class 'typing.TypeVar'>,), 'populate_by_name': True, 'protected_namespaces': (), 'ser_json_bytes': 'base64', 'val_json_bytes': 'base64', 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- start_offset: str | None¶
- word: str | None¶
- class genai.types.WordInfoDict¶
Bases:
TypedDictInformation about a single recognized word.
- end_offset: str | None¶
End offset in time of the word relative to the start of the audio.
- start_offset: str | None¶
Start offset in time of the word relative to the start of the audio.
- word: str | None¶
Transcript of the word.