Skip to content

Configure the Comet LLM SDK

When getting started with logging your prompt engineering workflows to CometLLM, you need to make sure to provide your Comet API key and also define the correct Comet LLM project settings. Both these goals are achieved by initializing the Comet SDK.

This page presents you with instructions on how to best initialize the Comet SDK, and an overview of all configuration parameters for initialization.

Set the API key

The recommended way to set the API key is by running comet_llm.init() in your Python code without setting the API key beforehand:

import comet_llm


When no API key is set in the environment, the .init() method interactively prompts you for your API key and stores it for you in the .comet.config configuration file. Once available, Comet directly accesses your API key from configuration file so you only need to input your API key once.


You can also set the API key using one of the methods introduced in the Configure CometLLM logging section below.

Note that it is not recommended to pass the API key as an .init() method argument because it is not safe to hardcode its value.

Configure CometLLM logging

Below we provide instructions and an example for each of the three different ways in which you can configure the comet_llm Python SDK.

The provided examples all use the project_name configuration parameter. For a comprehensive list of Comet configuration names—for both the config file and environment variables—, please refer to the Explore Comet LLM configuration options section below.


Comet prioritizes setting configuration options in the following order:

  1. From .init() method arguments.
  2. With Comet environment variables.
  3. From the .comet.config file in your current folder.
  4. From the .comet.config file in your HOME directory.

So, a configuration parameter explicitly passed to code has top priority.

From the .comet.config file

The .comet.config configuration file follows the format:


You can update directly the configuration file by adding each configuration option under the right section name. For example:


With Comet environment variables

You can use environment variables to define Comet LLM configuration parameter.

Define them from terminal with your desired scope as follows:

export $COMET_PROJECT_NAME="llm-example"

1. Open one of .bashrc, .bash_profile, or .profile configuration files depending on your set-up.

2. Add the following line to the file:

export COMET_PROJECT_NAME="llm-example"

3. Save and execute the file, e.g. with source ~/.bashrc.

For more information and instructions, read more about setting environment variables in Python.

From .init() method arguments

You can pass a subset of the configuration parameters as .init() method arguments. For example:

import comet_llm

project_name = "llm-example"

Please refer to the comet_llm.init() reference for a complete list of supported arguments.

Explore Comet LLM configuration options

The table below outlines all the available configuration environment variables for Comet LLM and their corresponding section<>attribute names in the .comet.config file.

Comet Config Section<>NameEnvironment VariableDescription
COMET_API_KEYThe API key used for logging data and using the Python API.
COMET_WORKSPACEUse this workspace when logging data.
COMET_PROJECT_NAMEUse this project when logging data.
COMET_URL_OVERRIDEURL to upload data to, this needs to be updated for on-premise deployments. Defaults to

In addition, the following configuration parameters are available only as environment variables:

Environment VariableDescription
COMET_INIA path to another .comet.config file to take into account


If configuration options are not explicitly set, Comet uses default values. Specifically, the default workspace corresponds to your username and the default project_name corresponds to "llm-general".

May. 17, 2024