Skip to content
This documentation covers kagent while it is in development and can describe unreleased features. For the current release, see the latest docs.

Add a model

Page as Markdown

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

Add a model

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

About this tutorial

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 use cases to follow it. For the settings of each provider, see Configure models.

Time: about 10 minutes.

Before you begin

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

Add the model

Follow the steps in the kagent UI, or apply the same resources as YAML from the command line.

Open the kagent UI

kagent dashboard

The command forwards the UI to http://localhost:8082 and opens it in your browser. Leave it running while you work.

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.

Verify the model

  1. Check that the model configuration exists, with the provider and model that you chose. If you named it differently, use your name.

    kubectl get modelconfig claude-sonnet-5-5 -n kagent

    Example output:

    NAME                PROVIDER    MODEL
    claude-sonnet-5-5   Anthropic   claude-sonnet-5-5
    
  2. If you created the second-opinion agent in the kagent UI, check that it is ready.

    kubectl get agent second-opinion -n kagent

    Example output:

    NAME            READY   AGE
    second-opinion  True    2m
    
  3. Click the agent name to open its chat page, and send it a message. The agent answers from the new model.

What you built

A second model configuration, and an agent that runs on it while your other agents keep their model. Along the way, you used these features:

FeatureWhat you didRead more
Model configurationsAdded a ModelConfig for a second provider, with its API key in a SecretConfigure models
Agents and inline templatesPointed one agent at the new configurationAbout agents

Clean up

  1. Delete the agent, if you created it.

    kubectl delete agent second-opinion -n kagent
  2. Delete the model configuration. Before you delete it, note the name of its Secret on the Models page. The YAML tab names the Secret claude-sonnet-5-5.

    kubectl delete modelconfig claude-sonnet-5-5 -n kagent
  3. Delete the Secret that holds the API key.

    kubectl delete secret claude-sonnet-5-5 -n kagent

Next steps