Skip to main content

Using Agenta from CLI

Agenta was designed for use both from the CLI and from the web interface. This guide explains the basics of using Agenta from the CLI. For more details, refer to the CLI developer guide.

Installation

The agenta CLI can be easily installed through pip:

pip install -U agenta

Creating an application

  1. Create a new project

To create an application in Agenta, first, initialize an empty project. Run the following command in the folder containing your application code:

agenta init

This will prompt you for the project name, the Agenta host, and the API key (if using the cloud or enterprise version).

Running agenta init creates a blank project in Agenta and generates a config.toml file in that folder, which contains all the information about your project.

  1. Serve the first app variant With the project created, we need to add the first app variant to it. This can be done by running the following command: bash agenta variant serve <filename.py>

This will create a new app variant in Agenta under the name filename.default. Here, filename is the name of the codebase containing the app logic, while default is a default configuration created for that codebase. Each new app variant created from the web interface or from the CLI will always have the name format <codebase_name>.<configuration_name>.

Running this comand will create a container for the application with a REST API endpoint. This endpoint is what is used by the agenta web interface to communicate with the application.

The CLI will also display the URL of the endpoint, which can be used to test the application.

Adding a multiple variants for one application

You can add multiple app variants to a single application using the CLI. This is useful if you want to test different workflows for the same application (i.e. single prompt vs. chain of prompts). To do this, create a new python file containing the new logic, then execute the following command:

agenta variant serve <new_filename.py>

In the UI, you'll find the new variant under the same application, labeled <new_filename>.default. You can modify the configuration for this variant in the playground and create numerous variants based on it.