@@ -26,6 +26,8 @@ public final class GenerativeModel {
2626 /// The backing service responsible for sending and receiving model requests to the backend.
2727 let generativeAIService : GenerativeAIService
2828
29+ let location : String
30+
2931 /// Configuration parameters used for the MultiModalModel.
3032 let generationConfig : GenerationConfig ?
3133
@@ -61,6 +63,7 @@ public final class GenerativeModel {
6163 init ( name: String ,
6264 projectID: String ,
6365 apiKey: String ,
66+ location: String = " us-central1 " ,
6467 generationConfig: GenerationConfig ? = nil ,
6568 safetySettings: [ SafetySetting ] ? = nil ,
6669 tools: [ Tool ] ? ,
@@ -78,6 +81,7 @@ public final class GenerativeModel {
7881 auth: auth,
7982 urlSession: urlSession
8083 )
84+ self . location = location
8185 self . generationConfig = generationConfig
8286 self . safetySettings = safetySettings
8387 self . tools = tools
@@ -125,6 +129,7 @@ public final class GenerativeModel {
125129 try content. throwIfError ( )
126130 let response : GenerateContentResponse
127131 let generateContentRequest = GenerateContentRequest ( model: modelResourceName,
132+ location: location,
128133 contents: content,
129134 generationConfig: generationConfig,
130135 safetySettings: safetySettings,
@@ -182,6 +187,7 @@ public final class GenerativeModel {
182187 -> AsyncThrowingStream < GenerateContentResponse , Error > {
183188 try content. throwIfError ( )
184189 let generateContentRequest = GenerateContentRequest ( model: modelResourceName,
190+ location: location,
185191 contents: content,
186192 generationConfig: generationConfig,
187193 safetySettings: safetySettings,
@@ -253,6 +259,7 @@ public final class GenerativeModel {
253259 public func countTokens( _ content: [ ModelContent ] ) async throws -> CountTokensResponse {
254260 let countTokensRequest = CountTokensRequest (
255261 model: modelResourceName,
262+ location: location,
256263 contents: content,
257264 systemInstruction: systemInstruction,
258265 tools: tools,
0 commit comments