Instructor is a Python library for generating structured outputs from LLMs using Pydantic models. Braintrust integrates with Instructor to trace structured output generation.Documentation Index
Fetch the complete documentation index at: https://braintrust.dev/docs/llms.txt
Use this file to discover all available pages before exploring further.
Setup
Install Instructor alongside the Braintrust SDK and OpenAI client:Trace with Instructor
When using Instructor with Braintrust, wrap the OpenAI client withwrap_openai before patching with Instructor. This ensures Braintrust captures the low-level metrics and headers from OpenAI.
trace-instructor.py
The order matters:
instructor.patch(wrap_openai(OpenAI())) ensures Braintrust captures complete metrics.