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(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct FunctionDeclaration : Sendableextension FunctionDeclaration: 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.Declaration
Swift
@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.
Declaration
Swift
@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.Declaration
Swift
@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 generate content request.
Declaration
Swift
@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.
Declaration
Swift
@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.
Declaration
Swift
@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.
Declaration
Swift
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct Citation : Sendableextension Citation: Decodable -
A value enumerating possible reasons for a model to terminate a content generation request.
Declaration
Swift
@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.
Declaration
Swift
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct PromptFeedback : Sendableextension PromptFeedback: Decodable -
A struct defining model parameters to be used when sending generative AI requests to the backend model.
Declaration
Swift
@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.
Declaration
Swift
@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.
Declaration
Swift
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct ModalityTokenCount : Sendableextension ModalityTokenCount: Decodable -
Content part modality.
Declaration
Swift
@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.Declaration
Swift
@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.
Declaration
Swift
@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.
Declaration
Swift
@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.
Declaration
Swift
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct HarmCategory : CodableProtoEnum, Hashable, Sendable -
The model’s response to a count tokens request.
Declaration
Swift
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct CountTokensResponseextension CountTokensResponse: Decodable -
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.Declaration
Swift
@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.
Declaration
Swift
@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:)whereTisImagenInlineImage
Declaration
Swift
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct ImagenGenerationResponse<T>extension 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.Declaration
Swift
@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.Declaration
Swift
public struct ImagenImagesBlockedError : Errorextension ImagenImagesBlockedError: CustomNSError -
An image generated by Imagen, represented as inline data.
Declaration
Swift
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct ImagenInlineImageextension ImagenInlineImage: Equatableextension ImagenInlineImage: Decodable -
A filter level controlling whether generation of images containing people or faces is allowed.
See the
personGenerationdocumentation for more details.Declaration
Swift
@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.Declaration
Swift
@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.
Declaration
Swift
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct ImagenSafetySettings -
A text part containing a string value.
Declaration
Swift
@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.
Declaration
Swift
@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.
Declaration
Swift
@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.
Declaration
Swift
@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.Declaration
Swift
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct FunctionResponsePart : 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.
Declaration
Swift
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct ResponseModality : EncodableProtoEnum, Sendable