FirebaseVertexAI Framework Reference Stay organized with collections Save and categorize content based on your preferences.
Structures
The following structures are available globally.
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.Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructFunctionDeclaration:SendableextensionFunctionDeclaration:EncodableA 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 performan action, or set of actions, outside of knowledge and scope of the model.Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructTool:SendableextensionTool:EncodableConfiguration for specifying function calling behavior.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructFunctionCallingConfig:SendableextensionFunctionCallingConfig:EncodableTool configuration for any
Toolspecified in the request.Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructToolConfig:SendableextensionToolConfig:EncodableThe model’s response to a generate content request.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructGenerateContentResponse:SendableextensionGenerateContentResponse:DecodableA struct representing a possible reply to a content generation prompt. Each content generationprompt may produce multiple candidate responses.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructCandidate:SendableextensionCandidate:DecodableA collection of source attributions for a piece of content.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructCitationMetadata:SendableextensionCitationMetadata:DecodableA struct describing a source attribution.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructCitation:SendableextensionCitation:DecodableA value enumerating possible reasons for a model to terminate a content generation request.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructFinishReason:DecodableProtoEnum,Hashable,SendableA metadata struct containing any feedback the model had on the prompt it was provided.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructPromptFeedback:SendableextensionPromptFeedback:DecodableA struct defining model parameters to be used when sending generative AIrequests to the backend model.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructGenerationConfig:SendableextensionGenerationConfig:EncodableConfiguration parameters for sending requests to the backend.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructRequestOptions:SendableextensionRequestOptions:EquatableRepresents token counting info for a single modality.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructModalityTokenCount:SendableextensionModalityTokenCount:DecodableContent part modality.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructContentModality:DecodableProtoEnum,Hashable,SendableA type describing data in media formats interpretable by an AI model. Each generative AIrequest or response contains an
ArrayofModelContents, and eachModelContentvaluemay comprise multiple heterogeneousParts.Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructModelContent:Equatable,SendableextensionModelContent:CodableA type defining potentially harmful media categories and their model-assigned ratings. A valueof this type may be assigned to a category for every model-generated response, not justresponses that exceed a certain threshold.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructSafetyRating:Equatable,Hashable,SendableextensionSafetyRating:DecodableA type used to specify a threshold for harmful content, beyond which the model will return afallback response instead of generated content.
Seesafety settings for Geminimodels formore details.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructSafetySetting:SendableextensionSafetySetting:EncodableCategories describing the potential harm a piece of content may pose.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructHarmCategory:CodableProtoEnum,Hashable,SendableThe model’s response to a count tokens request.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructCountTokensResponseextensionCountTokensResponse:DecodableAn aspect ratio for images generated by Imagen.
To specify an aspect ratio for generated images, set
aspectRatioinyourImagenGenerationConfig. See theClouddocumentationfor more details and examples of the supported aspect ratios.Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructImagenAspectRatio:SendableConfiguration options for generating images with Imagen.
SeeParameters for Imagenmodels tolearn about parameters available for use with Imagen models, including how to configure them.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructImagenGenerationConfigA 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:)whereTisImagenInlineImage
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructImagenGenerationResponse<T>extensionImagenGenerationResponse:DecodablewhereT:DecodableAn image format for images generated by Imagen.
To specify an image format for generated images, set
imageFormatinyourImagenGenerationConfig. See theClouddocumentationfor more details.Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructImagenImageFormatAn 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 beadjusted in yourImagenSafetySettings. See theResponsible AI and usage guidelines forImagenfor more details.Declaration
Swift
publicstructImagenImagesBlockedError:ErrorextensionImagenImagesBlockedError:CustomNSErrorAn image generated by Imagen, represented as inline data.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructImagenInlineImageextensionImagenInlineImage:EquatableextensionImagenInlineImage:DecodableA filter level controlling whether generation of images containing people or faces is allowed.
See the
personGenerationdocumentation for more details.Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructImagenPersonFilterLevel:ProtoEnumA filter level controlling how aggressively to filter sensitive content.
Text prompts provided as inputs and images (generated or uploaded) through Imagen on Vertex AIare assessed against a list of safety filters, which include ‘harmful categories’ (for example,
violence,sexual,derogatory, andtoxic). This filter level controls how aggressively tofilter out potentially harmful content from responses. See thesafetySettingdocumentation and theResponsible AI and usageguidelinesfor more details.Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructImagenSafetyFilterLevel:ProtoEnum,SendableSettings for controlling the aggressiveness of filtering out sensitive content.
See theResponsible AI and usageguidelinesfor more details.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructImagenSafetySettingsA text part containing a string value.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructTextPart:PartA data part that is provided inline in requests.
Data provided as an inline data part is encoded as base64 and included directly (inline) in therequest. For large files, see
FileDataPartwhich references content by URI instead ofincluding the data in the request.Important
Only small files can be sent as inline data because of limits on total requestsizes; seeinput files and requirements for more details and size limits.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructInlineDataPart:PartFile data stored in Cloud Storage for Firebase, referenced by URI.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructFileDataPart:PartA predicted function call returned from the model.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructFunctionCallPart:PartResult output from a function call.
Contains a string representing the
FunctionDeclaration.nameand a structured JSON objectcontaining any output from the function is used as context to the model. This should contain theresult of aFunctionCallPartmade based on model prediction.Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructFunctionResponsePart:PartRepresents 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 themultimodalresponsesdocumentation for more details.Important
Support for each response modality, or combination of modalities, depends on themodel.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructResponseModality:EncodableProtoEnum,Sendable
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-04-21 UTC.