adk-java
adk-java copied to clipboard
Setting api key programmatically
Sorry if I missed something obvious but is there way to set api key (e.g. for Gemini) programmatically?
you might try this:
return LlmAgent.builder()
.model(new Gemini("gemini-2.0-flash",
Client.builder()
.vertexAI(false)
.apiKey(GOOGLE_API_KEY)
.build()))
.name(NAME)
.instruction("You are a helpful agent who can answer user questions about the time and weather in a city.")
.build();
That worked, thanks!
Also there is a simpler way that is coming out in 0.2.0 https://github.com/google/adk-java/blob/c8fed2db9b142696aca9468742c17ea283a73f4a/core/src/main/java/com/google/adk/models/Gemini.java#L92