For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
Gemini
Configure kagent to use Google Gemini models through the Google AI Studio API.
The Gemini provider reaches Google’s Gemini models through the Google AI Studio API, authenticating with a single API key. To reach Gemini through Google Cloud instead, see Google Vertex AI.
Before you begin
Make sure that your Google Cloud account has a project with the Gemini API enabled.
Create the ModelConfig
Get an API key from Google AI Studio, and save it as an environment variable.
export GOOGLE_API_KEY=<your_api_key>Create a Kubernetes Secret that stores the API key. Create it in the same namespace as the AgentTemplates that use it, such as
kagent.kubectl create secret generic kagent-gemini -n kagent --from-literal GOOGLE_API_KEY=$GOOGLE_API_KEYCreate a
ModelConfigthat references the Secret.kubectl apply -f - <<EOF apiVersion: kagent.dev/v1alpha3 kind: ModelConfig metadata: name: gemini-model-config namespace: kagent spec: apiKeySecret: kagent-gemini apiKeySecretKey: GOOGLE_API_KEY model: gemini-2.5-flash provider: Gemini gemini: {} EOFField Description apiKeySecretThe name of the Kubernetes Secret that stores the API key, in the same namespace as this ModelConfig. apiKeySecretKeyThe key within that Secret that holds the API key. modelThe model to use. For the available models, see the Gemini API docs. providerThe provider to use, Gemini.geminiSettings that only the Gemini provider takes. An empty block is valid.
Gemini provider settings
The gemini block takes one optional setting. For its type, default, and validation rules, see the API reference.
| Field | Description |
|---|---|
maxOutputTokens | A cap on the tokens generated in one response. |
Use the ModelConfig
Reference the ModelConfig by name from an AgentTemplate in the same namespace.
spec:
modelConfig:
name: gemini-model-config