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.

Anthropic

Page as Markdown

Configure kagent to use Anthropic Claude models by creating a ModelConfig for the Anthropic provider.

The Anthropic provider calls the Anthropic API directly.

Note

This provider works on the kagent, byo, and claude runtimes, but not on codex. A claude Harness accepts no anthropic settings beyond baseUrl. For more information, see Agent harness. To reach Claude models through Google Cloud instead, see Google Vertex AI.

Create the ModelConfig

  1. Save your Anthropic API key as an environment variable.

    export ANTHROPIC_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-anthropic -n kagent --from-literal ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY
  3. Create a ModelConfig that references the Secret.

    kubectl apply -f - <<EOF
    apiVersion: kagent.dev/v1alpha3
    kind: ModelConfig
    metadata:
      name: anthropic-model-config
      namespace: kagent
    spec:
      apiKeySecret: kagent-anthropic
      apiKeySecretKey: ANTHROPIC_API_KEY
      model: claude-sonnet-4-20250514
      provider: Anthropic
      anthropic: {}
    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 Anthropic model docs.
    providerThe provider to use, Anthropic.
    anthropicSettings that only the Anthropic provider takes. An empty block is valid.

Anthropic provider settings

The anthropic block takes the following optional settings. For every field, including its type, default, and validation rules, see the API reference.

FieldDescription
baseUrlAn alternative API endpoint, for a proxy or a compatible service.
maxTokensA cap on the tokens generated in one response.
temperatureHow much randomness the model applies when it picks the next token.
topPThe nucleus sampling cutoff.
topKHow many candidate tokens to sample from.

Use the ModelConfig

Reference the ModelConfig by name from an AgentTemplate in the same namespace.

spec:
  modelConfig:
    name: anthropic-model-config

Next steps