Structures
The following structures are available globally.
- 
                  
                  The model’s response to a generate content request. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct GenerateContentResponse : Sendableextension GenerateContentResponse: Decodable
- 
                  
                  A struct representing a possible reply to a content generation prompt. Each content generation prompt may produce multiple candidate responses. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct Candidate : Sendableextension Candidate: Decodable
- 
                  
                  A collection of source attributions for a piece of content. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct CitationMetadata : Sendableextension CitationMetadata: Decodable
- 
                  
                  A struct describing a source attribution. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct Citation : Sendable, Equatableextension Citation: Decodable
- 
                  
                  A value enumerating possible reasons for a model to terminate a content generation request. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct FinishReason : DecodableProtoEnum, Hashable, Sendable
- 
                  
                  A metadata struct containing any feedback the model had on the prompt it was provided. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct PromptFeedback : Sendableextension PromptFeedback: Decodable
- 
                  
                  Metadata returned to the client when grounding is enabled. Important If using Grounding with Google Search, you are required to comply with the “Grounding with Google Search” usage requirements for your chosen API provider: Gemini Developer API or Vertex AI Gemini API (see Service Terms section within the Service Specific Terms). DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct GroundingMetadata : Sendable, Equatable, Hashableextension GroundingMetadata: Decodable
- 
                  
                  Represents a specific segment within a ModelContentstruct, often used to pinpoint the exact location of text or data that grounding information refers to.DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct Segment : Sendable, Equatable, Hashableextension Segment: Decodable
- 
                  
                  A struct defining model parameters to be used when sending generative AI requests to the backend model. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct GenerationConfig : Sendableextension GenerationConfig: Encodable
- 
                  
                  Configuration parameters for sending requests to the backend. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct RequestOptions : Sendableextension RequestOptions: Equatable
- 
                  
                  Represents token counting info for a single modality. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct ModalityTokenCount : Sendableextension ModalityTokenCount: Decodable
- 
                  
                  Content part modality. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct ContentModality : DecodableProtoEnum, Hashable, Sendable
- 
                  
                  A type describing data in media formats interpretable by an AI model. Each generative AI request or response contains an ArrayofModelContents, and eachModelContentvalue may comprise multiple heterogeneousParts.DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct ModelContent : Equatable, Sendableextension ModelContent: Codable
- 
                  
                  A type defining potentially harmful media categories and their model-assigned ratings. A value of this type may be assigned to a category for every model-generated response, not just responses that exceed a certain threshold. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct SafetyRating : Equatable, Hashable, Sendableextension SafetyRating: Decodable
- 
                  
                  A type used to specify a threshold for harmful content, beyond which the model will return a fallback response instead of generated content. See safety settings for Gemini models for more details. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct SafetySetting : Sendableextension SafetySetting: Encodable
- 
                  
                  Categories describing the potential harm a piece of content may pose. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct HarmCategory : CodableProtoEnum, Hashable, Sendable
- 
                  
                  Structured representation of a function declaration. This FunctionDeclarationis a representation of a block of code that can be used as aToolby the model and executed by the client.DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct FunctionDeclaration : Sendableextension FunctionDeclaration: Encodable
- 
                  
                  A tool that allows the generative model to connect to Google Search to access and incorporate up-to-date information from the web into its responses. Important When using this feature, you are required to comply with the “Grounding with Google Search” usage requirements for your chosen API provider: Gemini Developer API or Vertex AI Gemini API (see Service Terms section within the Service Specific Terms). DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct GoogleSearch : Sendableextension GoogleSearch: Encodable
- 
                  
                  A helper tool that the model may use when generating responses. A Toolis a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model.DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct Tool : Sendableextension Tool: Encodable
- 
                  
                  Configuration for specifying function calling behavior. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct FunctionCallingConfig : Sendableextension FunctionCallingConfig: Encodable
- 
                  
                  Tool configuration for any Toolspecified in the request.DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct ToolConfig : Sendableextension ToolConfig: Encodable
- 
                  
                  The model’s response to a count tokens request. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct CountTokensResponse : Sendableextension CountTokensResponse: Decodable
