File tree Expand file tree Collapse file tree 2 files changed +6
-17
lines changed
core/src/main/java/com/google/adk/models Expand file tree Collapse file tree 2 files changed +6
-17
lines changed Original file line number Diff line number Diff line change @@ -193,8 +193,6 @@ public Builder vertexCredentials(VertexCredentials vertexCredentials) {
193193 *
194194 * @return A new {@link Gemini} instance.
195195 * @throws NullPointerException if modelName is null.
196- * @throws IllegalStateException if none of apiKey, VertexCredentials, or an explicit apiClient
197- * is set.
198196 */
199197 public Gemini build () {
200198 Objects .requireNonNull (modelName , "modelName must be set." );
@@ -206,9 +204,11 @@ public Gemini build() {
206204 } else if (vertexCredentials != null ) {
207205 return new Gemini (modelName , vertexCredentials );
208206 } else {
209- throw new IllegalStateException (
210- "Authentication strategy not set: Either apiKey, VertexCredentials, or an explicit"
211- + " apiClient must be provided." );
207+ return new Gemini (
208+ modelName ,
209+ Client .builder ()
210+ .httpOptions (HttpOptions .builder ().headers (TRACKING_HEADERS ).build ())
211+ .build ());
212212 }
213213 }
214214 }
Original file line number Diff line number Diff line change 1616
1717package com .google .adk .models ;
1818
19- import com .google .genai .Client ;
2019import java .util .Map ;
2120import java .util .concurrent .ConcurrentHashMap ;
2221
@@ -32,22 +31,12 @@ public interface LlmFactory {
3231 BaseLlm create (String modelName );
3332 }
3433
35- /** API client for interacting with the Gemini model. */
36- private static final Client geminiApiClient = Client .builder ().build ();
37-
3834 /** Map of model name patterns regex to factories. */
3935 private static final Map <String , LlmFactory > llmFactories = new ConcurrentHashMap <>();
4036
41- /** Returns the singleton instance of the Gemini API client. */
42- private static Client getGeminiApiClient () {
43- return geminiApiClient ;
44- }
45-
4637 /** Registers default LLM factories, e.g. for Gemini models. */
4738 static {
48- registerLlm (
49- "gemini-.*" ,
50- modelName -> Gemini .builder ().modelName (modelName ).apiClient (getGeminiApiClient ()).build ());
39+ registerLlm ("gemini-.*" , modelName -> Gemini .builder ().modelName (modelName ).build ());
5140 }
5241
5342 /**
You can’t perform that action at this time.
0 commit comments