Skip to content

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

Add a model

Page as Markdown

Add a model from a second provider in the kagent UI, and run an agent on it beside your default model.

Add a model

Add a model from a second provider in the kagent UI, and run an agent on it beside your default model.

Use case: your team wants to run an agent on a different provider, or to compare two models on the same task.

An agent reaches its model through a model configuration, which names a provider, a model, and where the API key is stored. The installation created one, default-model-config, from the API key that you set. In this tutorial, you add a second configuration for another provider in the kagent UI, and create an agent that uses it. Your other agents keep the model that they have.

This tutorial stands on its own. You do not need any of the projects to follow it.

Before you begin

  1. Install kagent.
  2. Have an API key for the provider that you want to add. This tutorial uses Anthropic.
  3. Open the kagent UI with kagent dashboard.

Add the model

The kagent UI adding an Anthropic model configuration and listing it on the Models page
Figure: Adding an Anthropic model configuration, sped up
  1. In the sidebar, click Models, and then click New Model.

  2. From the Provider list, choose a provider, such as Anthropic.

  3. From the Model list, choose a model, such as claude-sonnet-5-5. To use a model that is not listed, type its name.

  4. Leave Name empty to name the configuration after the model, and leave Namespace as kagent.

  5. Under Authentication, leave API key selected, and enter your API key. kagent stores the key in a Kubernetes Secret that the controller creates.

  6. Click Create model. The Models page lists the new configuration with its provider, its model, and the Secret that holds the key.

Run an agent on the new model

Create an agent that uses the new configuration, so that you can try the model without changing the agents that you already have.

  1. In the sidebar, click Agents, and then click New Agent.

  2. In the Name field, enter second-opinion.

  3. In the Template section, select Inline, and fill in the template.

    FieldValue
    Model configurationThe configuration that you created, such as kagent/claude-sonnet-5-5.
    DescriptionAnswers on a second model
    System promptYou are a concise, helpful assistant.
  4. Click Create agent, and then click Refresh until the agent is Ready.

To compare the two models, send the same message to this agent and to an agent that uses default-model-config.

To move an existing agent to the new model instead, open the agent’s edit form, choose the configuration from the Model configuration list, and click Save agent.

YAML version

Everything that you did in the UI is stored as Kubernetes resources. To create the same resources from the command line, or to keep them in a Git repository, apply this YAML. In the UI, kagent creates the Secret for you. From the command line, you create it yourself.

The Secret with the API key, and the model configuration
kubectl apply -f - <<EOF
apiVersion: v1
kind: Secret
metadata:
  name: claude-sonnet-5-5
  namespace: kagent
stringData:
  ANTHROPIC_API_KEY: your-api-key-here
---
apiVersion: api.kagent.dev/v1alpha3
kind: ModelConfig
metadata:
  name: claude-sonnet-5-5
  namespace: kagent
spec:
  provider: Anthropic
  model: claude-sonnet-5-5
  apiKeySecret: claude-sonnet-5-5
  apiKeySecretKey: ANTHROPIC_API_KEY
  stream: true
EOF

Next steps