- 
                  
                  Represents available backend APIs for the Firebase AI SDK. DeclarationSwift public struct Backend
- 
                  
                  An aspect ratio for images generated by Imagen. To specify an aspect ratio for generated images, set aspectRatioin yourImagenGenerationConfig. See the Cloud documentation for more details and examples of the supported aspect ratios.DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct ImagenAspectRatio : Sendable
- 
                  
                  Configuration options for generating images with Imagen. See Parameters for Imagen models to learn about parameters available for use with Imagen models, including how to configure them. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct ImagenGenerationConfig
- 
                  
                  A response from a request to generate images with Imagen. The type placeholder Tis an image type; this is currently always anImagenInlineImage.This type is returned from: - generateImages(prompt:)where- Tis- ImagenInlineImage
 DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct ImagenGenerationResponse<T> : Sendable where T : Sendableextension ImagenGenerationResponse: Decodable where T: Decodable
- 
                  
                  An image format for images generated by Imagen. To specify an image format for generated images, set imageFormatin yourImagenGenerationConfig. See the Cloud documentation for more details.DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct ImagenImageFormat
- 
                  
                  An error that occurs when image generation fails due to all generated images being blocked. The images may have been blocked due to the specified ImagenSafetyFilterLevel, theImagenPersonFilterLevel, or filtering included in the model. These filter levels may be adjusted in yourImagenSafetySettings. See the Responsible AI and usage guidelines for Imagen for more details.DeclarationSwift public struct ImagenImagesBlockedError : Errorextension ImagenImagesBlockedError: CustomNSError
- 
                  
                  An image generated by Imagen, represented as inline data. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct ImagenInlineImage : Sendableextension ImagenInlineImage: Equatableextension ImagenInlineImage: Decodable
- 
                  
                  A filter level controlling whether generation of images containing people or faces is allowed. See the personGenerationdocumentation for more details.DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct ImagenPersonFilterLevel : ProtoEnum
- 
                  
                  A filter level controlling how aggressively to filter sensitive content. Text prompts provided as inputs and images (generated or uploaded) through Imagen on Vertex AI are assessed against a list of safety filters, which include ‘harmful categories’ (for example, violence,sexual,derogatory, andtoxic). This filter level controls how aggressively to filter out potentially harmful content from responses. See thesafetySettingdocumentation and the Responsible AI and usage guidelines for more details.DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct ImagenSafetyFilterLevel : ProtoEnum, Sendable
- 
                  
                  Settings for controlling the aggressiveness of filtering out sensitive content. See the Responsible AI and usage guidelines for more details. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct ImagenSafetySettings
- 
                  
                  Configuration options for audio transcriptions when communicating with a model that supports the Gemini Live API. While there are not currently any options, this will likely change in the future. For now, just providing an instance of this struct will enable audio transcriptions for the corresponding input or output fields. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, *) @available(watchOS, unavailable) public struct AudioTranscriptionConfig : Sendable
- 
                  
                  Text transcription of some audio form during a live interaction with the model. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, *) @available(watchOS, unavailable) public struct LiveAudioTranscription : Sendable
- 
                  
                  Configuration options for live content generation. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, *) @available(watchOS, unavailable) public struct LiveGenerationConfig : Sendable
- 
                  
                  Incremental server update generated by the model in response to client messages. Content is generated as quickly as possible, and not in realtime. Clients may choose to buffer and play it out in realtime. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, *) @available(watchOS, unavailable) public struct LiveServerContent : Sendable
- 
                  
                  Server will not be able to service client soon. To learn more about session limits, see the docs on Maximum session duration. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, *) @available(watchOS, unavailable) public struct LiveServerGoingAwayNotice : Sendable
- 
                  
                  Update from the server, generated from the model in response to client messages. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, *) @available(watchOS, unavailable) public struct LiveServerMessage : Sendable
- 
                  
                  Request for the client to execute the provided functionCalls.The client should return matching FunctionResponsePart, where thefunctionIdfields correspond to individualFunctionCallParts.DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) @available(watchOS, unavailable) public struct LiveServerToolCall : Sendable
