For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
Anthropic
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
Save your Anthropic API key as an environment variable.
export ANTHROPIC_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-anthropic -n kagent --from-literal ANTHROPIC_API_KEY=$ANTHROPIC_API_KEYCreate a
ModelConfigthat 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: {} 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 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.
| Field | Description |
|---|---|
baseUrl | An alternative API endpoint, for a proxy or a compatible service. |
maxTokens | A cap on the tokens generated in one response. |
temperature | How much randomness the model applies when it picks the next token. |
topP | The nucleus sampling cutoff. |
topK | How 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