Classes
The following classes are available globally.
-
An object that represents a back-and-forth chat with a model, capturing the history and saving the context in memory between each message sent.
Declaration
Swift
public final class Chat : Sendable -
The Firebase AI SDK provides access to Gemini models directly from your app.
Declaration
Swift
public final class FirebaseAI : Sendable -
A type that represents a remote multimodal model (like Gemini), with the ability to generate content based on various input types.
Declaration
Swift
public final class GenerativeModel : Sendable -
[Public Preview] An ongoing conversation with a model backed by a server prompt template.
Warning
This API is a public preview and may be subject to change.
A
TemplateChatmanages conversation history on the client while utilizing the prompt, system instructions, and configurations defined in a server prompt template. The template's configurations apply to every turn automatically.Function Calling in Chat
If the template defines function declarations in its frontmatter
tools, the model may return aFunctionCallPartin its response candidates. When this occurs, execute the local function logic and supply the result as aFunctionResponsePartin a new message using one of thesendMessage(_:)orsendMessageStream(_:)methods to continue the conversation.For more details, see Multi-turn interactions with server prompt templates.
Declaration
Swift
public final class TemplateChat : Sendable -
[Public Preview] A multimodal model (like Gemini) that generates content using server-managed prompt templates.
Warning
This API is a public preview and may be subject to change.
When using server prompt templates, prompts, system instructions, tools, and model configurations are defined and stored server-side in the Firebase console or via the Firebase AI Logic REST API. Client applications only pass a template identifier and any runtime input variables required by the template.
Benefits of this approach include:
- Protecting prompts and system instructions from exposure in client code.
- Updating prompts, schemas, and configurations without releasing a new app version.
Tip
We recommend versioning your template IDs (for example,
my-template-v1-0-0) and using Firebase Remote Config to dynamically manage template IDs in client requests.For more details, see the Server Prompt Templates guide.
Declaration
Swift
public final class TemplateGenerativeModel : Sendable -
A multimodal model (like Gemini) capable of real-time content generation based on various input types, supporting bidirectional streaming.
You can create a new session via
LiveGenerativeModel/connect().Declaration
Swift
@available(watchOS, unavailable) public final class LiveGenerativeModel -
A live WebSocket session, capable of streaming content to and from the model.
Messages are streamed through
responses, and can be sent through either the dedicated realtime API function (such assendAudioRealtime(_:)andsendTextRealtime(_:)), or through the incremental API (such assendContent(_:turnComplete:)).To create an instance of this class, see
LiveGenerativeModel.Declaration
Swift
@available(watchOS, unavailable) public final class LiveSession : Sendable -
A
Schemaobject 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.
Declaration
Swift
public final class Schema : Sendableextension Schema: Encodableextension Schema: Equatable