Setting up OpenLIT SDK for Middleware (Python)

This guide will walk you through the process of setting up the OpenLIT SDK to work with Middleware for LLM Observability in a Python environment.

1. Install the SDK

Run the following command in your terminal:

2. Initialize the SDK

You can initialize the OpenLIT SDK using either function arguments or environment variables:

Setup using function arguments

In your LLM application, initialize the OpenLIT SDK:

Setup using Environment Variables

Set the following environment variables:

Then, in your Python code, simply call:

The SDK will automatically use the environment variables for configuration.

You can disable metrics collection by setting disable_metrics=True in the init function or by setting the OPENLIT_DISABLE_METRICS=true environment variable.

3. Use the SDK

Here's an example of how to use OpenLIT to monitor OpenAI usage:

Viewing Your Traces and Metrics

After setting up the Traceloop SDK with Middleware, you'll be able to view your LLM application traces in your Middleware LLM Observability Section.

This integration provides instant visibility into everything happening within your LLM, including performance metrics and usage patterns.

For more advanced configurations and use cases, please refer to the OpenLIT Python SDK documentation.

Need assistance or want to learn more about using OpenLIT with Middleware? Refer to the OpenLIT documentation or contact our support team in Slack.