Using Opik with Pydantic AI
Opik integrates with Pydantic AI to provide a simple way to log your agent calls.
Creating an account on Comet.com
Comet provides a hosted version of the Opik platform, simply create an account and grab you API Key.
You can also run the Opik platform locally, see the installation guide for more information.
Setting up the logging
Pydantic AI uses the logfire library to log traces to Opik. Before logging our agent calls, we will configure the integration by installing the required libraries and setting the correct environment variables:
Now that everything is configured correctly, we can enable the logging:
Logging your first trace
Before we log our first trace, we are going to configure the environment and ensure the code runs in a Notebook
Note: This screenshot was taken for a more complex agent but you should see a very trace.