Debug Mode & Environment Variables

Opik uses environment variables to configure its behavior. These variables can be set in your shell or in a .env file.

Debug Mode

To enable debug mode, you can set the following environment variables:

$export OPIK_FILE_LOGGING_LEVEL="DEBUG"
>export OPIK_LOGGING_FILE=".tmp/opik-debug-$(date +%Y%m%d).log"

It is important to set these environment variables before you import opik in your Python scripts.

Using a .env file

You can also use a .env file to manage your environment variables. This is a good practice to avoid hardcoding secrets and to make your configuration more portable. You can use the python-dotenv library to load the variables from the .env file.

First, install python-dotenv:

$pip install python-dotenv

Then, create a .env file in your project’s root directory with the following content:

1# Opik Configuration
2OPIK_API_KEY="YOUR_OPIK_API_KEY"
3
4# LLM Provider API Keys
5LLMPROVIDER_API_KEY="YOUR_LLMPROVIDER_API_KEY"
6
7# Debug Mode
8OPIK_FILE_LOGGING_LEVEL="DEBUG"
9OPIK_LOGGING_FILE=".tmp/opik-debug.log"

Finally, in your Python script, load the environment variables from the .env file before importing opik:

1from dotenv import load_dotenv
2
3load_dotenv()
4
5import opik
6
7# Your Opik code here