Observability for OpenAI (TypeScript) with Opik
Observability for OpenAI (TypeScript) with Opik
Observability for OpenAI (TypeScript) with Opik
Opik provides seamless integration with the official OpenAI Node.js SDK through the opik-openai package, allowing you to trace, monitor, and debug your OpenAI API calls.
openai ≥ 6.0.1)opik peer dependency)To trace your OpenAI API calls, you need to wrap your OpenAI client instance with the trackOpenAI function:
The integration fully supports OpenAI’s streaming responses:
The trackOpenAI function accepts an optional configuration object to customize the integration:
Missing Traces: Ensure your OpenAI and Opik API keys are correct and that you’re calling await trackedOpenAI.flush() before your application exits.
Incomplete Data: For streaming responses, make sure you’re consuming the entire stream before ending your application.
Hierarchical Traces: To create proper parent-child relationships, use the parent option in the configuration when you want OpenAI calls to be children of another trace.
Performance Impact: The Opik integration adds minimal overhead to your OpenAI API calls.