@@ -45,6 +45,40 @@ public final class GenerativeModel {
4545 /// Configuration parameters for sending requests to the backend.
4646 let requestOptions : RequestOptions
4747
48+ /// Initializes a new remote model with the given parameters.
49+ ///
50+ /// - Parameters:
51+ /// - name: The name of the model to use, e.g., `"gemini-1.5-pro-latest"`; see
52+ /// [Gemini models](https://ai.google.dev/models/gemini) for a list of supported model names.
53+ /// - apiKey: The API key for your project.
54+ /// - generationConfig: The content generation parameters your model should use.
55+ /// - safetySettings: A value describing what types of harmful content your model should allow.
56+ /// - tools: A list of ``Tool`` objects that the model may use to generate the next response.
57+ /// - systemInstruction: Instructions that direct the model to behave a certain way; currently
58+ /// only text content is supported.
59+ /// - toolConfig: Tool configuration for any `Tool` specified in the request.
60+ /// - requestOptions Configuration parameters for sending requests to the backend.
61+ public convenience init ( name: String ,
62+ apiKey: String ,
63+ generationConfig: GenerationConfig ? = nil ,
64+ safetySettings: [ SafetySetting ] ? = nil ,
65+ tools: [ Tool ] ? = nil ,
66+ toolConfig: ToolConfig ? = nil ,
67+ systemInstruction: any ThrowingPartsRepresentable ... ,
68+ requestOptions: RequestOptions = RequestOptions ( ) ) {
69+ self . init (
70+ name: name,
71+ apiKey: apiKey,
72+ generationConfig: generationConfig,
73+ safetySettings: safetySettings,
74+ tools: tools,
75+ toolConfig: toolConfig,
76+ systemInstruction: try ? ModelContent ( role: " system " , parts: systemInstruction) ,
77+ requestOptions: requestOptions,
78+ urlSession: . shared
79+ )
80+ }
81+
4882 /// Initializes a new remote model with the given parameters.
4983 ///
5084 /// - Parameters:
0 commit comments