Service Client: Google::Ai::Generativelanguage::V1beta3::TextService::TextServiceClient
Client stub representing the remote TextService 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::V1beta3::TextService - Compiled Protocol Buffers messages for google/ai/generativelanguage/v1beta3/text_service.proto
SYNOPSIS
use Google::Ai::Generativelanguage::V1beta3::TextService;
my $msg = Google::Ai::Generativelanguage::V1beta3::TextService::GenerateTextRequest->new({
model => $model,
prompt => $prompt,
temperature => $temperature,
candidate_count => $candidate_count,
});
# Read or update a field
my $val = $msg->model();
# Binary wire-format roundtrip
my $bytes = $msg->serialize();
my $decoded = Google::Ai::Generativelanguage::V1beta3::TextService::GenerateTextRequest->parse($bytes);
# Canonical ProtoJSON
my $json = $msg->to_json();
DESCRIPTION
Auto-generated Protobuf message classes compiled from google/ai/generativelanguage/v1beta3/text_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::V1beta3::TextService::GenerateTextRequest
Request to generate a text completion response from the model.
Inherits from Protobuf::Message.
Accessors
$msg->model()/$msg->model($value)Type:
StringRequired. The name of the `Model` or `TunedModel` to use for generating the completion. Examples: models/text-bison-001 tunedModels/sentence-translator-u3b7m
$msg->prompt()/$msg->prompt($value)Type:
Message(Google::Ai::Generativelanguage::V1beta3::TextService::TextPrompt)Required. The free-form input text given to the model as a prompt.
Given a prompt, the model will generate a TextCompletion response it predicts as the completion of the input text.
$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 the `getModel` function.
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.
$msg->candidate_count()/$msg->candidate_count($value)Type:
Int32Optional. Number of generated responses to return.
This value must be between [1, 8], inclusive. If unset, this will default to 1.
$msg->max_output_tokens()/$msg->max_output_tokens($value)Type:
Int32Optional. The maximum number of tokens to include in a candidate.
If unset, this will default to output_token_limit specified in the `Model` specification.
$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 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 number of tokens based on the cumulative probability.
Note: The default value varies by model, see the `Model.top_p` attribute of the `Model` returned the `getModel` function.
$msg->top_k()/$msg->top_k($value)Type:
Int32Optional. The maximum number of tokens to consider when sampling.
The model uses combined Top-k and nucleus sampling.
Top-k sampling considers the set of `top_k` most probable tokens. Defaults to 40.
Note: The default value varies by model, see the `Model.top_k` attribute of the `Model` returned the `getModel` function.
$msg->safety_settings()/$msg->safety_settings($value)Type:
Message(Google::Ai::Generativelanguage::V1beta3::Safety::SafetySetting)A list of unique `SafetySetting` instances for blocking unsafe content.
that will be enforced on the `GenerateTextRequest.prompt` and `GenerateTextResponse.candidates`. There should not be more than one setting for each `SafetyCategory` type. The API will block any prompts 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.
$msg->stop_sequences()/$msg->stop_sequences($value)Type:
StringThe 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.
Google::Ai::Generativelanguage::V1beta3::TextService::GenerateTextResponse
The response from the model, including candidate completions.
Inherits from Protobuf::Message.
Accessors
$msg->candidates()/$msg->candidates($value)Type:
Message(Google::Ai::Generativelanguage::V1beta3::TextService::TextCompletion)Candidate responses from the model.
$msg->filters()/$msg->filters($value)Type:
Message(Google::Ai::Generativelanguage::V1beta3::Safety::ContentFilter)A set of content filtering metadata for the prompt and response text.
This indicates which `SafetyCategory`(s) blocked a candidate from this response, the lowest `HarmProbability` that triggered a block, and the HarmThreshold setting for that category. This indicates the smallest change to the `SafetySettings` that would be necessary to unblock at least 1 response.
The blocking is configured by the `SafetySettings` in the request (or the default `SafetySettings` of the API).
$msg->safety_feedback()/$msg->safety_feedback($value)Type:
Message(Google::Ai::Generativelanguage::V1beta3::Safety::SafetyFeedback)Returns any safety feedback related to content filtering.
Google::Ai::Generativelanguage::V1beta3::TextService::TextPrompt
Text given to the model as a prompt.
The Model will use this TextPrompt to Generate a text completion.
Inherits from Protobuf::Message.
Accessors
$msg->text()/$msg->text($value)Type:
StringRequired. The prompt text.
Google::Ai::Generativelanguage::V1beta3::TextService::TextCompletion
Output text returned from a model.
Inherits from Protobuf::Message.
Accessors
$msg->output()/$msg->output($value)Type:
StringOutput only. The generated text returned from the model.
$msg->safety_ratings()/$msg->safety_ratings($value)Type:
Message(Google::Ai::Generativelanguage::V1beta3::Safety::SafetyRating)Ratings for the safety of a response.
There is at most one rating per category.
$msg->citation_metadata()/$msg->citation_metadata($value)Type:
Message(Google::Ai::Generativelanguage::V1beta3::Citation::CitationMetadata)Output only. Citation information for model-generated `output` in this `TextCompletion`.
This field may be populated with attribution information for any text included in the `output`.
Google::Ai::Generativelanguage::V1beta3::TextService::EmbedTextRequest
Request to get a text embedding from the model.
Inherits from Protobuf::Message.
Accessors
$msg->model()/$msg->model($value)Type:
StringRequired. The model name to use with the format model=models/{model}.
$msg->text()/$msg->text($value)Type:
StringRequired. The free-form input text that the model will turn into an embedding.
Google::Ai::Generativelanguage::V1beta3::TextService::EmbedTextResponse
The response to a EmbedTextRequest.
Inherits from Protobuf::Message.
Accessors
$msg->embedding()/$msg->embedding($value)Type:
Message(Google::Ai::Generativelanguage::V1beta3::TextService::Embedding)Output only. The embedding generated from the input text.
Google::Ai::Generativelanguage::V1beta3::TextService::BatchEmbedTextRequest
Batch request to get a text embedding 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 embedding. Examples: models/embedding-gecko-001
$msg->texts()/$msg->texts($value)Type:
StringRequired. The free-form input texts that the model will turn into an embedding. The current limit is 100 texts, over which an error will be thrown.
Google::Ai::Generativelanguage::V1beta3::TextService::BatchEmbedTextResponse
The response to a EmbedTextRequest.
Inherits from Protobuf::Message.
Accessors
$msg->embeddings()/$msg->embeddings($value)Type:
Message(Google::Ai::Generativelanguage::V1beta3::TextService::Embedding)Output only. The embeddings generated from the input text.
Google::Ai::Generativelanguage::V1beta3::TextService::Embedding
A list of floats representing the embedding.
Inherits from Protobuf::Message.
Accessors
$msg->value()/$msg->value($value)Type:
FloatThe embedding values.
Google::Ai::Generativelanguage::V1beta3::TextService::CountTextTokensRequest
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->prompt()/$msg->prompt($value)Type:
Message(Google::Ai::Generativelanguage::V1beta3::TextService::TextPrompt)Required. The free-form input text given to the model as a prompt.
Google::Ai::Generativelanguage::V1beta3::TextService::CountTextTokensResponse
A response from `CountTextTokens`.
It returns the model's `token_count` for the `prompt`.
Inherits from Protobuf::Message.
Accessors
$msg->token_count()/$msg->token_count($value)Type:
Int32The number of tokens that the `model` tokenizes the `prompt` into.
Always non-negative.
SEE ALSO
Protobuf, Protobuf::Message, Google::Ai::Generativelanguage::V1beta3::TextService::Types, https://protobuf.dev/
LICENSE AND COPYRIGHT
Copyright (C) 2026 Google LLC
This program is released under the Apache 2.0 license.