With HoneyHive, we allow users to get visibility into their AI pipelines by tracing:

  1. Model inference calls as model events
  2. External API calls (like retrieval) as tool events
  3. Groups of inference & external API calls as chain events
  4. An entire trace of requests as a session

Logging a Trace

We use OpenTelemetry to automatically instrument your AI application.

You can find the full list of supported packages here.

Prerequisites

  • You have already created a project in HoneyHive, as explained here.
  • You have an API key for your project, as explained here.

Expected Time: 5 minutes

Steps

1

Installation

To install our SDKs, run the following commands in the shell.

pip install honeyhive
2

Authenticate the SDK & initialize the tracer

Initializing the HoneyHiveTracer marks the beginning of your session and allows you to begin tracing your program. To initialize, pass the following parameters:

  • api_key: Get your API key from HoneyHive Account Settings.
  • project: Create a project from HoneyHive Projects.
  • (optional) source: The source of the trace, e.g. “prod”, “dev”, etc. Defaults to “dev”.
  • (optional) session_name: The name of the session, defaults to the main module name.

If you are using a self-hosted or dedicated deployment, you also need to pass:

  • server_url: The private HoneyHive endpoint found in the Settings page in the HoneyHive app.
from honeyhive import HoneyHiveTracer

# Add this code at the beginning of your AI pipeline code
HoneyHiveTracer.init(
    api_key=MY_HONEYHIVE_API_KEY,
    project=MY_HONEYHIVE_PROJECT_NAME,
    source=MY_SOURCE, # Optional
    session_name=MY_SESSION_NAME, # Optional
    server_url=MY_HONEYHIVE_SERVER_URL # Optional / Required for self-hosted or dedicated deployments
)

# Your LLM and vector database calls will now be automatically instrumented
# Run HoneyHiveTracer.init() again to end the current session and start a new one
3

Trace any custom spans using function decorators

The above initialization will auto-capture all interactions with our supported providers.

To capture anything else, you can trace any function in your code and see its inputs, outputs, errors, duration, etc. by decorating it as follows.

The following method isn’t compatible with the LangChain callback handlers.
from honeyhive import trace

@trace
def my_function(param1, param2):
    # Code here
    return result

View the trace

Now that you have successfully traced your session, you can review it in the platform.

  1. Navigate to the project in the platform via the projects page or the dropdown in the Header.
  2. Follow these steps after

Learn more