Class GeminiAPI
java.lang.Object
uno.anahata.ai.gemini.GeminiAPI
Manages the connection to the Gemini API, including API key rotation and model selection.
This class loads API keys from a configuration file and provides a round-robin mechanism for selecting a key for each request, helping to distribute load and stay within rate limits.
-
Constructor Summary
ConstructorsConstructorDescriptionGeminiAPI(ChatConfig config) Constructs a new GeminiAPI instance and loads API keys from the configuration. -
Method Summary
Modifier and TypeMethodDescriptionGets the list of all available model IDs.com.google.genai.ClientGets a newClientinstance using the next available API key in the pool.Gets the currently selected model ID.voidsetModelId(String modelId) Sets the model ID to be used for subsequent requests.
-
Constructor Details
-
GeminiAPI
Constructs a new GeminiAPI instance and loads API keys from the configuration.- Parameters:
config- The chat configuration.
-
-
Method Details
-
getClient
public com.google.genai.Client getClient()Gets a newClientinstance using the next available API key in the pool.- Returns:
- A configured Gemini Client.
- Throws:
IllegalStateException- if no API keys are available.
-
getModelId
-
setModelId
Sets the model ID to be used for subsequent requests.- Parameters:
modelId- The new model ID.
-
getAvailableModelIds
-
