TemplateGenerativeModel
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public final class TemplateGenerativeModel : SendableA type that represents a remote multimodal model (like Gemini), with the ability to generate content based on various input types.
Public Preview: This API is a public preview and may be subject to change.
-
Generates content from a prompt template and inputs.
Public Preview: This API is a public preview and may be subject to change.
Throws
AGenerateContentErrorif the request failed.Declaration
Swift
public func generateContent(templateID: String, inputs: [String: Any], options: RequestOptions = RequestOptions()) async throws -> GenerateContentResponseParameters
templateIDThe ID of the prompt template to use.
inputsA dictionary of variables to substitute into the template.
optionsThe
RequestOptionsfor the request, currently used to override default request timeout.Return Value
The content generated by the model.
-
Generates content from a prompt template and inputs, with streaming responses.
Public Preview: This API is a public preview and may be subject to change.
Throws
AGenerateContentErrorif the request failed.Declaration
Swift
public func generateContentStream(templateID: String, inputs: [String: Any], options: RequestOptions = RequestOptions()) throws -> AsyncThrowingStream<GenerateContentResponse, Error>Parameters
templateIDThe ID of the prompt template to use.
inputsA dictionary of variables to substitute into the template.
optionsThe
RequestOptionsfor the request, currently used to override default request timeout.Return Value
An
AsyncThrowingStreamthat yieldsGenerateContentResponseobjects.