gemini_live_core library
Pure-Dart entry point for the gemini_live package.
Use this library in pure Dart CLI, server, or background isolate environments
where Flutter (dart:ui) is not required.
Classes
- ActivityEnd
- A signal that marks the end of explicit user activity.
- ActivityStart
- A signal that marks the start of explicit user activity.
- ApiError
- Structured error details returned by an HTTP API error response.
- AudioChunk
- A chunk of generated audio from the music model.
- AudioMetadata
- Metadata configuring static audio preprocessing on Part or FunctionResponsePart.
- AudioStaticMediaProcessing
- Static audio media processing options for the Interactions API.
- AudioTranscriptionConfig
- Audio transcription settings for input or output streams.
- AuthConfig
- Authentication configuration for tool integrations (such as Google Maps).
- AuthToken
- Ephemeral authentication token representation.
- AuthTokensService
- Service for generating ephemeral authentication tokens for Gemini Live API connections.
- AutomaticActivityDetection
- Automatic voice activity detection settings for realtime audio.
- AvatarConfig
- Avatar options for live video-capable sessions.
- Blob
- Inline binary data encoded for API transport.
- CallableTool
- A tool that provides its Tool declaration and can execute FunctionCalls.
- CallableToolConfig
- Configuration options for a CallableTool.
- CallDeadline
- A wall-clock deadline bounding an entire multi-hop continuation call.
- CancelInteractionEvent
- Client wire event that permanently aborts an in-flight Live Interaction.
- ChoiceAnswer
- Calibrated result for a ChoiceQuestion.
- ChoiceQuestion
- A single-select categorical decision question over mutually exclusive options.
- CodeExecutionResult
- The result of model-executed code.
- CompleteInteractionEvent
- Client wire event that half-closes input while awaiting remaining output.
- ComputerUse
- Computer-use tool configuration.
- ConnectInteractionEvent
- Client wire event that reconnects to an existing Live Interaction.
- Content
- A conversational turn made of one or more Part values.
- ContextWindowCompressionConfig
- Context compression settings for long-running sessions.
- CreateAuthTokenConfig
- Configuration parameters for creating an ephemeral authentication token.
- CreateDecisionRequest
- Request payload for evaluating structured decision questions against shared input.
- CreateDecisionResponse
-
Response returned from
DecisionsService.create. - CreateInteractionEvent
- Client wire event that starts a new Live Interaction.
- CreateVoiceRequest
- Request payload for creating a custom voice.
- CustomizedAvatar
- A customized avatar reference image.
- DecisionAnswer
- Base class for a calibrated decision answer in CreateDecisionResponse.
- DecisionPromptFeedback
- Input content filter feedback returned in CreateDecisionResponse.
- DecisionQuestion
- Base class for a single structured decision question in CreateDecisionRequest.
- DecisionsService
-
Service for evaluating structured decision questions (
POST /{api_version}/decisions). - DeleteVoiceResponse
- Response returned by DeleteVoice.
- DisconnectEvent
- Client wire event requesting graceful disconnection without ending the interaction.
- DocumentMetadata
- Metadata configuring static document preprocessing on Part or FunctionResponsePart.
- DocumentMimeTypes
- Standard document, Office, and OpenDocument MIME types supported in interactions.
- DocumentStaticMediaProcessing
- Static document media processing options for paginated documents and spreadsheets in the Interactions API.
- DynamicRetrievalConfig
- Dynamic retrieval thresholds for grounded search.
- ExecutableCode
- Executable code emitted by the model.
- FileData
- URI-based media content referenced by a part.
- FunctionCall
- A tool invocation requested by the model.
- FunctionDeclaration
- A function schema exposed to the model as a callable tool.
- FunctionResponse
- A tool result sent back to the model.
- FunctionResponseBlob
- Inline binary data returned from a function response.
- FunctionResponseFileData
- File metadata returned from a function response.
- FunctionResponsePart
- A single payload part inside a function response.
- GeminiLiveAudioBuffer
- An in-memory accumulator for raw 16-bit linear PCM audio chunks that supports instant barge-in flushing, duration calculation, and WAV file export.
- GeminiLiveAudioUtils
- Utilities for working with raw PCM audio data in Gemini Live sessions.
-
GeminiLiveFrameRateLimiter<
T> -
A stream transformer and imperative gate that throttles high-frequency
camera or screen-capture frame streams down to Gemini Live's recommended
1–2 FPS rate (
maxFps). - GeminiLiveFunctionTool
- A developer-friendly, inline implementation of CallableTool that wraps a single FunctionDeclaration and a Dart handler closure.
- GeminiLivePcmChunker
- A stream transformer and buffer utility that slices or accumulates irregular raw PCM byte streams into uniform, sample-aligned chunks.
- GeminiLiveReconnectPolicy
-
Configuration policy for automatic session reconnection and resumption
when a Gemini Live WebSocket session receives a
GoAwaynotice or closes unexpectedly. - GeminiLiveToolRegistry
- A composite CallableTool registry that bundles multiple GeminiLiveFunctionTool definitions into a single Tool declaration and automatically routes incoming FunctionCalls by name.
- GeminiVoicesService
- Service for managing custom voices and listing system voice catalog resources using the Gemini Voices API.
- GenAICredentials
- Bearer token credentials and optional Google Cloud quota project configuration for API and Live WebSocket requests.
- GenerationConfig
- Generation parameters used when starting a Live API session.
- GoogleGenAI
- The primary class for interacting with the Google Generative AI API.
- GoogleMaps
- Configuration options for Google Maps grounding in Tool.
- GoogleSearch
- Google Search tool configuration.
- GoogleSearchRetrieval
- Retrieval settings for the Google Search tool.
- HistoryConfig
- Configuration for history exchange between client and server.
- HttpOptions
- HTTP and WebSocket transport options for API requests and Live sessions.
- ImageSearch
- Image search for grounding and related configurations.
- InteractionAgents
- Well-known agent identifiers supported by the Gemini Interactions API.
- InteractionAuthToken
- Short-lived authentication token minted for a Live Interaction session.
- InteractionAuthTokenCreateParams
- Parameters for creating a short-lived auth token bound to an interaction.
- InteractionCancelledEvent
- Server wire event signaling that a Live Interaction was cancelled.
- InteractionConnectedEvent
- Server wire event confirming reconnection to an existing Live Interaction.
- InteractionFunction
- An Interactions API function tool definition supporting deferred loading.
- InteractionModels
- Well-known model identifiers supported by the Gemini Interactions API.
- Interval
- A time interval used by search filters.
- JsonSchemaTransformer
-
Normalizes JSON Schema maps (including
$defs,$ref, nullableanyOfunions, andproperty_ordering) into Gemini API-compatible schema payloads. - LanguageAuto
- Indicates the language of the audio should be automatically detected.
- LanguageHints
- Provides hints to the model about possible languages present in the audio.
- ListVoicesResponse
- Response returned by ListVoices.
- LiveCallbacks
- Callbacks for Live API WebSocket lifecycle and message events.
- LiveClientContent
- Client-authored conversation turns sent to the model.
- LiveClientContextUpdate
-
Updates to the context (
systemInstructionand/ortools) of the current Live API session. - LiveClientContextUpdateTools
- A wrapper around the list of tools for in-session context updates.
- LiveClientMessage
- A top-level client message sent over the Live API socket.
- LiveClientRealtimeInput
- Realtime media or text input sent while a session is active.
- LiveClientSetup
- The initial setup message sent when opening a Live API session.
- LiveClientToolResponse
- A batch of tool results returned to the server.
- LiveConnectConfig
- Session configuration for Live API connections.
- LiveConnectConstraints
- Configuration constraints locked in the ephemeral token for Live API connections.
- LiveConnectParameters
- Parameters for establishing a Live API connection.
- LiveInteractionCompletedEvent
- Server wire event signaling that a Live Interaction completed.
- LiveInteractionCreatedEvent
- Server wire event confirming that a new Live Interaction was created.
- LiveModels
- Well-known model identifiers supported by the Gemini Live API.
- LiveMusicCallbacks
- Callbacks for Realtime Music (Lyria Live) events.
- LiveMusicClientContent
- User input to steer the music stream.
- LiveMusicClientMessage
- Messages sent from the client over the Live Music WebSocket.
- LiveMusicClientSetup
- Setup message sent on initial connection to the music stream.
- LiveMusicConnectParameters
- Parameters for establishing a Realtime Music generation session.
- LiveMusicFilteredPrompt
- Information about a prompt filtered by safety filters.
- LiveMusicGenerationConfig
- Configuration options for realtime music generation.
- LiveMusicModels
- Well-known model identifiers supported by the Realtime Music (Lyria Live) API.
- LiveMusicServerContent
- Server content payload containing generated audio chunks.
- LiveMusicServerMessage
- Response message received from the Live Music WebSocket server.
- LiveMusicServerSetupComplete
- Confirmation message sent from the server once setup is complete.
- LiveMusicService
- Service for connecting to Gemini Realtime Music generation (Lyria Live).
- LiveMusicSession
- Represents an active Realtime Music generation session via WebSocket.
- LiveMusicSetConfigParameters
- Parameters for updating the music generation configuration on an active LiveMusicSession.
- LiveMusicSetWeightedPromptsParameters
- Parameters for setting weighted prompts on an active LiveMusicSession.
- LiveMusicSourceMetadata
- Prompts and configuration used to generate an audio chunk.
- LiveSendClientContentParameters
- Parameters for sending conversational turns to the session.
- LiveSendRealtimeInputParameters
- Parameters for sending realtime media or text input.
- LiveSendToolResponseParameters
- Parameters for sending tool results back to the model.
- LiveServerContent
- Server-generated content and turn lifecycle updates.
- LiveServerError
- An error returned by the Live API server.
- LiveServerGoAway
- A shutdown warning indicating when the session will expire.
- LiveServerMessage
- A top-level server message received over the Live API socket.
- LiveServerSessionResumptionUpdate
- A session resumption token update from the server.
- LiveServerSetupComplete
- Acknowledgement payload returned after session setup completes.
- LiveServerToolCall
- A tool call request emitted by the server.
- LiveServerToolCallCancellation
- A cancellation notice for previously issued tool calls.
- LiveService
- Service for connecting to the Gemini Live API via WebSocket.
- LiveSession
- Represents an active Live API WebSocket session.
- McpServer
- An MCP server that can be called by the model to perform actions.
- ModalityTokenCount
- Token counts broken down by media modality.
- MultiSpeakerVoiceConfig
- Speech settings for two-speaker text-to-speech output.
- NoulAnswer
- Calibrated result for a NoulQuestion.
- NoulCriteria
-
Criteria descriptions for the
trueandfalseoutcomes of a NoulQuestion. - NoulQuestion
-
A binary (
true/false) decision question. - PageContentLayer
- Content layer identifiers extractable from paginated documents.
- PageProcessingOptions
- Processing options for paginated documents such as PDFs, Office documents, and presentations.
- Part
- A single multimodal part within a content turn.
- PartialArg
- One streamed partial argument value for a function call.
- PartMediaResolution
- Input media tokenization hints attached to a part.
- PrebuiltVoiceConfig
- A prebuilt voice selection for synthesized audio output.
- ProactivityConfig
- Proactivity options for realtime audio and video Live sessions.
- PromptedVoice
- Parameters for prompted voice generation.
- RawJsonLineBuffer
- Buffers raw JSON stream lines until outer curly braces balance outside JSON string literals.
- RealtimeInputConfig
- Realtime input settings sent during session setup.
- ReplicatedVoice
- Parameters for replicated (cloned) voice generation.
- ReplicatedVoiceConfig
- Voice cloning settings for custom speech output.
- SafetySetting
- Safety settings to block unsafe content in Gemini responses.
- ScoreAnswer
- Calibrated result for a ScoreQuestion.
- ScoreQuestion
- A quantitative rubric scoring question over discrete numeric levels.
- SearchTypes
- Different types of search that can be enabled on the GoogleSearch tool.
- SessionResumptionConfig
- Session resumption settings for reconnectable sessions.
- SlidingWindow
- Sliding window targets used during context compression.
- SmartTranscriptionMode
- Configuration for smart transcription mode in interactions.
- SpeakerVoiceConfig
- Voice assignment for one speaker in a multi-speaker response.
- SpeechAnnotation
- Speech annotation for text content indicating speaker and style segment boundaries.
- SpeechConfig
- Speech generation settings for audio responses.
- SpeechMetadata
- Extra metadata associated with a content part for speech synthesis.
- SpreadsheetContentLayer
- Content layer identifiers extractable from spreadsheets.
- SpreadsheetMetadata
- Metadata configuring static spreadsheet preprocessing on Part or FunctionResponsePart.
- SpreadsheetProcessingOptions
- Processing options for spreadsheets in the Interactions API.
- StaticMediaProcessing
- Static video media processing options for the Interactions API.
- StreamableHttpTransport
- A transport that can stream HTTP requests and responses for an McpServer.
- ThinkingConfig
- Thinking controls for models that can emit thought content.
- Tool
- A tool bundle that can be attached to a model session.
- ToolCall
- A server-side tool call embedded in a model part.
- ToolExaAiSearch
- A tool that uses the Exa.ai search engine for grounding.
- ToolParallelAiSearch
- A tool that uses the Parallel.ai search engine for grounding.
- ToolResponse
- The client-side result of a server-side tool call.
- ToolSearch
- A tool that allows the model to dynamically search for and load deferred tool definitions into context on demand.
- ToolSearchCallArguments
- Arguments passed to a ToolSearchCallStep or ToolSearchCallDelta.
- ToolSearchCallDelta
- Incremental streaming delta for a ToolSearchCallStep.
- ToolSearchCallStep
- Completed Interactions step representing a dynamic tool search invocation.
- ToolSearchExecution
- Execution mode for an Interactions ToolSearch tool.
- ToolSearchResultDelta
- Incremental streaming delta for a ToolSearchResultStep.
- ToolSearchResultStep
- Completed Interactions step containing retrieved function definitions for a ToolSearchCallStep.
- Transcription
- A transcription update for input or output audio.
- TranslationConfig
- Stream translation settings for Live sessions.
- UsageMetadata
- Usage statistics attached to a server response.
- UserActionInput
- Interactive client user action event for world simulation and interactive media sessions.
- UserActionKey
- Interactive keyboard targets for UserActionInput.
- UserActionType
- Interactive action types for UserActionInput.
- VideoContentLayer
- Content layer identifiers extractable from video inputs in static processing.
- VideoMetadata
- Additional video metadata attached to inline or URI-based media.
- VoiceActivity
- A higher-level voice activity event emitted by the server.
- VoiceActivityDetectionSignal
- A low-level VAD signal emitted by the server.
- VoiceAudioData
- Audio data containing base64-encoded audio bytes and mime type.
- VoiceConfig
- Voice settings applied to spoken responses.
- VoiceConsentSignature
- The signature of a voice consent check.
- VoiceResource
- A custom voice resource (created via CreateVoice) or prebuilt system voice (returned by ListVoices).
- WavAudioInfo
-
Metadata and raw PCM payload parsed from a RIFF WAVE (
.wav) byte buffer. - WebSearch
- Standard web search for grounding and related configurations.
- WeightedPrompt
- Maps a prompt to a relative weight to steer music generation.
- WordInfo
- Information about a single recognized word in a Transcription.
- WorldPromptContent
- Text prompt describing a simulated world for WorldSetupEvent.
- WorldReferenceImage
- Reference image initializing the first frame of a WorldSetupEvent.
- WorldSetupEvent
- World setup configuration sent after CreateInteractionEvent for world-simulation models.
Enums
- ActivityHandling
- How detected user activity affects model generation.
- AudioTranscriptionConfigMode
- Configures transcription mode for audio transcription.
- Behavior
- Execution modes for server-side behaviors such as function calling.
- DecisionBlockReason
- Reasons a decision input was blocked by content filters.
- DocumentMetadataContentLayer
- Content layers to extract from a document in DocumentMetadata.
- EndSensitivity
- Sensitivity levels for detecting the end of speech.
- Environment
- Environments supported by the computer-use tool.
- EnvironmentMode
- Compute lifecycle modes for execution environments.
- FinishReason
- The reason why the model stopped generating tokens.
- FunctionResponseScheduling
- Scheduling strategies for tool responses.
- GeminiLiveVoice
- Standard prebuilt voice personas available in Google Gemini Live and Text-to-Speech (TTS).
- HarmBlockMethod
- Safety blocking methods.
- HarmBlockThreshold
- Safety thresholds used to block unsafe content.
- HarmCategory
- Harm categories reported by Gemini safety metadata.
- InteractionStatus
- The different activity states of the live session.
- LiveMusicPlaybackControl
- Playback control signal for music generation.
- MediaModality
- Media kinds used in token accounting details.
- MediaProcessing
- How the model processes a part's media for understanding.
- MediaResolution
- The token resolution at which input media content is sampled.
- Modality
- Server content modalities.
- MusicGenerationMode
- The mode of music generation.
- PartMediaResolutionLevel
- Media tokenization quality used for a specific part.
- ReinforcementTuningThinkingLevel
- Indicates the maximum thinking depth during reinforcement tuning.
- SafetyPolicy
- Safety policies that can be disabled for the computer-use tool.
- Scale
- Musical scale of generated music.
- ServiceTier
- Pricing and performance service tier reported in usage metadata.
- SpreadsheetMetadataContentLayer
- Content layers to extract from a spreadsheet in SpreadsheetMetadata.
- StartSensitivity
- Sensitivity levels for detecting the start of speech.
- ThinkingLevel
- Thinking effort levels for models that support thought generation.
- ToolType
- Tool categories reported in server-side tool call parts.
- TrafficType
- Traffic classes used for usage accounting.
- TurnCompleteReason
- Reasons a model turn completed without a final response.
- TurnCoverage
- How much of the user turn is forwarded to the model.
- VadSignalType
- Voice activity detection signals emitted by the server.
- VideoMetadataContentLayer
- Content layers to extract from a video in VideoMetadata.
- VoiceActivityType
- Voice activity events detected for an audio stream.
- VoicePitch
- The perceived pitch of a synthesized voice.
- VoiceType
- The type of voice resource.
Functions
-
addWavHeader(
Uint8List pcmBytes, {required int sampleRate, int numChannels = 1, int bitsPerSample = 16}) → Uint8List - PCM 오디오 데이터에 WAV 헤더를 추가하여 완전한 WAV 파일 바이트를 생성합니다.
-
parseWavHeader(
Uint8List wavBytes) → WavAudioInfo - Parses a standard 44-byte RIFF WAVE header and extracts its WavAudioInfo metadata along with the raw PCM audio payload.
-
stripWavHeader(
Uint8List bytes) → Uint8List -
Strips the 44-byte RIFF WAVE header if present, returning only raw PCM bytes.
If
bytesdoes not start with a'RIFF'/'WAVE'header, returnsbytesunchanged.
Typedefs
-
GeminiLiveMultimodalToolHandler
= FutureOr<
List< Function(Map<FunctionResponsePart> >String, dynamic> args) - Callback signature for returning multimodal FunctionResponsePart items alongside the structured JSON map in a FunctionResponse.
-
GeminiLiveToolHandler
= FutureOr<
Map< Function(Map<String, dynamic> >String, dynamic> args) - Callback signature for handling a Gemini Live function call.
- StreamTranslationConfig = TranslationConfig
- Deprecated alias for TranslationConfig.
Exceptions / Errors
- ApiClientError
- Exception thrown for 4XX client error responses from the Google GenAI API.
- ApiServerError
- Exception thrown for 5XX server error responses from the Google GenAI API.
- ContinuationInterruptedError
- An exception thrown when automatic continuation fails after partial progress.
- ContinuationTimeoutError
- An exception thrown when a per-call timeout expires before automatic continuation finishes.
- GoogleGenAiError
- Base exception thrown when an HTTP request to the Google GenAI API fails.
- TimeoutException
- Exception thrown when a Live API operation exceeds its timeout.