compat/firebase_ai library
Drop-in replacement for the Live API of package:firebase_ai.
Exposes the same class names and signatures as firebase_ai 4.x, backed by the gemini_live WebSocket engine, without Firebase setup. Moving between the two packages takes two edits:
// firebase_ai
import 'package:firebase_ai/firebase_ai.dart';
await Firebase.initializeApp();
// gemini_live
import 'package:gemini_live/compat/firebase_ai.dart';
FirebaseAI.initialize(apiKey: 'YOUR_GEMINI_API_KEY');
Everything from FirebaseAI.googleAI().liveGenerativeModel(...) onward is
shared. Members of GeminiLiveSessionExtras and GeminiLiveResponseExtras
are gemini_live only.
This library does not export the core package:gemini_live/gemini_live.dart
API, whose Content, Part, Tool and LiveSession types differ. Import
that library with a prefix if both are needed in one file.
Classes
- ActivityDetectionConfig
- Configures automatic detection of user activity.
- AudioTranscriptionConfig
- The audio transcription configuration.
- AutoFunctionDeclaration
- A FunctionDeclaration that carries its own implementation.
- CodeExecution
- A tool that enables the model to use code execution.
- CodeExecutionResultPart
- A Part that represents the code execution result from the model.
- Content
- The base structured datatype containing multi-part content of a message.
- ContextWindowCompressionConfig
- Enables context window compression to manage the model's context window.
- ExecutableCodePart
- A Part that represents the code that is executed by the model.
- FileData
- A Part with Firebase Storage uri as prompt content
- FirebaseAI
-
Entry point mirroring
FirebaseAIfrompackage:firebase_ai. - FunctionCall
-
A predicted
FunctionCallreturned from the model that contains a string representing theFunctionDeclaration.namewith the arguments and their values. - FunctionDeclaration
- Structured representation of a function declaration as defined by the OpenAPI 3.03 specification.
- FunctionResponse
- The response class for FunctionCall
- GeminiTokenUsageTracker
- Real-time token usage and cost tracker for Gemini Live API sessions.
- GoingAwayNotice
- A server message indicating that the server will not be able to service the client soon.
- GoogleMaps
- A tool that allows a Gemini model to connect to Google Maps.
- GoogleSearch
- A tool that allows a Gemini model to connect to Google Search.
- InlineDataPart
- A Part with the byte content of a file.
- JSONSchema
- The definition of a JSON Schema data type.
- LiveGenerationConfig
- Configuration options for live content generation.
- LiveGenerativeModel
- A live, generative AI model for real-time interaction.
- LiveServerContent
- Content generated by the model in a live stream.
- LiveServerMessage
- An abstract class representing a message received from a live server.
- LiveServerResponse
- A single response chunk received during a live content generation.
- LiveServerToolCall
- A tool call in a live stream.
- LiveServerToolCallCancellation
- A tool call cancellation in a live stream.
- LiveSession
- Manages asynchronous communication with Gemini model over a WebSocket connection.
- MultiSpeakerVoiceConfig
- The configuration for the multi-speaker setup.
- Part
- A datatype containing media that is part of a multi-part Content message.
- RealtimeInputConfig
- Configures the realtime input behavior of the model.
- Schema
- The definition of an input or output data types.
- SessionResumptionConfig
- Configuration for the session resumption mechanism.
- SessionResumptionUpdate
- An update of the session resumption state.
- SlidingWindow
- Configures the sliding window context compression mechanism.
- SpeakerVoiceConfig
- The configuration for a single speaker in a multi speaker setup.
- SpeechConfig
- Speech configuration class for setting the voice of the model.
- TextPart
- A Part with the text content.
- Tool
- Tool details that the model may use to generate a response.
- Transcription
- Audio transcription message.
- UnknownPart
- A Part with an unrecognized shape, kept as raw json.
- UrlContext
- A tool that allows you to provide additional context to the model in the form of public web URLs.
Enums
- ActivityHandling
- The different ways of handling user activity.
- GeminiLiveVoice
- Standard prebuilt voice personas available in Google Gemini Live and Text-to-Speech (TTS).
- MediaResolution
- Media resolution for the input media.
- ResponseModalities
- The available response modalities.
- SchemaType
- The value type of a Schema.
- Sensitivity
- Sensitivity of the automatic activity detection.
- TurnCoverage
- Options about which input is included in the user's turn.
Extensions
- GeminiLiveResponseExtras on LiveServerResponse
- Features that only gemini_live provides. See GeminiLiveSessionExtras.
- GeminiLiveSessionExtras on LiveSession
- Features that only gemini_live provides.
Exceptions / Errors
- FirebaseAIException
- Exception thrown when generating content fails.
- FirebaseAISdkException
- Exception indicating a stale package version or implementation bug.
- InvalidApiKey
- Exception thrown when the API key is invalid.
- QuotaExceeded
- Exception thrown when the quota is exceeded.
- ServerException
- Exception thrown when the server failed to generate content.
- ServiceApiNotEnabled
- Exception thrown when the Firebase AI Logic API is not enabled.
- UnsupportedUserLocation
- Exception thrown when the user location is unsupported.