googleai_dart library

Unofficial Dart client for the Google AI Gemini Developer API and Vertex AI Gemini API with unified interface.

Classes

AgentConfig
Base class for agent configurations.
AllowedTools
Configuration for allowed tools.
Annotation
Citation information for model-generated content.
ApiKeyCredentials
API key authentication credentials.
ApiKeyProvider
Simple API key provider with static credentials.
AttributionSourceId
Identifier for the source contributing to this attribution.
AudioContent
An audio content block.
AudioDelta
An audio delta update.
AudioTranscriptionConfig
Configuration for audio transcription.
AuthCredentials
Authentication credentials returned by AuthProvider.
AuthProvider
Authentication provider interface for the GoogleAI client.
AuthToken
Ephemeral authentication token for secure client-side API access.
AutomaticActivityDetection
Configuration for automatic voice activity detection (VAD).
BatchEmbedContentsRequest
Batch request to get embeddings from the model for a list of prompts.
BatchEmbedContentsResponse
The response to a BatchEmbedContentsRequest.
BatchStats
Stats about a batch operation.
BearerTokenCredentials
Bearer token authentication credentials.
BearerTokenProvider
Simple bearer token provider with static credentials.
BidiGenerateContentClientContent
Client content message for sending conversation context.
BidiGenerateContentClientMessage
Base class for client-to-server WebSocket messages.
BidiGenerateContentRealtimeInput
Real-time input message for streaming audio, video, or text.
BidiGenerateContentServerContent
Server content message containing model output.
BidiGenerateContentServerMessage
Base class for server-to-client WebSocket messages.
BidiGenerateContentSetup
Initial session setup message.
BidiGenerateContentSetupComplete
Session setup complete message.
BidiGenerateContentToolCall
Tool call request message.
BidiGenerateContentToolCallCancellation
Tool call cancellation message.
BidiGenerateContentToolResponse
Tool response message.
Blob
Inline binary data (e.g., image, audio) encoded as base64.
CachedContent
Cached content for reuse across requests.
CachedContentUsageMetadata
Usage metadata for cached content.
Candidate
A generated response from the model.
ChunkingConfig
Parameters for telling the service how to chunk the file.
CitationMetadata
Citation sources for generated content.
CitationSource
A citation source.
CodeExecutionCallContent
A code execution call content block.
CodeExecutionCallDelta
A code execution call delta update.
CodeExecutionResult
Result of executing the ExecutableCode.
CodeExecutionResultContent
A code execution result content block.
CodeExecutionResultDelta
A code execution result delta update.
CodeExecutionResultPart
Result from code execution.
CodeExecutionTool
A tool that allows the model to execute code.
ComputerUse
Computer Use tool type.
ComputerUseTool
A tool that allows the model to interact with the computer.
Condition
Filter condition applicable to a single key.
Content
Represents a message in a conversation (user or model turn).
ContentDeltaEvent
An event containing a delta update for content.
ContentEmbedding
An embedding for a piece of content.
ContentStartEvent
An event indicating that content output has started.
ContentStopEvent
An event indicating that content output has stopped.
ContextWindowCompressionConfig
Configuration for context window compression.
Corpus
A collection of Documents.
CountTokensRequest
Request to count tokens.
CountTokensResponse
Response from counting tokens.
CreateAgentInteractionParams
Parameters for creating an interaction with an agent.
CreateAuthTokenRequest
Request wrapper for creating an ephemeral authentication token.
CreateModelInteractionParams
Parameters for creating an interaction with a model.
Dataset
Reference to a training dataset.
DeepResearchAgentConfig
Configuration for the Deep Research agent.
Document
A collection of related content in a corpus.
DocumentContent
A document content block.
DocumentDelta
A document delta update.
DynamicAgentConfig
Configuration for dynamic agents.
DynamicRetrievalConfig
Describes the options to customize dynamic retrieval.
EmbedContentBatch
A resource representing a batch of EmbedContent requests.
EmbedContentBatchOutput
The output of an EmbedContent batch request.
EmbedContentBatchStats
Stats about an embed batch operation.
EmbedContentRequest
Request to embed content.
EmbedContentResponse
Response from embedding content.
EphemeralTokenCredentials
Ephemeral token authentication credentials.
EphemeralTokenProvider
Provider for ephemeral token authentication.
ErrorEvent
An event indicating that an error has occurred.
ExecutableCode
Code generated by the model that is meant to be executed.
ExecutableCodePart
Code for model to execute.
File
Represents an uploaded file.
FileData
Reference to an uploaded file (via /v1beta/files).
FileDataPart
Reference to uploaded file.
FileSearch
The FileSearch tool that retrieves knowledge from Semantic Retrieval corpora.
FileSearchCustomMetadata
User-provided custom metadata stored as key-value pairs for file search.
FileSearchResult
A File Search result item.
FileSearchResultContent
A File Search result content block.
FileSearchResultDelta
A File Search result delta update.
FileSearchStore
A FileSearchStore is a collection of Documents.
FileSearchTool
A tool that allows the model to search files.
FunctionCall
A predicted function call returned from the model.
FunctionCallContent
A function tool call content block.
FunctionCallDelta
A function call delta update.
FunctionCallingConfig
Configuration for specifying function calling behavior.
FunctionCallPart
Model's request to call a function.
FunctionDeclaration
Structured representation of a function declaration.
FunctionResponse
The result output from a function call.
FunctionResponseBlob
Raw media bytes for function response.
FunctionResponseInlinePart
A datatype containing media that is part of a FunctionResponse message.
FunctionResponsePart
Result from function execution.
FunctionResultContent
A function tool result content block.
FunctionResultDelta
A function result delta update.
FunctionTool
A function tool that can be called by the model.
GenerateAnswerRequest
Request to generate a grounded answer from the Model.
GenerateAnswerResponse
Response from the model for a grounded answer.
GenerateContentBatch
A resource representing a batch of GenerateContent requests.
GenerateContentBatchOutput
The output of a GenerateContent batch request.
GenerateContentRequest
Request to generate content.
GenerateContentResponse
Response from generating content.
GeneratedFile
A file generated on behalf of a user (e.g., video generated by Veo).
GenerationConfig
Configuration options for model generation.
GoAway
Go away message indicating session is ending.
GoogleAIClient
Main client for the GoogleAI API.
GoogleAIConfig
Configuration for the GoogleAI client.
GoogleMaps
The GoogleMaps Tool that provides geospatial context for the user's query.
GoogleSearch
Google Search tool configuration.
GoogleSearchCallContent
A Google Search call content block.
GoogleSearchCallDelta
A Google Search call delta update.
GoogleSearchResult
A Google Search result item.
GoogleSearchResultContent
A Google Search result content block.
GoogleSearchResultDelta
A Google Search result delta update.
GoogleSearchRetrieval
Tool to retrieve public web data for grounding, powered by Google.
GoogleSearchTool
A tool that allows the model to search Google.
GroundingAttribution
Attribution for a source that contributed to an answer.
GroundingChunk
Grounding chunk.
GroundingChunkCustomMetadata
Custom metadata associated with a grounding chunk.
GroundingChunkStringList
A list of strings associated with a grounding chunk.
GroundingMetadata
Metadata returned to client when grounding is enabled.
GroundingPassage
Passage included inline with a grounding configuration.
GroundingPassageId
Identifier for a passage within a GroundingPassage.
GroundingPassages
A repeated list of passages.
GroundingSupport
Grounding support.
Hyperparameters
Hyperparameters for tuning a model.
Image
An image result from a web search.
ImageConfig
Config for image generation features.
ImageContent
An image content block.
ImageDelta
An image delta update.
ImageSearch
Image search configuration.
ImportFileRequest
Request for ImportFile to import a File API file with a FileSearchStore.
ImportFileResponse
Response for ImportFile to import a File API file with a FileSearchStore.
InlineDataPart
Inline binary data (base64).
InlinedEmbedContentRequest
A single embed request in a batch with optional metadata.
InlinedEmbedContentRequests
A list of inlined embed requests for batch processing.
InlinedEmbedContentResponse
A single embed response in a batch with optional metadata and error.
InlinedEmbedContentResponses
A list of inlined embed responses from batch processing.
InlinedRequest
A single request in a batch with optional metadata.
InlinedRequests
A list of inlined requests for batch processing.
InlinedResponse
A single response in a batch with optional metadata and error.
InlinedResponses
A list of inlined responses from batch processing.
InputConfig
Configures the input to a batch request.
InputEmbedContentConfig
Configures the input to an embed batch request.
InputFeedback
Feedback related to the input data used to answer the question, as opposed to the model-generated response to the question.
Interaction
The Interaction resource.
InteractionCompleteEvent
An event indicating that an interaction has completed.
InteractionContent
The content of an interaction response.
InteractionDelta
A delta update for interaction content.
InteractionError
An error from an interaction.
InteractionEvent
An event from the Interactions API streaming response.
InteractionGenerationConfig
Configuration parameters for model interactions.
InteractionSpeechConfig
Configuration for speech interaction.
InteractionStartEvent
An event indicating that an interaction has started.
InteractionStatusUpdateEvent
An event indicating that an interaction's status has been updated.
InteractionTool
A tool that can be used by the model.
InteractionToolChoice
Configuration for tool choice.
InteractionUsage
Statistics on the interaction request's token usage.
Interval
Represents a time interval.
LatLng
An object that represents a latitude/longitude pair.
ListBatchesResponse
Response message for listing batch operations.
ListCachedContentsResponse
Response from listing cached contents.
ListCorporaResponse
Response from ListCorpora containing a paginated list of Corpora.
ListDocumentsResponse
Response from ListDocuments containing a paginated list of Documents.
ListFileSearchStoresResponse
Response from ListFileSearchStores containing a paginated list of FileSearchStores.
ListFilesResponse
Response from listing files.
ListGeneratedFilesResponse
Response for ListGeneratedFiles.
ListModelsResponse
Response from listing models.
ListOperationsResponse
Response from listing operations.
ListPermissionsResponse
Response message for listing permissions.
ListTunedModelsResponse
Response from listing tuned models.
LiveClient
Client for the Gemini Live API.
LiveConfig
Main configuration for Live API sessions.
LiveGenerationConfig
Generation configuration for Live API sessions.
LiveSession
A live streaming session with the Gemini Live API.
LiveVoices
Available prebuilt voices for Live API.
LogprobCandidate
A single candidate token with its log probability.
LogprobsResult
Token-level log probabilities.
LROPoller<T>
Poller for long-running operations (LRO).
Maps
A grounding chunk from Google Maps.
McpServer
A MCPServer is a server that can be called by the model to perform actions.
McpServerTool
A tool that allows the model to call an MCP (Model Context Protocol) server.
McpServerToolCallContent
An MCP Server tool call content block.
McpServerToolCallDelta
An MCP Server tool call delta update.
McpServerToolResultContent
An MCP Server tool result content block.
McpServerToolResultDelta
An MCP Server tool result delta update.
Media
A proto encapsulate various types of media.
MediaResolution
Media resolution for a media part.
MetadataFilter
User provided filter to limit retrieval based on Chunk or Document level metadata values.
ModalityTokenCount
Represents token counting info for a single modality.
ModalityTokens
Token count for a single response modality.
Model
Represents a model available in the GoogleAI API.
ModelStatus
Status of a model.
NoAuthCredentials
No authentication credentials.
NoAuthProvider
Provider that returns no authentication credentials.
Operation
Represents a long-running operation.
OperationError
Error information for a failed operation.
PaginatedResponse<T>
Generic paginated response.
Paginator<T>
Helper for paginated API responses.
Part
A single unit of content (text, media, function call, etc.).
PartMetadataPart
Custom metadata.
Permission
Permission resource grants user, group or everyone access to a resource.
PlaceAnswerSources
Collection of sources that provide answers about the features of a given place in Google Maps.
PrebuiltVoiceConfig
Configuration for prebuilt voices.
PredictLongRunningGeneratedVideoResponse
Veo response containing generated video samples.
PredictLongRunningMetadata
Metadata for PredictLongRunning long running operations.
PredictLongRunningOperation
Represents a long-running operation for video prediction.
PredictLongRunningRequest
Request message for PredictLongRunning operation.
PredictLongRunningResponse
Response message for PredictLongRunning operation.
PredictRequest
Request message for Predict operation.
PredictResponse
Response message for Predict operation.
ProactivityConfig
Configuration for proactive audio responses.
PromptFeedback
Feedback on the prompt in the request.
RealtimeInputConfig
Configuration for real-time input handling.
RegisterFilesRequest
Request to register files.
RegisterFilesResponse
Response from registering files.
RequestMetadata
Metadata about the HTTP request that caused an error.
ResponseMetadata
Metadata about the HTTP response that caused an error.
RetrievalConfig
Retrieval config.
RetrievalMetadata
Metadata related to retrieval in the grounding flow.
RetrievedContext
Chunk from context retrieved by the file search tool.
RetryPolicy
Retry policy configuration.
ReviewSnippet
Encapsulates a snippet of a user review that answers a question about the features of a specific place in Google Maps.
SafetyRating
Safety rating for a piece of content.
SafetySetting
Safety setting to block content at different thresholds.
Schema
Schema for structured data.
SearchEntryPoint
Google search entry point.
SearchTypes
Search types configuration.
Segment
Segment of the content.
SemanticRetrieverChunk
Identifier for a Chunk retrieved via Semantic Retriever specified in the GenerateAnswerRequest using SemanticRetrieverConfig.
SemanticRetrieverConfig
Configuration for retrieving grounding content from a Corpus or Document created using the Semantic Retriever API.
SessionResumptionConfig
Configuration for session resumption.
SessionResumptionUpdate
Session resumption update message.
SlidingWindow
Sliding window configuration for context compression.
SpeechConfig
Configuration for speech synthesis.
Status
Error status information for RPC APIs.
StreamableHttpTransport
A transport that can stream HTTP requests and responses.
TextContent
A text content block.
TextDelta
A text delta update.
TextPart
Text content.
ThinkingConfig
Configuration for thinking features.
ThoughtContent
A thought content block.
ThoughtPart
Reasoning step indicator.
ThoughtSignatureDelta
A thought signature delta update.
ThoughtSignaturePart
Cached thought key (base64).
ThoughtSummaryDelta
A thought summary delta update.
Tool
Tool that the model may use to generate a response.
ToolConfig
The Tool configuration containing parameters for specifying Tool use in the request.
TopCandidates
Top candidates for a token position.
Transcription
Transcription of audio content.
TransferOwnershipRequest
Request to transfer ownership of a resource.
TunedModel
A fine-tuned model.
TuningExample
A single training example.
TuningExamples
Training examples for tuning.
TuningTask
Record of a tuning task.
Turn
A conversation turn in an interaction.
UnknownClientMessage
Unknown client message type.
UnknownServerMessage
Unknown server message type.
UploadToFileSearchStoreRequest
Request for UploadToFileSearchStore.
UploadToFileSearchStoreResponse
Response from UploadToFileSearchStore.
UrlContextCallContent
A URL context call content block.
UrlContextCallDelta
A URL context call delta update.
UrlContextResult
A URL context result item.
UrlContextResultContent
A URL context result content block.
UrlContextResultDelta
A URL context result delta update.
UrlContextTool
A tool that allows the model to fetch URL context.
UsageMetadata
Token usage metadata for the request/response.
Video
Representation of a video.
VideoContent
A video content block.
VideoDelta
A video delta update.
VideoMetadata
Metadata for a video file.
VideoMetadataPart
Video timing/sampling metadata.
VoiceConfig
Configuration for voice selection.
Web
Chunk from the web.
WebSearch
Web search configuration.
WhiteSpaceConfig
Configuration for a white space chunking algorithm.