- 
                  
                  Notification for the client to cancel a previous function call from LiveServerToolCall.The client does not need to send FunctionResponseParts for the cancelledFunctionCallParts.DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, *) @available(watchOS, unavailable) public struct LiveServerToolCallCancellation : Sendable
- 
                  
                  The model sent a message that the SDK failed to parse. This may indicate that the SDK version needs updating, a model is too old for the current SDK version, or that the model is just not supported. Check the NSUnderlyingErrorKeyentry inerrorUserInfofor the error that caused this.DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, *) @available(watchOS, unavailable) public struct LiveSessionUnsupportedMessageError : Error, Sendable, CustomNSError
- 
                  
                  The live session was closed, because the network connection was lost. Check the NSUnderlyingErrorKeyentry inerrorUserInfofor the error that caused this.DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, *) @available(watchOS, unavailable) public struct LiveSessionLostConnectionError : Error, Sendable, CustomNSError
- 
                  
                  The live session was closed, but not for a reason the SDK expected. Check the NSUnderlyingErrorKeyentry inerrorUserInfofor the error that caused this.DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, *) @available(watchOS, unavailable) public struct LiveSessionUnexpectedClosureError : Error, Sendable, CustomNSError
- 
                  
                  The model refused our request to setup a live session. This can occur due to the model not supporting the requested response modalities, the project not having access to the model, the model being invalid, or some internal error. Check the NSUnderlyingErrorKeyentry inerrorUserInfofor the error that caused this.DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, *) @available(watchOS, unavailable) public struct LiveSessionSetupError : Error, Sendable, CustomNSError
- 
                  
                  Configuration for controlling the voice of the model during conversation. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, *) @available(watchOS, unavailable) public struct SpeechConfig : Sendable
- 
                  
                  A text part containing a string value. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct TextPart : Part
- 
                  
                  A data part that is provided inline in requests. Data provided as an inline data part is encoded as base64 and included directly (inline) in the request. For large files, see FileDataPartwhich references content by URI instead of including the data in the request.Important Only small files can be sent as inline data because of limits on total request sizes; see input files and requirements for more details and size limits. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct InlineDataPart : Part
- 
                  
                  File data stored in Cloud Storage for Firebase, referenced by URI. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct FileDataPart : Part
- 
                  
                  A predicted function call returned from the model. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct FunctionCallPart : Part
- 
                  
                  Result output from a function call. Contains a string representing the FunctionDeclaration.nameand a structured JSON object containing any output from the function is used as context to the model. This should contain the result of aFunctionCallPartmade based on model prediction.DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct FunctionResponsePart : Part
- 
                  
                  A part containing code that was executed by the model. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct ExecutableCodePart : Part
- 
                  
                  The result of executing code. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct CodeExecutionResultPart : Part
- 
                  
                  Represents the different types, or modalities, of data that a model can produce as output. To configure the desired output modalities for model requests, set the responseModalitiesparameter when initializing aGenerationConfig. See the multimodal responses documentation for more details.Important Support for each response modality, or combination of modalities, depends on the model. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct ResponseModality : EncodableProtoEnum, Sendable
- 
                  
                  Configuration for controlling the “thinking” behavior of compatible Gemini models. Certain models, like Gemini 2.5 Flash and Pro, utilize a thinking process before generating a response. This allows them to reason through complex problems and plan a more coherent and accurate answer. DeclarationSwift public struct ThinkingConfig : Sendableextension ThinkingConfig: Encodable
- 
                  
                  A tool that allows the model to execute code. This tool can be used to solve complex problems, for example, by generating and executing Python code to solve a math problem. DeclarationSwift public struct CodeExecution : Sendable, Encodable
- 
                  
                  Metadata related to the urlContext()tool.Warning URL context is a Public Preview feature, which means that it is not subject to any SLA or deprecation policy and could change in backwards-incompatible ways. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct URLContextMetadata : Sendable, Hashableextension URLContextMetadata: Decodable
- 
                  
                  Metadata for a single URL retrieved by the urlContext()tool.Warning URL context is a Public Preview feature, which means that it is not subject to any SLA or deprecation policy and could change in backwards-incompatible ways. DeclarationSwift @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct URLMetadata : Sendable, Hashableextension URLMetadata: Decodable