generativelanguage library

The Google Cloud client for the Generative Language API.

The Gemini API allows developers to build generative AI applications using Gemini models. Gemini is our most capable model, built from the ground up to be multimodal. It can generalize and seamlessly understand, operate across, and combine different types of information including language, images, audio, video, and code. You can use the Gemini API for use cases like reasoning across text and images, content generation, dialogue agents, summarization and classification systems, and more.

Classes

AttributionSourceId
Identifier for the source contributing to this attribution.
AttributionSourceId_GroundingPassageId
Identifier for a part within a GroundingPassage.
AttributionSourceId_SemanticRetrieverChunk
Identifier for a Chunk retrieved via Semantic Retriever specified in the GenerateAnswerRequest using SemanticRetrieverConfig.
AudioTranscriptionConfig
The audio transcription configuration.
BatchCreateChunksRequest
Request to batch create Chunks.
BatchCreateChunksResponse
Response from BatchCreateChunks containing a list of created Chunks.
BatchDeleteChunksRequest
Request to batch delete Chunks.
BatchEmbedContentsRequest
Batch request to get embeddings from the model for a list of prompts.
BatchEmbedContentsResponse
The response to a BatchEmbedContentsRequest.
BatchEmbedTextRequest
Batch request to get a text embedding from the model.
BatchEmbedTextResponse
The response to a EmbedTextRequest.
BatchUpdateChunksRequest
Request to batch update Chunks.
BatchUpdateChunksResponse
Response from BatchUpdateChunks containing a list of updated Chunks.
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.
BidiGenerateContentClientMessage
Messages sent by the client in the BidiGenerateContent call.
BidiGenerateContentRealtimeInput
User input that is sent in real time.
BidiGenerateContentRealtimeInput_ActivityEnd
Marks the end of user activity.
BidiGenerateContentRealtimeInput_ActivityStart
Marks the start of user activity.
BidiGenerateContentServerContent
Incremental server update generated by the model in response to client messages.
BidiGenerateContentServerMessage
Response message for the BidiGenerateContent call.
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.
BidiGenerateContentSetupComplete
Sent in response to a BidiGenerateContentSetup message from the client.
BidiGenerateContentToolCall
Request for the client to execute the function_calls and return the responses with the matching ids.
BidiGenerateContentToolCallCancellation
Notification for the client that a previously issued ToolCallMessage with the specified ids 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.
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.
BidiGenerateContentTranscription
Transcription of audio (input or output).
Blob
Raw media bytes.
CachedContent
Content that has been preprocessed and can be used in subsequent request to GenerativeService.
CachedContent_UsageMetadata
Metadata on the usage of the cached content.
CacheService
API for managing cache of content (CachedContent resources) that can be used in GenerativeService requests. This way generate content requests can benefit from preprocessing work being done earlier, possibly lowering their computational cost. It is intended to be used with large contexts.
Candidate
A response candidate generated from the model.
Candidate_FinishReason
Defines the reason why the model stopped generating tokens.
Chunk
A Chunk is a subpart of a Document that is treated as an independent unit for the purposes of vector representation and storage. A Corpus can have a maximum of 1 million Chunks.
Chunk_State
States for the lifecycle of a Chunk.
ChunkData
Extracted data that represents the Chunk content.
CitationMetadata
A collection of source attributions for a piece of content.
CitationSource
A citation to a source for a portion of a specific response.
CodeExecution
Tool that executes code generated by the model, and automatically returns the result to the model.
CodeExecutionResult
Result of executing the ExecutableCode.
CodeExecutionResult_Outcome
Enumeration of possible outcomes of the code execution.
Condition
Filter condition applicable to a single key.
Condition_Operator
Defines the valid operators that can be applied to a key-value pair.
Content
The base structured datatype containing multi-part content of a message.
ContentEmbedding
A list of floats representing an embedding.
ContentFilter
Content filtering metadata associated with processing a single request.
ContentFilter_BlockedReason
A list of reasons why content may have been blocked.
ContextWindowCompressionConfig
Enables context window compression — a mechanism for managing the model's context window so that it does not exceed a given length.
ContextWindowCompressionConfig_SlidingWindow
The SlidingWindow method operates by discarding content at the beginning of the context window. The resulting context will always begin at the start of a USER role turn. System instructions and any BidiGenerateContentSetup.prefix_turns will always remain at the beginning of the result.
Corpus
A Corpus is a collection of Documents. A project can create up to 5 corpora.
CountMessageTokensRequest
Counts the number of tokens in the prompt sent to a model.
CountMessageTokensResponse
A response from CountMessageTokens.
CountTextTokensRequest
Counts the number of tokens in the prompt sent to a model.
CountTextTokensResponse
A response from CountTextTokens.
CountTokensRequest
Counts the number of tokens in the prompt sent to a model.
CountTokensResponse
A response from CountTokens.
CreateCachedContentRequest
Request to create CachedContent.
CreateChunkRequest
Request to create a Chunk.
CreateCorpusRequest
Request to create a Corpus.
CreateDocumentRequest
Request to create a Document.
CreateFileRequest
Request for CreateFile.
CreateFileResponse
Response for CreateFile.
CreatePermissionRequest
Request to create a Permission.
CreateTunedModelMetadata
Metadata about the state and progress of creating a tuned model returned from the long-running operation
CreateTunedModelRequest
Request to create a TunedModel.
CustomMetadata
User provided metadata stored as key-value pairs.
Dataset
Dataset for training or validation.
DeleteCachedContentRequest
Request to delete CachedContent.
DeleteChunkRequest
Request to delete a Chunk.
DeleteCorpusRequest
Request to delete a Corpus.
DeleteDocumentRequest
Request to delete a Document.
DeleteFileRequest
Request for DeleteFile.
DeletePermissionRequest
Request to delete the Permission.
DeleteTunedModelRequest
Request to delete a TunedModel.
DiscussService
An API for using Generative Language Models (GLMs) in dialog applications.
Document
A Document is a collection of Chunks. A Corpus can have a maximum of 10,000 Documents.
DownloadFileRequest
Request for DownloadFile.
DownloadFileResponse
Response for DownloadFile.
DynamicRetrievalConfig
Describes the options to customize dynamic retrieval.
DynamicRetrievalConfig_Mode
The mode of the predictor to be used in dynamic retrieval.
EmbedContentRequest
Request containing the Content for the model to embed.
EmbedContentResponse
The response to an EmbedContentRequest.
Embedding
A list of floats representing the embedding.
EmbedTextRequest
Request to get a text embedding from the model.
EmbedTextResponse
The response to a EmbedTextRequest.
Example
An input/output example used to instruct the Model.
ExecutableCode
Code generated by the model that is meant to be executed, and the result returned to the model.
ExecutableCode_Language
Supported programming languages for the generated code.
File
A file uploaded to the API. Next ID: 15
File_Source
File_State
States for the lifecycle of a File.
FileData
URI based data.
FileService
An API for uploading and managing files.
FunctionCall
A predicted FunctionCall returned from the model that contains a string representing the FunctionDeclaration.name with the arguments and their values.
FunctionCallingConfig
Configuration for specifying function calling behavior.
FunctionCallingConfig_Mode
Defines the execution behavior for function calling by defining the execution mode.
FunctionDeclaration
Structured representation of a function declaration as defined by the OpenAPI 3.03 specification. Included in this declaration are the function name and parameters. 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.
FunctionDeclaration_Behavior
Defines the function behavior. Defaults to BLOCKING.
FunctionResponse
The 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 aFunctionCall made based on model prediction.
FunctionResponse_Scheduling
Specifies how the response should be scheduled in the conversation.
FunctionResponseBlob
Raw media bytes for function response.
FunctionResponsePart
A datatype containing media that is part of a FunctionResponse message.
GenerateAnswerRequest
Request to generate a grounded answer from the Model.
GenerateAnswerRequest_AnswerStyle
Style for grounded answers.
GenerateAnswerResponse
Response from the model for a grounded answer.
GenerateAnswerResponse_InputFeedback
Feedback related to the input data used to answer the question, as opposed to the model-generated response to the question.
GenerateAnswerResponse_InputFeedback_BlockReason
Specifies what was the reason why input was blocked.
GenerateContentRequest
Request to generate a completion from the model. NEXT ID: 18
GenerateContentResponse
Response from the model supporting multiple candidate responses.
GenerateContentResponse_PromptFeedback
A set of the feedback metadata the prompt specified in GenerateContentRequest.content.
GenerateContentResponse_PromptFeedback_BlockReason
Specifies the reason why the prompt was blocked.
GenerateContentResponse_UsageMetadata
Metadata on the generation request's token usage.
GenerateMessageRequest
Request to generate a message response from the model.
GenerateMessageResponse
The response from the model.
GenerateTextRequest
Request to generate a text completion response from the model.
GenerateTextResponse
The response from the model, including candidate completions.
GenerationConfig
Configuration options for model generation and outputs. Not all parameters are configurable for every model. Next ID: 29
GenerationConfig_MediaResolution
Media resolution for the input media.
GenerationConfig_Modality
Supported modalities of the response.
GenerativeService
API for using Large Models that generate multimodal content and have additional capabilities beyond text generation.
GetCachedContentRequest
Request to read CachedContent.
GetChunkRequest
Request for getting information about a specific Chunk.
GetCorpusRequest
Request for getting information about a specific Corpus.
GetDocumentRequest
Request for getting information about a specific Document.
GetFileRequest
Request for GetFile.
GetModelRequest
Request for getting information about a specific Model.
GetPermissionRequest
Request for getting information about a specific Permission.
GetTunedModelRequest
Request for getting information about a specific Model.
GoAway
A notice that the server will soon disconnect.
GoogleSearchRetrieval
Tool to retrieve public web data for grounding, powered by Google.
GroundingAttribution
Attribution for a source that contributed to an answer.
GroundingChunk
Grounding chunk.
GroundingChunk_Web
Chunk from the web.
GroundingMetadata
Metadata returned to client when grounding is enabled.
GroundingPassage
Passage included inline with a grounding configuration.
GroundingPassages
A repeated list of passages.
GroundingSupport
Grounding support.
HarmCategory
The category of a rating.
Hyperparameters
Hyperparameters controlling the tuning process. Read more at https://ai.google.dev/docs/model_tuning_guidance
ImageConfig
Config for image generation features.
ListCachedContentsRequest
Request to list CachedContents.
ListCachedContentsResponse
Response with CachedContents list.
ListChunksRequest
Request for listing Chunks.
ListChunksResponse
Response from ListChunks containing a paginated list of Chunks. The Chunks are sorted by ascending chunk.create_time.
ListCorporaRequest
Request for listing Corpora.
ListCorporaResponse
Response from ListCorpora containing a paginated list of Corpora. The results are sorted by ascending corpus.create_time.
ListDocumentsRequest
Request for listing Documents.
ListDocumentsResponse
Response from ListDocuments containing a paginated list of Documents. The Documents are sorted by ascending document.create_time.
ListFilesRequest
Request for ListFiles.
ListFilesResponse
Response for ListFiles.
ListModelsRequest
Request for listing all Models.
ListModelsResponse
Response from ListModel containing a paginated list of Models.
ListPermissionsRequest
Request for listing permissions.
ListPermissionsResponse
Response from ListPermissions containing a paginated list of permissions.
ListTunedModelsRequest
Request for listing TunedModels.
ListTunedModelsResponse
Response from ListTunedModels containing a paginated list of Models.
LogprobsResult
Logprobs Result
LogprobsResult_Candidate
Candidate for the logprobs token and score.
LogprobsResult_TopCandidates
Candidates with top log probabilities at each decoding step.
Media
A proto encapsulate various type of media.
Message
The base unit of structured text.
MessagePrompt
All of the structured input text passed to the model as a prompt.
MetadataFilter
User provided filter to limit retrieval based on Chunk or Document level metadata values. Example (genre = drama OR genre = action): key = "document.custom_metadata.genre" conditions = {string_value = "drama", operation = EQUAL}, {string_value = "action", operation = EQUAL}
Modality
Content Part modality
ModalityTokenCount
Represents token counting info for a single modality.
Model
Information about a Generative Language Model.
ModelService
Provides methods for getting metadata information about Generative Models.
MultiSpeakerVoiceConfig
The configuration for the multi-speaker setup.
Part
A datatype containing media that is part of a multi-part Content message.
Permission
Permission resource grants user, group or the rest of the world access to the PaLM API resource (e.g. a tuned model, corpus).
Permission_GranteeType
Defines types of the grantee of this permission.
Permission_Role
Defines the role granted by this permission.
PermissionService
Provides methods for managing permissions to PaLM API resources.
PrebuiltVoiceConfig
The configuration for the prebuilt speaker to use.
PredictionService
A service for online predictions and explanations.
PredictLongRunningGeneratedVideoResponse
Veo response.
PredictLongRunningMetadata
Metadata for PredictLongRunning long running operations.
PredictLongRunningRequest
Request message for PredictionService.PredictLongRunning.
PredictLongRunningResponse
Response message for PredictionService.PredictLongRunning
PredictRequest
Request message for PredictionService.Predict.
PredictResponse
Response message for PredictionService.Predict.
QueryCorpusRequest
Request for querying a Corpus.
QueryCorpusResponse
Response from QueryCorpus containing a list of relevant chunks.
QueryDocumentRequest
Request for querying a Document.
QueryDocumentResponse
Response from QueryDocument containing a list of relevant chunks.
RealtimeInputConfig
Configures the realtime input behavior in BidiGenerateContent.
RealtimeInputConfig_ActivityHandling
The different ways of handling user activity.
RealtimeInputConfig_AutomaticActivityDetection
Configures automatic detection of activity.
RealtimeInputConfig_AutomaticActivityDetection_EndSensitivity
Determines how end of speech is detected.
RealtimeInputConfig_AutomaticActivityDetection_StartSensitivity
Determines how start of speech is detected.
RealtimeInputConfig_TurnCoverage
Options about which input is included in the user's turn.
RelevantChunk
The information for a chunk relevant to a query.
RetrievalMetadata
Metadata related to retrieval in the grounding flow.
RetrieverService
An API for semantic search over a corpus of user uploaded content.
SafetyFeedback
Safety feedback for an entire request.
SafetyRating
Safety rating for a piece of content.
SafetyRating_HarmProbability
The probability that a piece of content is harmful.
SafetySetting
Safety setting, affecting the safety-blocking behavior.
SafetySetting_HarmBlockThreshold
Block at and beyond a specified harm probability.
Schema
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.
SearchEntryPoint
Google search entry point.
Segment
Segment of the content.
SemanticRetrieverConfig
Configuration for retrieving grounding content from a Corpus or Document created using the Semantic Retriever API.
SessionResumptionConfig
Session resumption configuration.
SessionResumptionUpdate
Update of the session resumption state.
SpeakerVoiceConfig
The configuration for a single speaker in a multi speaker setup.
SpeechConfig
The speech generation config.
StringList
User provided string values assigned to a single metadata key.
TaskType
Type of task for which the embedding will be used.
TextCompletion
Output text returned from a model.
TextPrompt
Text given to the model as a prompt.
TextService
API for using Generative Language Models (GLMs) trained to generate text.
ThinkingConfig
Config for thinking features.
Tool
Tool details that the model may use to generate response.
Tool_ComputerUse
Computer Use tool type.
Tool_ComputerUse_Environment
Represents the environment being operated, such as a web browser.
Tool_GoogleSearch
GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google.
ToolConfig
The Tool configuration containing parameters for specifying Tool use in the request.
TransferOwnershipRequest
Request to transfer the ownership of the tuned model.
TransferOwnershipResponse
Response from TransferOwnership.
TunedModel
A fine-tuned model created using ModelService.CreateTunedModel.
TunedModel_State
The state of the tuned model.
TunedModelSource
Tuned model as a source for training a new model.
TuningExample
A single example for tuning.
TuningExamples
A set of tuning examples. Can be training or validation data.
TuningSnapshot
Record for a single tuning step.
TuningTask
Tuning tasks that create tuned models.
Type
Type contains the list of OpenAPI data types as defined by https://spec.openapis.org/oas/v3.0.3#data-types
UpdateCachedContentRequest
Request to update CachedContent.
UpdateChunkRequest
Request to update a Chunk.
UpdateCorpusRequest
Request to update a Corpus.
UpdateDocumentRequest
Request to update a Document.
UpdatePermissionRequest
Request to update the Permission.
UpdateTunedModelRequest
Request to update a TunedModel.
UrlContext
Tool to support URL context retrieval.
UrlContextMetadata
Metadata related to url context retrieval tool.
UrlMetadata
Context of the a single url retrieval.
UrlMetadata_UrlRetrievalStatus
Status of the url retrieval.
UsageMetadata
Usage metadata about response(s).
Video
Representation of a video.
VideoFileMetadata
Metadata for a video File.
VideoMetadata
Metadata describes the input video content.
VoiceConfig
The configuration for the voice to use.