Enums

AbortionStage
Stage at which request was aborted.
ActivityHandling
How the model handles user activity during generation.
AnswerStyle
Style in which answers should be returned.
ApiMode
API mode determining which Google AI service to use.
ApiVersion
API version for the GoogleAI and Vertex AI APIs. https://ai.google.dev/gemini-api/docs/api-versions
AuthPlacement
Authentication placement strategy.
BatchState
State of a batch operation.
BlockReason
Specifies the reason why the input was blocked.
DocumentState
State of a Document.
EndSensitivity
Sensitivity for detecting the end of user speech.
EphemeralTokenPlacement
Ephemeral token placement strategy.
FileSource
Source of a file.
FileState
State of an uploaded file.
FinishReason
Why generation stopped.
FunctionCallingMode
Function calling mode.
FunctionResponseScheduling
Scheduling options for function responses.
GeneratedFileState
The state of a GeneratedFile.
GranteeType
The type of grantee for a permission.
HarmBlockThreshold
Threshold for blocking harmful content.
HarmCategory
Harm categories that can be blocked.
HarmProbability
The probability that content is harmful.
InteractionResponseModality
The modality of a response.
InteractionStatus
The status of an interaction.
InteractionThinkingLevel
Controls the level of thought tokens the model should generate.
InteractionThinkingSummaries
Controls whether to include thought summaries in the response.
InteractionToolChoiceType
The type of tool choice.
Language
Code execution language.
MediaResolutionLevel
Media resolution level.
ModelStage
Lifecycle stage of a model.
Outcome
Outcome of the code execution.
PermissionRole
The role granted by a permission.
SchemaType
Schema type.
StartSensitivity
Sensitivity for detecting the start of user speech.
TaskType
Type of task for which the embedding will be used.
ThinkingLevel
Controls the depth of reasoning before generating responses.
TunedModelState
State of a tuned model.
TurnCoverage
How much input is included in a turn.

