The Galileo SDKs provide a comprehensive set of tools for logging, evaluating, and experimenting with LLM applications. Regardless of how you go about logging your AI application, you will still need to install the Galileo SDK and initialize your API keys by following the steps below.

Installation

pip install galileo

If you want to use the OpenAI wrapper in Python, you need to install with the optional OpenAI dependencies.

pip install "galileo[openai]"

Initialization and Authentication

You need a Galileo API key set as an environment variable called GALILEO_API_KEY. The Galileo SDK will automatically pick this up from the environment variable at run time.

You can also optionally set the following environment variables to define the project, log stream, and console URL that Galileo should use.

Environment variableDescription
GALILEO_PROJECTThe Galileo project to log to. If this is not set, you will need to pass the project name in code.
GALILEO_LOG_STREAMThe default log stream to log to. If this is not set, you will need to pass the log stream name in code.
GALILEO_CONSOLE_URLFor custom Galileo deployments only, set this to the URL of your Galileo console to log to. If this is not set, it will default to the hosted Galileo version at app.galileo.ai.

If you are using the free version of Galileo, there is no need to set the GALILEO_CONSOLE_URL environment variable.

When developing your application, you should use a .env file. Create or update a .env file with the following values as required:

# Scoped to an Organization
GALILEO_API_KEY=...

# Optional, set a default Project
GALILEO_PROJECT=...

# Optional, set a default Log Stream
GALILEO_LOG_STREAM=...

# (Optional) set the url for your custom Galileo deployment
# This is only for custom deployments of Galileo, and should
# not be set if you are using the free version
GALILEO_CONSOLE_URL=...

You can then load the environment variables from this file:

from dotenv import load_dotenv
load_dotenv()

For Python, you will need to install python-dotenv if you haven’t already.

pip install python-dotenv
The SDK automatically targets the hosted Galileo console. If you are using a deployment of Galileo on premises or in the cloud, point GALILEO_CONSOLE_URL to your own installation.

Logging

The Galileo SDKs allow you to log all prompts, responses, and statistics around your LLM usage. There are three main ways to log your application:

  1. Use a third-party integration - use wrappers that integrate with common SDKs to automatically log LLM calls or agentic workflows.
  2. Use a decorator - by decorating a function that calls an LLM with the @log decorator or log wrapper, the Galileo SDK logs all AI prompts within.
  3. Directly using the GalileoLogger class - For more control over your logging, you can use the GalileoLogger directly. This allows you to manually create sessions, start traces, and log spans. This can be mixed with the other methods, for example accessing the logger directly inside a decorated function call to manually add spans.

Log Experiments

Experiments are logged automatically when they are run, but you can use these same SDK concepts inside the code being run by your experiment for greater control and additional logging. This allows you to not only create distinct experiments, such as in notebooks, but to also add experiments to your production application code.

See our run experiments with code documentation for more details.

Next Steps

Logging with the SDKs

How-to guides

SDK Reference