Service Client: Google::Ai::Generativelanguage::V1beta::GenerativeService::GenerativeServiceClient
Client stub representing the remote GenerativeService gRPC service. Delegates call dispatching to Google::gRPC::Client.
target
The endpoint target address. Defaults to ai.googleapis.com:443.
credentials
The authentication credentials provider. Defaults to application default credentials via Google::Auth.
NAME
Google::Ai::Generativelanguage::V1beta::GenerativeService - Compiled Protocol Buffers messages for google/ai/generativelanguage/v1beta/generative_service.proto
SYNOPSIS
use Google::Ai::Generativelanguage::V1beta::GenerativeService;
my $msg = Google::Ai::Generativelanguage::V1beta::GenerativeService::GenerateContentRequest->new({
model => $model,
system_instruction => $system_instruction,
contents => $contents,
tools => $tools,
});
# Read or update a field
my $val = $msg->model();
# Binary wire-format roundtrip
my $bytes = $msg->serialize();
my $decoded = Google::Ai::Generativelanguage::V1beta::GenerativeService::GenerateContentRequest->parse($bytes);
# Canonical ProtoJSON
my $json = $msg->to_json();
DESCRIPTION
Auto-generated Protobuf message classes compiled from google/ai/generativelanguage/v1beta/generative_service.proto. All message classes inherit from Protobuf::Message and support new(), serialize(), parse(), to_json(), from_json(), to_text(), and to_perl().
MESSAGES
Google::Ai::Generativelanguage::V1beta::GenerativeService::GenerateContentRequest
Request to generate a completion from the model.
Inherits from Protobuf::Message.
Accessors
$msg->model()/$msg->model($value)Type:
StringRequired. The name of the `Model` to use for generating the completion.
Format: `models/{model}`.
$msg->system_instruction()/$msg->system_instruction($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::Content)Optional. Developer set [system instruction(s)](https://ai.google.dev/gemini-api/docs/system-instructions). Currently, text only.
$msg->contents()/$msg->contents($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::Content)Required. The content of the current conversation with the model.
For single-turn queries, this is a single instance. For multi-turn queries like [chat](https://ai.google.dev/gemini-api/docs/text-generation#chat), this is a repeated field that contains the conversation history and the latest request.
$msg->tools()/$msg->tools($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::Tool)Optional. 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`. Supported `Tool`s are `Function` and `code_execution`. Refer to the [Function calling](https://ai.google.dev/gemini-api/docs/function-calling) and the [Code execution](https://ai.google.dev/gemini-api/docs/code-execution) guides to learn more.
$msg->tool_config()/$msg->tool_config($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::ToolConfig)Optional. Tool configuration for any `Tool` specified in the request. Refer to the [Function calling guide](https://ai.google.dev/gemini-api/docs/function-calling#function_calling_mode) for a usage example.
$msg->safety_settings()/$msg->safety_settings($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Safety::SafetySetting)Optional. A list of unique `SafetySetting` instances for blocking unsafe content.
This will be enforced on the `GenerateContentRequest.contents` and `GenerateContentResponse.candidates`. There should not be more than one setting for each `SafetyCategory` type. The API will block any contents and responses that fail to meet the thresholds set by these settings. This list overrides the default settings for each `SafetyCategory` specified in the safety_settings. If there is no `SafetySetting` for a given `SafetyCategory` provided in the list, the API will use the default safety setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT, HARM_CATEGORY_HARASSMENT, HARM_CATEGORY_CIVIC_INTEGRITY are supported. Refer to the [guide](https://ai.google.dev/gemini-api/docs/safety-settings) for detailed information on available safety settings. Also refer to the [Safety guidance](https://ai.google.dev/gemini-api/docs/safety-guidance) to learn how to incorporate safety considerations in your AI applications.
$msg->generation_config()/$msg->generation_config($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::GenerationConfig)Optional. Configuration options for model generation and outputs.
$msg->cached_content()/$msg->cached_content($value)Type:
StringOptional. The name of the content [cached](https://ai.google.dev/gemini-api/docs/caching) to use as context to serve the prediction. Format: `cachedContents/{cachedContent}`
Google::Ai::Generativelanguage::V1beta::GenerativeService::PrebuiltVoiceConfig
The configuration for the prebuilt speaker to use.
Inherits from Protobuf::Message.
Accessors
$msg->voice_name()/$msg->voice_name($value)Type:
StringThe name of the preset voice to use.
Google::Ai::Generativelanguage::V1beta::GenerativeService::VoiceConfig
The configuration for the voice to use.
Inherits from Protobuf::Message.
Accessors
$msg->prebuilt_voice_config()/$msg->prebuilt_voice_config($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::PrebuiltVoiceConfig)The configuration for the prebuilt voice to use.
Google::Ai::Generativelanguage::V1beta::GenerativeService::SpeakerVoiceConfig
The configuration for a single speaker in a multi speaker setup.
Inherits from Protobuf::Message.
Accessors
$msg->speaker()/$msg->speaker($value)Type:
StringRequired. The name of the speaker to use. Should be the same as in the prompt.
$msg->voice_config()/$msg->voice_config($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::VoiceConfig)Required. The configuration for the voice to use.
Google::Ai::Generativelanguage::V1beta::GenerativeService::MultiSpeakerVoiceConfig
The configuration for the multi-speaker setup.
Inherits from Protobuf::Message.
Accessors
$msg->speaker_voice_configs()/$msg->speaker_voice_configs($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::SpeakerVoiceConfig)Required. All the enabled speaker voices.
Google::Ai::Generativelanguage::V1beta::GenerativeService::SpeechConfig
The speech generation config.
Inherits from Protobuf::Message.
Accessors
$msg->voice_config()/$msg->voice_config($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::VoiceConfig)The configuration in case of single-voice output.
$msg->multi_speaker_voice_config()/$msg->multi_speaker_voice_config($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::MultiSpeakerVoiceConfig)Optional. The configuration for the multi-speaker setup. It is mutually exclusive with the voice_config field.
$msg->language_code()/$msg->language_code($value)Type:
StringOptional. Language code (in BCP 47 format, e.g. "en-US") for speech synthesis.
Valid values are: de-DE, en-AU, en-GB, en-IN, en-US, es-US, fr-FR, hi-IN, pt-BR, ar-XA, es-ES, fr-CA, id-ID, it-IT, ja-JP, tr-TR, vi-VN, bn-IN, gu-IN, kn-IN, ml-IN, mr-IN, ta-IN, te-IN, nl-NL, ko-KR, cmn-CN, pl-PL, ru-RU, and th-TH.
Google::Ai::Generativelanguage::V1beta::GenerativeService::ThinkingConfig
Config for thinking features.
Inherits from Protobuf::Message.
Accessors
$msg->include_thoughts()/$msg->include_thoughts($value)Type:
BoolIndicates whether to include thoughts in the response. If true, thoughts are returned only when available.
$msg->thinking_budget()/$msg->thinking_budget($value)Type:
Int32The number of thoughts tokens that the model should generate.
Google::Ai::Generativelanguage::V1beta::GenerativeService::ImageConfig
Config for image generation features.
Inherits from Protobuf::Message.
Accessors
$msg->aspect_ratio()/$msg->aspect_ratio($value)Type:
StringOptional. The aspect ratio of the image to generate. Supported aspect ratios: 1:1, 2:3, 3:2, 3:4, 4:3, 9:16, 16:9, 21:9.
If not specified, the model will choose a default aspect ratio based on any reference images provided.
Google::Ai::Generativelanguage::V1beta::GenerativeService::GenerationConfig
Configuration options for model generation and outputs. Not all parameters are configurable for every model.
Inherits from Protobuf::Message.
Accessors
$msg->candidate_count()/$msg->candidate_count($value)Type:
Int32Optional. Number of generated responses to return. If unset, this will default to 1. Please note that this doesn't work for previous generation models (Gemini 1.0 family)
$msg->stop_sequences()/$msg->stop_sequences($value)Type:
StringOptional. The set of character sequences (up to 5) that will stop output generation. If specified, the API will stop at the first appearance of a `stop_sequence`. The stop sequence will not be included as part of the response.
$msg->max_output_tokens()/$msg->max_output_tokens($value)Type:
Int32Optional. The maximum number of tokens to include in a response candidate.
Note: The default value varies by model, see the `Model.output_token_limit` attribute of the `Model` returned from the `getModel` function.
$msg->temperature()/$msg->temperature($value)Type:
FloatOptional. Controls the randomness of the output.
Note: The default value varies by model, see the `Model.temperature` attribute of the `Model` returned from the `getModel` function.
Values can range from [0.0, 2.0].
$msg->top_p()/$msg->top_p($value)Type:
FloatOptional. The maximum cumulative probability of tokens to consider when sampling.
The model uses combined Top-k and Top-p (nucleus) sampling.
Tokens are sorted based on their assigned probabilities so that only the most likely tokens are considered. Top-k sampling directly limits the maximum number of tokens to consider, while Nucleus sampling limits the number of tokens based on the cumulative probability.
Note: The default value varies by `Model` and is specified by the`Model.top_p` attribute returned from the `getModel` function. An empty `top_k` attribute indicates that the model doesn't apply top-k sampling and doesn't allow setting `top_k` on requests.
$msg->top_k()/$msg->top_k($value)Type:
Int32Optional. The maximum number of tokens to consider when sampling.
Gemini models use Top-p (nucleus) sampling or a combination of Top-k and nucleus sampling. Top-k sampling considers the set of `top_k` most probable tokens. Models running with nucleus sampling don't allow top_k setting.
Note: The default value varies by `Model` and is specified by the`Model.top_p` attribute returned from the `getModel` function. An empty `top_k` attribute indicates that the model doesn't apply top-k sampling and doesn't allow setting `top_k` on requests.
$msg->seed()/$msg->seed($value)Type:
Int32Optional. Seed used in decoding. If not set, the request uses a randomly generated seed.
$msg->response_mime_type()/$msg->response_mime_type($value)Type:
StringOptional. MIME type of the generated candidate text. Supported MIME types are: `text/plain`: (default) Text output. `application/json`: JSON response in the response candidates. `text/x.enum`: ENUM as a string response in the response candidates. Refer to the [docs](https://ai.google.dev/gemini-api/docs/prompting_with_media#plain_text_formats) for a list of all supported text MIME types.
$msg->response_schema()/$msg->response_schema($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::Schema)Optional. Output schema of the generated candidate text. Schemas must be a subset of the [OpenAPI schema](https://spec.openapis.org/oas/v3.0.3#schema) and can be objects, primitives or arrays.
If set, a compatible `response_mime_type` must also be set. Compatible MIME types: `application/json`: Schema for JSON response. Refer to the [JSON text generation guide](https://ai.google.dev/gemini-api/docs/json-mode) for more details.
$msg->response_json_schema()/$msg->response_json_schema($value)Type:
Message(Google::Protobuf::Struct::Value)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.
$msg->response_json_schema_ordered()/$msg->response_json_schema_ordered($value)Type:
Message(Google::Protobuf::Struct::Value)Optional. An internal detail. Use `responseJsonSchema` rather than this field.
$msg->presence_penalty()/$msg->presence_penalty($value)Type:
FloatOptional. Presence penalty applied to the next token's logprobs if the token has already been seen in the response.
This penalty is binary on/off and not dependant on the number of times the token is used (after the first). Use [frequency_penalty][google.ai.generativelanguage.v1beta.GenerationConfig.frequency_penalty] for a penalty that increases with each use.
A positive penalty will discourage the use of tokens that have already been used in the response, increasing the vocabulary.
A negative penalty will encourage the use of tokens that have already been used in the response, decreasing the vocabulary.
$msg->frequency_penalty()/$msg->frequency_penalty($value)Type:
FloatOptional. Frequency penalty applied to the next token's logprobs, multiplied by the number of times each token has been seen in the respponse so far.
A positive penalty will discourage the use of tokens that have already been used, proportional to the number of times the token has been used: The more a token is used, the more difficult it is for the model to use that token again increasing the vocabulary of responses.
Caution: A _negative_ penalty will encourage the model to reuse tokens proportional to the number of times the token has been used. Small negative values will reduce the vocabulary of a response. Larger negative values will cause the model to start repeating a common token until it hits the [max_output_tokens][google.ai.generativelanguage.v1beta.GenerationConfig.max_output_tokens] limit.
$msg->response_logprobs()/$msg->response_logprobs($value)Type:
BoolOptional. If true, export the logprobs results in response.
$msg->logprobs()/$msg->logprobs($value)Type:
Int32Optional. Only valid if [response_logprobs=True][google.ai.generativelanguage.v1beta.GenerationConfig.response_logprobs]. This sets the number of top logprobs to return at each decoding step in the [Candidate.logprobs_result][google.ai.generativelanguage.v1beta.Candidate.logprobs_result]. The number must be in the range of [0, 20].
$msg->enable_enhanced_civic_answers()/$msg->enable_enhanced_civic_answers($value)Type:
BoolOptional. Enables enhanced civic answers. It may not be available for all models.
$msg->response_modalities()/$msg->response_modalities($value)Type:
Enum(Google::Ai::Generativelanguage::V1beta::GenerationConfig::Modality)Optional. The requested modalities of the response. Represents the set of modalities that the model can return, and should be expected in the response. This is an exact match to the modalities of the response.
A model may have multiple combinations of supported modalities. If the requested modalities do not match any of the supported combinations, an error will be returned.
An empty list is equivalent to requesting only text.
$msg->speech_config()/$msg->speech_config($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::SpeechConfig)Optional. The speech generation config.
$msg->thinking_config()/$msg->thinking_config($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::ThinkingConfig)Optional. Config for thinking features. An error will be returned if this field is set for models that don't support thinking.
$msg->image_config()/$msg->image_config($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::ImageConfig)Optional. Config for image generation. An error will be returned if this field is set for models that don't support these config options.
$msg->media_resolution()/$msg->media_resolution($value)Type:
Enum(Google::Ai::Generativelanguage::V1beta::GenerationConfig::MediaResolution)Optional. If specified, the media resolution specified will be used.
Enum: GenerationConfig::Modality
MODALITY_UNSPECIFIED=>0TEXT=>1IMAGE=>2AUDIO=>3
Enum: GenerationConfig::MediaResolution
MEDIA_RESOLUTION_UNSPECIFIED=>0MEDIA_RESOLUTION_LOW=>1MEDIA_RESOLUTION_MEDIUM=>2MEDIA_RESOLUTION_HIGH=>3
Google::Ai::Generativelanguage::V1beta::GenerativeService::SemanticRetrieverConfig
Configuration for retrieving grounding content from a `Corpus` or `Document` created using the Semantic Retriever API.
Inherits from Protobuf::Message.
Accessors
$msg->source()/$msg->source($value)Type:
StringRequired. Name of the resource for retrieval. Example: `corpora/123` or `corpora/123/documents/abc`.
$msg->query()/$msg->query($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::Content)Required. Query to use for matching `Chunk`s in the given resource by similarity.
$msg->metadata_filters()/$msg->metadata_filters($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Retriever::MetadataFilter)Optional. Filters for selecting `Document`s and/or `Chunk`s from the resource.
$msg->max_chunks_count()/$msg->max_chunks_count($value)Type:
Int32Optional. Maximum number of relevant `Chunk`s to retrieve.
$msg->minimum_relevance_score()/$msg->minimum_relevance_score($value)Type:
FloatOptional. Minimum relevance score for retrieved relevant `Chunk`s.
Google::Ai::Generativelanguage::V1beta::GenerativeService::GenerateContentResponse
Response from the model supporting multiple candidate responses.
Safety ratings and content filtering are reported for both prompt in `GenerateContentResponse.prompt_feedback` and for each candidate in `finish_reason` and in `safety_ratings`. The API: - Returns either all requested candidates or none of them - Returns no candidates at all only if there was something wrong with the prompt (check `prompt_feedback`) - Reports feedback on each candidate in `finish_reason` and `safety_ratings`.
Inherits from Protobuf::Message.
Accessors
$msg->candidates()/$msg->candidates($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::Candidate)Candidate responses from the model.
$msg->prompt_feedback()/$msg->prompt_feedback($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::GenerateContentResponse::PromptFeedback)Returns the prompt's feedback related to the content filters.
$msg->usage_metadata()/$msg->usage_metadata($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::GenerateContentResponse::UsageMetadata)Output only. Metadata on the generation requests' token usage.
$msg->model_version()/$msg->model_version($value)Type:
StringOutput only. The model version used to generate the response.
$msg->response_id()/$msg->response_id($value)Type:
StringOutput only. response_id is used to identify each response.
Google::Ai::Generativelanguage::V1beta::GenerativeService::Candidate
A response candidate generated from the model.
Inherits from Protobuf::Message.
Accessors
$msg->index()/$msg->index($value)Type:
Int32Output only. Index of the candidate in the list of response candidates.
$msg->content()/$msg->content($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::Content)Output only. Generated content returned from the model.
$msg->finish_reason()/$msg->finish_reason($value)Type:
Enum(Google::Ai::Generativelanguage::V1beta::Candidate::FinishReason)Optional. Output only. The reason why the model stopped generating tokens.
If empty, the model has not stopped generating tokens.
$msg->finish_message()/$msg->finish_message($value)Type:
StringOptional. Output only. Details the reason why the model stopped generating tokens. This is populated only when `finish_reason` is set.
$msg->safety_ratings()/$msg->safety_ratings($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Safety::SafetyRating)List of ratings for the safety of a response candidate.
There is at most one rating per category.
$msg->citation_metadata()/$msg->citation_metadata($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Citation::CitationMetadata)Output only. Citation information for model-generated candidate.
This field may be populated with recitation information for any text included in the `content`. These are passages that are "recited" from copyrighted material in the foundational LLM's training data.
$msg->token_count()/$msg->token_count($value)Type:
Int32Output only. Token count for this candidate.
$msg->grounding_attributions()/$msg->grounding_attributions($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::GroundingAttribution)Output only. Attribution information for sources that contributed to a grounded answer.
This field is populated for `GenerateAnswer` calls.
$msg->grounding_metadata()/$msg->grounding_metadata($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::GroundingMetadata)Output only. Grounding metadata for the candidate.
This field is populated for `GenerateContent` calls.
$msg->avg_logprobs()/$msg->avg_logprobs($value)Type:
DoubleOutput only. Average log probability score of the candidate.
$msg->logprobs_result()/$msg->logprobs_result($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::LogprobsResult)Output only. Log-likelihood scores for the response tokens and top tokens
$msg->url_context_metadata()/$msg->url_context_metadata($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::UrlContextMetadata)Output only. Metadata related to url context retrieval tool.
Enum: Candidate::FinishReason
FINISH_REASON_UNSPECIFIED=>0STOP=>1MAX_TOKENS=>2SAFETY=>3RECITATION=>4LANGUAGE=>6OTHER=>5BLOCKLIST=>7PROHIBITED_CONTENT=>8SPII=>9MALFORMED_FUNCTION_CALL=>10IMAGE_SAFETY=>11IMAGE_PROHIBITED_CONTENT=>14IMAGE_OTHER=>15NO_IMAGE=>16IMAGE_RECITATION=>17UNEXPECTED_TOOL_CALL=>12TOO_MANY_TOOL_CALLS=>13
Google::Ai::Generativelanguage::V1beta::GenerativeService::UrlContextMetadata
Metadata related to url context retrieval tool.
Inherits from Protobuf::Message.
Accessors
$msg->url_metadata()/$msg->url_metadata($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::UrlMetadata)List of url context.
Google::Ai::Generativelanguage::V1beta::GenerativeService::UrlMetadata
Context of the a single url retrieval.
Inherits from Protobuf::Message.
Accessors
$msg->retrieved_url()/$msg->retrieved_url($value)Type:
StringRetrieved url by the tool.
$msg->url_retrieval_status()/$msg->url_retrieval_status($value)Type:
Enum(Google::Ai::Generativelanguage::V1beta::UrlMetadata::UrlRetrievalStatus)Status of the url retrieval.
Enum: UrlMetadata::UrlRetrievalStatus
URL_RETRIEVAL_STATUS_UNSPECIFIED=>0URL_RETRIEVAL_STATUS_SUCCESS=>1URL_RETRIEVAL_STATUS_ERROR=>2URL_RETRIEVAL_STATUS_PAYWALL=>3URL_RETRIEVAL_STATUS_UNSAFE=>4
Google::Ai::Generativelanguage::V1beta::GenerativeService::LogprobsResult
Logprobs Result
Inherits from Protobuf::Message.
Accessors
$msg->log_probability_sum()/$msg->log_probability_sum($value)Type:
FloatSum of log probabilities for all tokens.
$msg->top_candidates()/$msg->top_candidates($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::LogprobsResult::TopCandidates)Length = total number of decoding steps.
$msg->chosen_candidates()/$msg->chosen_candidates($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::LogprobsResult::Candidate)Length = total number of decoding steps. The chosen candidates may or may not be in top_candidates.
Google::Ai::Generativelanguage::V1beta::GenerativeService::AttributionSourceId
Identifier for the source contributing to this attribution.
Inherits from Protobuf::Message.
Accessors
$msg->grounding_passage()/$msg->grounding_passage($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::AttributionSourceId::GroundingPassageId)Identifier for an inline passage.
$msg->semantic_retriever_chunk()/$msg->semantic_retriever_chunk($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::AttributionSourceId::SemanticRetrieverChunk)Identifier for a `Chunk` fetched via Semantic Retriever.
Google::Ai::Generativelanguage::V1beta::GenerativeService::GroundingAttribution
Attribution for a source that contributed to an answer.
Inherits from Protobuf::Message.
Accessors
$msg->source_id()/$msg->source_id($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::AttributionSourceId)Output only. Identifier for the source contributing to this attribution.
$msg->content()/$msg->content($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::Content)Grounding source content that makes up this attribution.
Google::Ai::Generativelanguage::V1beta::GenerativeService::RetrievalMetadata
Metadata related to retrieval in the grounding flow.
Inherits from Protobuf::Message.
Accessors
$msg->google_search_dynamic_retrieval_score()/$msg->google_search_dynamic_retrieval_score($value)Type:
FloatOptional. 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.
Google::Ai::Generativelanguage::V1beta::GenerativeService::GroundingMetadata
Metadata returned to client when grounding is enabled.
Inherits from Protobuf::Message.
Accessors
$msg->search_entry_point()/$msg->search_entry_point($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::SearchEntryPoint)Optional. Google search entry for the following-up web searches.
$msg->grounding_chunks()/$msg->grounding_chunks($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::GroundingChunk)List of supporting references retrieved from specified grounding source.
$msg->grounding_supports()/$msg->grounding_supports($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::GroundingSupport)List of grounding support.
$msg->retrieval_metadata()/$msg->retrieval_metadata($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::RetrievalMetadata)Metadata related to retrieval in the grounding flow.
$msg->web_search_queries()/$msg->web_search_queries($value)Type:
StringWeb search queries for the following-up web search.
$msg->google_maps_widget_context_token()/$msg->google_maps_widget_context_token($value)Type:
StringOptional. Resource name of the Google Maps widget context token that can be used with the PlacesContextElement widget in order to render contextual data. Only populated in the case that grounding with Google Maps is enabled.
Google::Ai::Generativelanguage::V1beta::GenerativeService::SearchEntryPoint
Google search entry point.
Inherits from Protobuf::Message.
Accessors
$msg->rendered_content()/$msg->rendered_content($value)Type:
StringOptional. Web content snippet that can be embedded in a web page or an app webview.
$msg->sdk_blob()/$msg->sdk_blob($value)Type:
BytesOptional. Base64 encoded JSON representing array of <search term, search url> tuple.
Google::Ai::Generativelanguage::V1beta::GenerativeService::GroundingChunk
Grounding chunk.
Inherits from Protobuf::Message.
Accessors
$msg->web()/$msg->web($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::GroundingChunk::Web)Grounding chunk from the web.
$msg->retrieved_context()/$msg->retrieved_context($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::GroundingChunk::RetrievedContext)Optional. Grounding chunk from context retrieved by the file search tool.
$msg->maps()/$msg->maps($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::GroundingChunk::Maps)Optional. Grounding chunk from Google Maps.
Google::Ai::Generativelanguage::V1beta::GenerativeService::Segment
Segment of the content.
Inherits from Protobuf::Message.
Accessors
$msg->part_index()/$msg->part_index($value)Type:
Int32Output only. The index of a Part object within its parent Content object.
$msg->start_index()/$msg->start_index($value)Type:
Int32Output only. Start index in the given Part, measured in bytes. Offset from the start of the Part, inclusive, starting at zero.
$msg->end_index()/$msg->end_index($value)Type:
Int32Output only. End index in the given Part, measured in bytes. Offset from the start of the Part, exclusive, starting at zero.
$msg->text()/$msg->text($value)Type:
StringOutput only. The text corresponding to the segment from the response.
Google::Ai::Generativelanguage::V1beta::GenerativeService::GroundingSupport
Grounding support.
Inherits from Protobuf::Message.
Accessors
$msg->segment()/$msg->segment($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::Segment)Segment of the content this support belongs to.
$msg->grounding_chunk_indices()/$msg->grounding_chunk_indices($value)Type:
Int32A 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.
$msg->confidence_scores()/$msg->confidence_scores($value)Type:
FloatConfidence 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.
Google::Ai::Generativelanguage::V1beta::GenerativeService::GenerateAnswerRequest
Request to generate a grounded answer from the `Model`.
Inherits from Protobuf::Message.
Accessors
$msg->inline_passages()/$msg->inline_passages($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::GroundingPassages)Passages provided inline with the request.
$msg->semantic_retriever()/$msg->semantic_retriever($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::SemanticRetrieverConfig)Content retrieved from resources created via the Semantic Retriever API.
$msg->model()/$msg->model($value)Type:
StringRequired. The name of the `Model` to use for generating the grounded response.
Format: `model=models/{model}`.
$msg->contents()/$msg->contents($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::Content)Required. The content of the current conversation with the `Model`. For single-turn queries, this is a single question to answer. For multi-turn queries, this is a repeated field that contains conversation history and the last `Content` in the list containing the question.
Note: `GenerateAnswer` only supports queries in English.
$msg->answer_style()/$msg->answer_style($value)Type:
Enum(Google::Ai::Generativelanguage::V1beta::GenerateAnswerRequest::AnswerStyle)Required. Style in which answers should be returned.
$msg->safety_settings()/$msg->safety_settings($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Safety::SafetySetting)Optional. A list of unique `SafetySetting` instances for blocking unsafe content.
This will be enforced on the `GenerateAnswerRequest.contents` and `GenerateAnswerResponse.candidate`. There should not be more than one setting for each `SafetyCategory` type. The API will block any contents and responses that fail to meet the thresholds set by these settings. This list overrides the default settings for each `SafetyCategory` specified in the safety_settings. If there is no `SafetySetting` for a given `SafetyCategory` provided in the list, the API will use the default safety setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT, HARM_CATEGORY_HARASSMENT are supported. Refer to the [guide](https://ai.google.dev/gemini-api/docs/safety-settings) for detailed information on available safety settings. Also refer to the [Safety guidance](https://ai.google.dev/gemini-api/docs/safety-guidance) to learn how to incorporate safety considerations in your AI applications.
$msg->temperature()/$msg->temperature($value)Type:
FloatOptional. Controls the randomness of the output.
Values can range from [0.0,1.0], inclusive. A value closer to 1.0 will produce responses that are more varied and creative, while a value closer to 0.0 will typically result in more straightforward responses from the model. A low temperature (~0.2) is usually recommended for Attributed-Question-Answering use cases.
Enum: GenerateAnswerRequest::AnswerStyle
ANSWER_STYLE_UNSPECIFIED=>0ABSTRACTIVE=>1EXTRACTIVE=>2VERBOSE=>3
Google::Ai::Generativelanguage::V1beta::GenerativeService::GenerateAnswerResponse
Response from the model for a grounded answer.
Inherits from Protobuf::Message.
Accessors
$msg->answer()/$msg->answer($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::Candidate)Candidate answer from the model.
Note: The model *always* attempts to provide a grounded answer, even when the answer is unlikely to be answerable from the given passages. In that case, a low-quality or ungrounded answer may be provided, along with a low `answerable_probability`.
$msg->answerable_probability()/$msg->answerable_probability($value)Type:
FloatOutput only. The model's estimate of the probability that its answer is correct and grounded in the input passages.
A low `answerable_probability` indicates that the answer might not be grounded in the sources.
When `answerable_probability` is low, you may want to:
* Display a message to the effect of "We couldn’t answer that question" to the user. * Fall back to a general-purpose LLM that answers the question from world knowledge. The threshold and nature of such fallbacks will depend on individual use cases. `0.5` is a good starting threshold.
$msg->input_feedback()/$msg->input_feedback($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::GenerateAnswerResponse::InputFeedback)Output only. Feedback related to the input data used to answer the question, as opposed to the model-generated response to the question.
The input data can be one or more of the following:
- Question specified by the last entry in `GenerateAnswerRequest.content` - Conversation history specified by the other entries in `GenerateAnswerRequest.content` - Grounding sources (`GenerateAnswerRequest.semantic_retriever` or `GenerateAnswerRequest.inline_passages`)
Google::Ai::Generativelanguage::V1beta::GenerativeService::EmbedContentRequest
Request containing the `Content` for the model to embed.
Inherits from Protobuf::Message.
Accessors
$msg->model()/$msg->model($value)Type:
StringRequired. The model's resource name. This serves as an ID for the Model to use.
This name should match a model name returned by the `ListModels` method.
Format: `models/{model}`
$msg->content()/$msg->content($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::Content)Required. The content to embed. Only the `parts.text` fields will be counted.
$msg->task_type()/$msg->task_type($value)Type:
Enum(Google::Ai::Generativelanguage::V1beta::TaskType)Optional. Optional task type for which the embeddings will be used. Not supported on earlier models (`models/embedding-001`).
$msg->title()/$msg->title($value)Type:
StringOptional. An optional title for the text. Only applicable when TaskType is `RETRIEVAL_DOCUMENT`.
Note: Specifying a `title` for `RETRIEVAL_DOCUMENT` provides better quality embeddings for retrieval.
$msg->output_dimensionality()/$msg->output_dimensionality($value)Type:
Int32Optional. Optional 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`).
Google::Ai::Generativelanguage::V1beta::GenerativeService::ContentEmbedding
A list of floats representing an embedding.
Inherits from Protobuf::Message.
Accessors
$msg->values()/$msg->values($value)Type:
FloatThe embedding values.
Google::Ai::Generativelanguage::V1beta::GenerativeService::EmbedContentResponse
The response to an `EmbedContentRequest`.
Inherits from Protobuf::Message.
Accessors
$msg->embedding()/$msg->embedding($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::ContentEmbedding)Output only. The embedding generated from the input content.
Google::Ai::Generativelanguage::V1beta::GenerativeService::BatchEmbedContentsRequest
Batch request to get embeddings from the model for a list of prompts.
Inherits from Protobuf::Message.
Accessors
$msg->model()/$msg->model($value)Type:
StringRequired. The model's resource name. This serves as an ID for the Model to use.
This name should match a model name returned by the `ListModels` method.
Format: `models/{model}`
$msg->requests()/$msg->requests($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::EmbedContentRequest)Required. Embed requests for the batch. The model in each of these requests must match the model specified `BatchEmbedContentsRequest.model`.
Google::Ai::Generativelanguage::V1beta::GenerativeService::BatchEmbedContentsResponse
The response to a `BatchEmbedContentsRequest`.
Inherits from Protobuf::Message.
Accessors
$msg->embeddings()/$msg->embeddings($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::ContentEmbedding)Output only. The embeddings for each request, in the same order as provided in the batch request.
Google::Ai::Generativelanguage::V1beta::GenerativeService::CountTokensRequest
Counts the number of tokens in the `prompt` sent to a model.
Models may tokenize text differently, so each model may return a different `token_count`.
Inherits from Protobuf::Message.
Accessors
$msg->model()/$msg->model($value)Type:
StringRequired. The model's resource name. This serves as an ID for the Model to use.
This name should match a model name returned by the `ListModels` method.
Format: `models/{model}`
$msg->contents()/$msg->contents($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::Content)Optional. The input given to the model as a prompt. This field is ignored when `generate_content_request` is set.
$msg->generate_content_request()/$msg->generate_content_request($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::GenerateContentRequest)Optional. The overall input given to the `Model`. This includes the prompt as well as other model steering information like [system instructions](https://ai.google.dev/gemini-api/docs/system-instructions), and/or function declarations for [function calling](https://ai.google.dev/gemini-api/docs/function-calling). `Model`s/`Content`s and `generate_content_request`s are mutually exclusive. You can either send `Model` + `Content`s or a `generate_content_request`, but never both.
Google::Ai::Generativelanguage::V1beta::GenerativeService::CountTokensResponse
A response from `CountTokens`.
It returns the model's `token_count` for the `prompt`.
Inherits from Protobuf::Message.
Accessors
$msg->total_tokens()/$msg->total_tokens($value)Type:
Int32The number of tokens that the `Model` tokenizes the `prompt` into. Always non-negative.
$msg->cached_content_token_count()/$msg->cached_content_token_count($value)Type:
Int32Number of tokens in the cached part of the prompt (the cached content).
$msg->prompt_tokens_details()/$msg->prompt_tokens_details($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::ModalityTokenCount)Output only. List of modalities that were processed in the request input.
$msg->cache_tokens_details()/$msg->cache_tokens_details($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::ModalityTokenCount)Output only. List of modalities that were processed in the cached content.
Google::Ai::Generativelanguage::V1beta::GenerativeService::RealtimeInputConfig
Configures the realtime input behavior in `BidiGenerateContent`.
Inherits from Protobuf::Message.
Accessors
$msg->automatic_activity_detection()/$msg->automatic_activity_detection($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::RealtimeInputConfig::AutomaticActivityDetection)Optional. If not set, automatic activity detection is enabled by default. If automatic voice detection is disabled, the client must send activity signals.
$msg->activity_handling()/$msg->activity_handling($value)Type:
Enum(Google::Ai::Generativelanguage::V1beta::RealtimeInputConfig::ActivityHandling)Optional. Defines what effect activity has.
$msg->turn_coverage()/$msg->turn_coverage($value)Type:
Enum(Google::Ai::Generativelanguage::V1beta::RealtimeInputConfig::TurnCoverage)Optional. Defines which input is included in the user's turn.
Enum: RealtimeInputConfig::ActivityHandling
ACTIVITY_HANDLING_UNSPECIFIED=>0START_OF_ACTIVITY_INTERRUPTS=>1NO_INTERRUPTION=>2
Enum: RealtimeInputConfig::TurnCoverage
TURN_COVERAGE_UNSPECIFIED=>0TURN_INCLUDES_ONLY_ACTIVITY=>1TURN_INCLUDES_ALL_INPUT=>2
Google::Ai::Generativelanguage::V1beta::GenerativeService::SessionResumptionConfig
Session resumption configuration.
This message is included in the session configuration as `BidiGenerateContentSetup.session_resumption`. If configured, the server will send `SessionResumptionUpdate` messages.
Inherits from Protobuf::Message.
Accessors
$msg->handle()/$msg->handle($value)Type:
StringThe handle of a previous session. If not present then a new session is created.
Session handles come from `SessionResumptionUpdate.token` values in previous connections.
Google::Ai::Generativelanguage::V1beta::GenerativeService::ContextWindowCompressionConfig
Enables context window compression — a mechanism for managing the model's context window so that it does not exceed a given length.
Inherits from Protobuf::Message.
Accessors
$msg->sliding_window()/$msg->sliding_window($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::ContextWindowCompressionConfig::SlidingWindow)A sliding-window mechanism.
$msg->trigger_tokens()/$msg->trigger_tokens($value)Type:
Int64The number of tokens (before running a turn) required to trigger a context window compression.
This can be used to balance quality against latency as shorter context windows may result in faster model responses. However, any compression operation will cause a temporary latency increase, so they should not be triggered frequently.
If not set, the default is 80% of the model's context window limit. This leaves 20% for the next user request/model response.
Google::Ai::Generativelanguage::V1beta::GenerativeService::AudioTranscriptionConfig
The audio transcription configuration.
Inherits from Protobuf::Message.
Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentSetup
Message to be sent in the first (and only in the first) `BidiGenerateContentClientMessage`. Contains configuration that will apply for the duration of the streaming RPC.
Clients should wait for a `BidiGenerateContentSetupComplete` message before sending any additional messages.
Inherits from Protobuf::Message.
Accessors
$msg->model()/$msg->model($value)Type:
StringRequired. The model's resource name. This serves as an ID for the Model to use.
Format: `models/{model}`
$msg->generation_config()/$msg->generation_config($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::GenerationConfig)Optional. Generation config.
The following fields are not supported:
- `response_logprobs` - `response_mime_type` - `logprobs` - `response_schema` - `response_json_schema` - `stop_sequence` - `routing_config` - `audio_timestamp`$msg->system_instruction()/$msg->system_instruction($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::Content)Optional. 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.
$msg->tools()/$msg->tools($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::Tool)Optional. 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.
$msg->realtime_input_config()/$msg->realtime_input_config($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::RealtimeInputConfig)Optional. Configures the handling of realtime input.
$msg->session_resumption()/$msg->session_resumption($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::SessionResumptionConfig)Optional. Configures session resumption mechanism.
If included, the server will send `SessionResumptionUpdate` messages.
$msg->context_window_compression()/$msg->context_window_compression($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::ContextWindowCompressionConfig)Optional. Configures a context window compression mechanism.
If included, the server will automatically reduce the size of the context when it exceeds the configured length.
$msg->input_audio_transcription()/$msg->input_audio_transcription($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::AudioTranscriptionConfig)Optional. If set, enables transcription of voice input. The transcription aligns with the input audio language, if configured.
$msg->output_audio_transcription()/$msg->output_audio_transcription($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::AudioTranscriptionConfig)Optional. If set, enables transcription of the model's audio output. The transcription aligns with the language code specified for the output audio, if configured.
Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentClientContent
Incremental update of the current conversation delivered from the client. All of the content here is unconditionally 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.
Inherits from Protobuf::Message.
Accessors
$msg->turns()/$msg->turns($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::Content)Optional. 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 the latest request.
$msg->turn_complete()/$msg->turn_complete($value)Type:
BoolOptional. If true, indicates that the server content generation should start with the currently accumulated prompt. Otherwise, the server awaits additional messages before starting generation.
Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentRealtimeInput
User input that is sent in real time.
The different modalities (audio, video and text) are handled as concurrent streams. The ordering across these streams is not guaranteed.
This is different from [BidiGenerateContentClientContent][google.ai.generativelanguage.v1beta.BidiGenerateContentClientContent] in a few ways:
* Can be sent continuously without interruption to model generation. * If there is a need to mix data interleaved across the [BidiGenerateContentClientContent][google.ai.generativelanguage.v1beta.BidiGenerateContentClientContent] and the [BidiGenerateContentRealtimeInput][google.ai.generativelanguage.v1beta.BidiGenerateContentRealtimeInput], the 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.
Inherits from Protobuf::Message.
Accessors
$msg->media_chunks()/$msg->media_chunks($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::Blob)Optional. Inlined bytes data for media input. Multiple `media_chunks` are not supported, all but the first will be ignored.
DEPRECATED: Use one of `audio`, `video`, or `text` instead.
$msg->audio()/$msg->audio($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::Blob)Optional. These form the realtime audio input stream.
$msg->audio_stream_end()/$msg->audio_stream_end($value)Type:
BoolOptional. 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.
$msg->video()/$msg->video($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::Blob)Optional. These form the realtime video input stream.
$msg->text()/$msg->text($value)Type:
StringOptional. These form the realtime text input stream.
$msg->activity_start()/$msg->activity_start($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentRealtimeInput::ActivityStart)Optional. Marks the start of user activity. This can only be sent if automatic (i.e. server-side) activity detection is disabled.
$msg->activity_end()/$msg->activity_end($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentRealtimeInput::ActivityEnd)Optional. Marks the end of user activity. This can only be sent if automatic (i.e. server-side) activity detection is disabled.
Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentToolResponse
Client 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 these dedicated set of messages.
Inherits from Protobuf::Message.
Accessors
$msg->function_responses()/$msg->function_responses($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::FunctionResponse)Optional. The response to the function calls.
Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentClientMessage
Messages sent by the client in the BidiGenerateContent call.
Inherits from Protobuf::Message.
Accessors
$msg->setup()/$msg->setup($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentSetup)Optional. Session configuration sent only in the first client message.
$msg->client_content()/$msg->client_content($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentClientContent)Optional. Incremental update of the current conversation delivered from the client.
$msg->realtime_input()/$msg->realtime_input($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentRealtimeInput)Optional. User input that is sent in real time.
$msg->tool_response()/$msg->tool_response($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentToolResponse)Optional. Response to a `ToolCallMessage` received from the server.
Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentSetupComplete
Sent in response to a `BidiGenerateContentSetup` message from the client.
Inherits from Protobuf::Message.
Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentServerContent
Incremental 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.
Inherits from Protobuf::Message.
Accessors
$msg->model_turn()/$msg->model_turn($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::Content)Output only. The content that the model has generated as part of the current conversation with the user.
$msg->generation_complete()/$msg->generation_complete($value)Type:
BoolOutput only. 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.
$msg->turn_complete()/$msg->turn_complete($value)Type:
BoolOutput only. If true, indicates that the model has completed its turn. Generation will only start in response to additional client messages.
$msg->interrupted()/$msg->interrupted($value)Type:
BoolOutput only. If true, indicates that a client message has interrupted current model generation. If the client is playing out the content in real time, this is a good signal to stop and empty the current playback queue.
$msg->grounding_metadata()/$msg->grounding_metadata($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::GroundingMetadata)Output only. Grounding metadata for the generated content.
$msg->input_transcription()/$msg->input_transcription($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentTranscription)Output only. Input audio transcription. The transcription is sent independently of the other server messages and there is no guaranteed ordering.
$msg->output_transcription()/$msg->output_transcription($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentTranscription)Output only. Output audio transcription. These transcriptions are part of the Generation output of the server. The last output transcription of this turn is sent before either `generation_complete` or `interrupted`, which in turn are followed by `turn_complete`. There is no guaranteed exact ordering between transcriptions and other `model_turn` output but the server tries to send the transcripts close to the corresponding audio output.
$msg->url_context_metadata()/$msg->url_context_metadata($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::UrlContextMetadata)$msg->waiting_for_input()/$msg->waiting_for_input($value)Type:
BoolOutput only. 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.
Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentToolCall
Request for the client to execute the `function_calls` and return the responses with the matching `id`s.
Inherits from Protobuf::Message.
Accessors
$msg->function_calls()/$msg->function_calls($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::FunctionCall)Output only. The function call to be executed.
Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentToolCallCancellation
Notification for the client that a previously issued `ToolCallMessage` with the specified `id`s should not have been 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.
Inherits from Protobuf::Message.
Accessors
$msg->ids()/$msg->ids($value)Type:
StringOutput only. The ids of the tool calls to be cancelled.
Google::Ai::Generativelanguage::V1beta::GenerativeService::GoAway
A notice that the server will soon disconnect.
Inherits from Protobuf::Message.
Accessors
$msg->time_left()/$msg->time_left($value)Type:
Message(Google::Protobuf::Duration::Duration)The remaining time before the connection will be terminated as ABORTED.
This duration will never be less than a model-specific minimum, which will be specified together with the rate limits for the model.
Google::Ai::Generativelanguage::V1beta::GenerativeService::SessionResumptionUpdate
Update of the session resumption state.
Only sent if `BidiGenerateContentSetup.session_resumption` was set.
Inherits from Protobuf::Message.
Accessors
$msg->new_handle()/$msg->new_handle($value)Type:
StringNew handle that represents a state that can be resumed. Empty if `resumable`=false.
$msg->resumable()/$msg->resumable($value)Type:
BoolTrue if the current session can be resumed at this point.
Resumption is not possible at some points in the session. For example, when the model is executing function calls or generating. Resuming the session (using a previous session token) in such a state will result in some data loss. In these cases, `new_handle` will be empty and `resumable` will be false.
Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentTranscription
Transcription of audio (input or output).
Inherits from Protobuf::Message.
Accessors
$msg->text()/$msg->text($value)Type:
StringTranscription text.
Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentServerMessage
Response message for the BidiGenerateContent call.
Inherits from Protobuf::Message.
Accessors
$msg->setup_complete()/$msg->setup_complete($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentSetupComplete)Output only. Sent in response to a `BidiGenerateContentSetup` message from the client when setup is complete.
$msg->server_content()/$msg->server_content($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentServerContent)Output only. Content generated by the model in response to client messages.
$msg->tool_call()/$msg->tool_call($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentToolCall)Output only. Request for the client to execute the `function_calls` and return the responses with the matching `id`s.
$msg->tool_call_cancellation()/$msg->tool_call_cancellation($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::BidiGenerateContentToolCallCancellation)Output only. Notification for the client that a previously issued `ToolCallMessage` with the specified `id`s should be cancelled.
$msg->go_away()/$msg->go_away($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::GoAway)Output only. A notice that the server will soon disconnect.
$msg->session_resumption_update()/$msg->session_resumption_update($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::SessionResumptionUpdate)Output only. Update of the session resumption state.
$msg->usage_metadata()/$msg->usage_metadata($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::GenerativeService::UsageMetadata)Output only. Usage metadata about the response(s).
Google::Ai::Generativelanguage::V1beta::GenerativeService::UsageMetadata
Usage metadata about response(s).
Inherits from Protobuf::Message.
Accessors
$msg->prompt_token_count()/$msg->prompt_token_count($value)Type:
Int32Output only. Number of tokens in the prompt. When `cached_content` is set, this is still the total effective prompt size meaning this includes the number of tokens in the cached content.
$msg->cached_content_token_count()/$msg->cached_content_token_count($value)Type:
Int32Number of tokens in the cached part of the prompt (the cached content)
$msg->response_token_count()/$msg->response_token_count($value)Type:
Int32Output only. Total number of tokens across all the generated response candidates.
$msg->tool_use_prompt_token_count()/$msg->tool_use_prompt_token_count($value)Type:
Int32Output only. Number of tokens present in tool-use prompt(s).
$msg->thoughts_token_count()/$msg->thoughts_token_count($value)Type:
Int32Output only. Number of tokens of thoughts for thinking models.
$msg->total_token_count()/$msg->total_token_count($value)Type:
Int32Output only. Total token count for the generation request (prompt + response candidates).
$msg->prompt_tokens_details()/$msg->prompt_tokens_details($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::ModalityTokenCount)Output only. List of modalities that were processed in the request input.
$msg->cache_tokens_details()/$msg->cache_tokens_details($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::ModalityTokenCount)Output only. List of modalities of the cached content in the request input.
$msg->response_tokens_details()/$msg->response_tokens_details($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::ModalityTokenCount)Output only. List of modalities that were returned in the response.
$msg->tool_use_prompt_tokens_details()/$msg->tool_use_prompt_tokens_details($value)Type:
Message(Google::Ai::Generativelanguage::V1beta::Content::ModalityTokenCount)Output only. List of modalities that were processed for tool-use request inputs.
SEE ALSO
Protobuf, Protobuf::Message, Google::Ai::Generativelanguage::V1beta::GenerativeService::Types, https://protobuf.dev/
LICENSE AND COPYRIGHT
Copyright (C) 2026 Google LLC
This program is released under the Apache 2.0 license.