Example: OpenAI Instrumentation
This guide demonstrates how to use TrueFoundry OtelCollector along with the Traceloop SDK to instrument OpenAI API calls.
Install Dependencies
First, you need to install the following
Setup environment variables
To enable tracing, you’ll need to configure a few environment variables in your application.
Before proceeding, make sure you’ve, Created a tracing project and Generated an API token. If you haven’t done this yet, follow the instructions in Getting Started.
Replace the placeholders above:
<<control-plane-url>>
: Your actual TrueFoundry control plane URL<<api-key>>
: The API key associated with your tracing project<<tracing-project-fqn>>
: The fully qualified name of your tracing project
Initialise instrumentation
OpenAI code
Below is an example of a OpenAI code setup. With the Traceloop SDK initialized as shown above, all agent activities will be automatically traced—no additional tracing code is required.
Run your application and view logged trace