Skip to content
This documentation covers the kagent 1.0 alpha. For the latest 0.x release, see the 0.x docs.

For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.

Gemini

Page as Markdown

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

  1. Get an API key from Google AI Studio, and save it as an environment variable.

    export GOOGLE_API_KEY=<your_api_key>
  2. 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_KEY
  3. Create a ModelConfig that 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: {}
    EOF
    FieldDescription
    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.

FieldDescription
maxOutputTokensA 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

Next steps