# Classes

The following classes are available globally.
- `


  ### [Chat](https://firebase.google.com/docs/reference/swift/firebaseailogic/api/reference/Classes/Chat)


  ` 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

- `


  ### [FirebaseAI](https://firebase.google.com/docs/reference/swift/firebaseailogic/api/reference/Classes/FirebaseAI)


  ` The Firebase AI SDK provides access to Gemini models directly from your app.

  #### Declaration

  Swift

      public final class FirebaseAI : Sendable

- `


  ### [GenerativeModel](https://firebase.google.com/docs/reference/swift/firebaseailogic/api/reference/Classes/GenerativeModel)


  ` 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

- `


  ### [TemplateChat](https://firebase.google.com/docs/reference/swift/firebaseailogic/api/reference/Classes/TemplateChat)


  ` **\[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 `TemplateChat` manages 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.

  > [!CAUTION]
  > Important
  >
  > The referenced server prompt template must include the `{{history}}` tag in its
  > content, which instructs the template where to inject the conversation turns.

  ### Function Calling in Chat

  If the template defines function declarations in its frontmatter `tools`, the model may return
  a `https://firebase.google.com/docs/reference/swift/firebaseailogic/api/reference/Structs/FunctionCallPart` in its response candidates. When this occurs, execute the local function
  logic and supply the result as a `https://firebase.google.com/docs/reference/swift/firebaseailogic/api/reference/Structs/FunctionResponsePart` in a new message using one of the
  `sendMessage(_:)` or `sendMessageStream(_:)` methods to continue the conversation.

  For more details, see
  [Multi-turn interactions with server prompt templates](https://firebase.google.com/docs/ai-logic/server-prompt-templates/multi-turn-interactions).

  #### Declaration

  Swift

      public final class TemplateChat : Sendable

- `


  ### [TemplateGenerativeModel](https://firebase.google.com/docs/reference/swift/firebaseailogic/api/reference/Classes/TemplateGenerativeModel)


  ` **\[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](https://firebase.google.com/docs/ai-logic/server-prompt-templates/versioning-with-remote-config)
  to dynamically manage template IDs in client requests.

  For more details, see the
  [Server Prompt Templates
  guide](https://firebase.google.com/docs/ai-logic/server-prompt-templates/get-started).

  #### Declaration

  Swift

      public final class TemplateGenerativeModel : Sendable

- `


  ### [LiveGenerativeModel](https://firebase.google.com/docs/reference/swift/firebaseailogic/api/reference/Classes/LiveGenerativeModel)


  ` 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

- `


  ### [LiveSession](https://firebase.google.com/docs/reference/swift/firebaseailogic/api/reference/Classes/LiveSession)


  ` A live WebSocket session, capable of streaming content to and from the model.

  Messages are streamed through `https://firebase.google.com/docs/reference/swift/firebaseailogic/api/reference/Classes/LiveSession#/s:15FirebaseAILogic11LiveSessionC9responsesScsyAA0C13ServerMessageVs5Error_pGvp`, and can be sent through either the
  dedicated realtime API function (such as `https://firebase.google.com/docs/reference/swift/firebaseailogic/api/reference/Classes/LiveSession#/s:15FirebaseAILogic11LiveSessionC17sendAudioRealtimeyy10Foundation4DataVYaF` and
  `https://firebase.google.com/docs/reference/swift/firebaseailogic/api/reference/Classes/LiveSession#/s:15FirebaseAILogic11LiveSessionC16sendTextRealtimeyySSYaF`), or through the incremental API (such as
  `https://firebase.google.com/docs/reference/swift/firebaseailogic/api/reference/Classes/LiveSession#/s:15FirebaseAILogic11LiveSessionC11sendContent_12turnCompleteySayAA05ModelF0VG_SbtYaF`).

  To create an instance of this class, see `https://firebase.google.com/docs/reference/swift/firebaseailogic/api/reference/Classes/LiveGenerativeModel`.

  #### Declaration

  Swift

      @available(watchOS, unavailable)
      public final class LiveSession : Sendable

- `


  ### [Schema](https://firebase.google.com/docs/reference/swift/firebaseailogic/api/reference/Classes/Schema)


  ` A `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](https://spec.openapis.org/oas/v3.0.3#schema).

  #### Declaration

  Swift

      public final class Schema : Sendable

      extension Schema: Encodable

      extension Schema: Equatable