Extensions

CandidateExtensions on Candidate
Convenience extensions for Candidate.
ContentExtensions on Content
Convenience extensions for Content.
GenerateContentResponseExtensions on GenerateContentResponse
Convenience extensions for GenerateContentResponse.
InteractionExtensions on Interaction
Convenience extensions for Interaction.

Functions

answerStyleFromString(String? value) AnswerStyle
Converts string to AnswerStyle enum.
answerStyleToString(AnswerStyle style) String
Converts AnswerStyle enum to string.
batchStateFromString(String? value) BatchState
Converts a string to a BatchState.
batchStateToString(BatchState state) String
Converts a BatchState to a string.
blockReasonFromString(String? value) BlockReason
Converts string to BlockReason enum.
blockReasonToString(BlockReason reason) String
Converts BlockReason enum to string.
fileSourceFromString(String? value) FileSource
Converts a string to a FileSource.
fileSourceToString(FileSource source) String
Converts a FileSource to a string.
fileStateFromString(String? value) FileState
Converts a string to a FileState.
fileStateToString(FileState state) String
Converts a FileState to a string.
finishReasonFromString(String? value) FinishReason
Converts string to FinishReason enum.
finishReasonToString(FinishReason reason) String
Converts FinishReason enum to string.
functionCallingModeFromString(String? value) FunctionCallingMode
Converts a string to a FunctionCallingMode.
functionCallingModeToString(FunctionCallingMode mode) String
Converts a FunctionCallingMode to a string.
generatedFileStateFromString(String? value) GeneratedFileState
Converts a string to a GeneratedFileState.
generatedFileStateToString(GeneratedFileState? state) String
Converts a GeneratedFileState to a string.
granteeTypeFromString(String? value) GranteeType
Converts a string to GranteeType.
granteeTypeToString(GranteeType type) String
Converts GranteeType to a string.
harmBlockThresholdFromString(String? value) HarmBlockThreshold
Converts string to HarmBlockThreshold enum.
harmBlockThresholdToString(HarmBlockThreshold threshold) String
Converts HarmBlockThreshold enum to string.
harmCategoryFromString(String? value) HarmCategory
Converts string to HarmCategory enum.
harmCategoryToString(HarmCategory category) String
Converts HarmCategory enum to string.
harmProbabilityFromString(String? value) HarmProbability
Converts string to HarmProbability enum.
harmProbabilityToString(HarmProbability probability) String
Converts HarmProbability enum to string.
interactionResponseModalityFromString(String? value) InteractionResponseModality
Converts a string to InteractionResponseModality.
interactionResponseModalityToString(InteractionResponseModality modality) String
Converts InteractionResponseModality to a string.
interactionStatusFromString(String? value) InteractionStatus
Converts a string to InteractionStatus.
interactionStatusToString(InteractionStatus status) String
Converts InteractionStatus to a string.
interactionThinkingLevelFromString(String? value) InteractionThinkingLevel
Converts a string to InteractionThinkingLevel.
interactionThinkingLevelToString(InteractionThinkingLevel level) String
Converts InteractionThinkingLevel to a string.
interactionThinkingSummariesFromString(String? value) InteractionThinkingSummaries
Converts a string to InteractionThinkingSummaries.
interactionThinkingSummariesToString(InteractionThinkingSummaries summaries) String
Converts InteractionThinkingSummaries to a string.
interactionToolChoiceTypeFromString(String? value) InteractionToolChoiceType
Converts a string to InteractionToolChoiceType.
interactionToolChoiceTypeToString(InteractionToolChoiceType type) String
Converts InteractionToolChoiceType to a string.
modelStageFromString(String? value) ModelStage
Parses a ModelStage from its string representation.
modelStageToString(ModelStage value) String
Converts a ModelStage to its string representation.
permissionRoleFromString(String? value) PermissionRole
Converts a string to PermissionRole.
permissionRoleToString(PermissionRole role) String
Converts PermissionRole to a string.
schemaTypeFromString(String? value) SchemaType
Converts string to SchemaType enum.
schemaTypeToString(SchemaType type) String
Converts SchemaType enum to string.
taskTypeFromString(String? value) TaskType
Converts string to TaskType enum.
taskTypeToString(TaskType type) String
Converts TaskType enum to string.
thinkingLevelFromString(String? value) ThinkingLevel
Converts string to ThinkingLevel enum.
thinkingLevelToString(ThinkingLevel level) String
Converts ThinkingLevel enum to string.
tunedModelStateFromString(String? value) TunedModelState
Converts a string to a TunedModelState.
tunedModelStateToString(TunedModelState state) String
Converts a TunedModelState to a string.

Exceptions / Errors

AbortedException
Exception thrown when a request is aborted by user.
ApiException
Exception for HTTP/API errors.
AuthenticationException
Exception for authentication errors (HTTP 401).
GoogleAIException
Base sealed class for all GoogleAI exceptions.
LiveConnectionException
Exception thrown when WebSocket connection fails.
LiveSessionClosedException
Exception thrown when the Live session is closed.
LiveSessionException
Exception thrown for general Live session errors.
LiveSessionResumptionException
Exception thrown when session resumption fails.
LiveSessionSetupException
Exception thrown when session setup fails.
RateLimitException
Exception for rate limit (429) errors.
StreamException
Exception for errors detected in streaming data.
TimeoutException
Exception for request timeouts.
ValidationException
Exception for client-side validation errors.