Summary
instructor is the de facto Python library for structured output extraction from LLMs, with 3M+ monthly PyPI downloads and 10K+ GitHub stars. It wraps provider clients (OpenAI, Anthropic, Google, Cohere, Mistral, Groq, Together, and 10+ others) to return validated Pydantic models. This repository has zero native instrumentation for the instructor execution surface — no integration directory, no wrap_instructor() function, no patcher, no auto_instrument() support.
Braintrust currently documents a manual workaround: instructor.patch(wrap_openai(OpenAI())). This approach is:
- OpenAI-only — users of
instructor.from_anthropic(), instructor.from_cohere(), instructor.from_google_generativeai(), instructor.from_mistral(), and 10+ other provider backends get zero Braintrust tracing.
- Layer-blind — the Instructor retry loop, validation failures, and response_model metadata are never captured as span attributes. Users see only the raw provider LLM call, not the structured extraction context.
What needs to be instrumented
The instructor package (v1.15.1) exposes these execution surfaces, none of which have native instrumentation:
Primary execution API
| Method |
Description |
client.chat.completions.create(response_model=..., ...) |
Patched create() — the core structured output call with Pydantic validation and retry logic |
client.chat.completions.create_with_completion(response_model=..., ...) |
Returns both the extracted model and raw completion |
client.chat.completions.create_partial(response_model=..., ...) |
Streams partial Pydantic objects progressively |
client.chat.completions.create_iterable(response_model=..., ...) |
Streams multiple Pydantic objects sequentially |
All methods have async variants via AsyncInstructor clients.
Initialization surfaces (15+ providers)
| Function |
Backend |
instructor.from_openai(client) |
OpenAI |
instructor.from_anthropic(client) |
Anthropic |
instructor.from_cohere(client) |
Cohere |
instructor.from_google_generativeai(client) |
Google GenAI |
instructor.from_mistral(client) |
Mistral |
instructor.from_groq(client) |
Groq |
instructor.from_together(client) |
Together AI |
instructor.from_litellm(client) |
LiteLLM |
instructor.from_provider("openai/gpt-4o") |
Unified provider string API |
Instructor-specific span attributes not captured by existing integrations
Even when the underlying provider is already instrumented (e.g., OpenAI), Instructor adds unique context that is not captured:
response_model — the Pydantic class being extracted (type name and schema)
max_retries — configured retry limit
retry_count — actual number of retries performed (validation failures)
validation_errors — Pydantic validation errors from failed attempts
mode — Instructor mode (e.g., TOOLS, JSON, MD_JSON, FUNCTIONS)
A user who makes 3 LLM calls due to validation failures currently sees 3 raw provider spans with no shared Instructor context. A native integration would create a parent Instructor span wrapping all retries.
No coverage in any instrumentation layer
- No integration directory (
py/src/braintrust/integrations/instructor/)
- No wrapper function (e.g.
wrap_instructor())
- No patcher in any existing integration
- No nox test session (
test_instructor)
- No version entry in
py/src/braintrust/integrations/versioning.py
- No mention in
py/src/braintrust/integrations/__init__.py
A grep for instructor (case-insensitive) across py/src/braintrust/integrations/ returns zero matches in integration code.
Braintrust docs status
unclear — The Braintrust integrations directory lists Instructor as a supported SDK integration. The Instructor-specific docs page describes a manual wrap_openai() workaround for OpenAI-backed Instructor only. No auto_instrument() support is documented, and non-OpenAI provider backends (Anthropic, Google, Cohere, Mistral, etc.) are not mentioned.
Upstream references
Local repo files inspected
py/src/braintrust/integrations/ — no instructor/ directory exists on main
py/src/braintrust/wrappers/ — no Instructor wrapper
py/noxfile.py — no test_instructor session
py/src/braintrust/integrations/__init__.py — Instructor not listed in integration registry
py/src/braintrust/integrations/versioning.py — no Instructor version matrix
py/pyproject.toml — no Instructor entries in [tool.braintrust.matrix]
- Full repo grep for
instructor (case-insensitive) across py/src/braintrust/integrations/ — zero matches
Summary
instructoris the de facto Python library for structured output extraction from LLMs, with 3M+ monthly PyPI downloads and 10K+ GitHub stars. It wraps provider clients (OpenAI, Anthropic, Google, Cohere, Mistral, Groq, Together, and 10+ others) to return validated Pydantic models. This repository has zero native instrumentation for theinstructorexecution surface — no integration directory, nowrap_instructor()function, no patcher, noauto_instrument()support.Braintrust currently documents a manual workaround:
instructor.patch(wrap_openai(OpenAI())). This approach is:instructor.from_anthropic(),instructor.from_cohere(),instructor.from_google_generativeai(),instructor.from_mistral(), and 10+ other provider backends get zero Braintrust tracing.What needs to be instrumented
The
instructorpackage (v1.15.1) exposes these execution surfaces, none of which have native instrumentation:Primary execution API
client.chat.completions.create(response_model=..., ...)create()— the core structured output call with Pydantic validation and retry logicclient.chat.completions.create_with_completion(response_model=..., ...)client.chat.completions.create_partial(response_model=..., ...)client.chat.completions.create_iterable(response_model=..., ...)All methods have async variants via
AsyncInstructorclients.Initialization surfaces (15+ providers)
instructor.from_openai(client)instructor.from_anthropic(client)instructor.from_cohere(client)instructor.from_google_generativeai(client)instructor.from_mistral(client)instructor.from_groq(client)instructor.from_together(client)instructor.from_litellm(client)instructor.from_provider("openai/gpt-4o")Instructor-specific span attributes not captured by existing integrations
Even when the underlying provider is already instrumented (e.g., OpenAI), Instructor adds unique context that is not captured:
response_model— the Pydantic class being extracted (type name and schema)max_retries— configured retry limitretry_count— actual number of retries performed (validation failures)validation_errors— Pydantic validation errors from failed attemptsmode— Instructor mode (e.g.,TOOLS,JSON,MD_JSON,FUNCTIONS)A user who makes 3 LLM calls due to validation failures currently sees 3 raw provider spans with no shared Instructor context. A native integration would create a parent Instructor span wrapping all retries.
No coverage in any instrumentation layer
py/src/braintrust/integrations/instructor/)wrap_instructor())test_instructor)py/src/braintrust/integrations/versioning.pypy/src/braintrust/integrations/__init__.pyA grep for
instructor(case-insensitive) acrosspy/src/braintrust/integrations/returns zero matches in integration code.Braintrust docs status
unclear— The Braintrust integrations directory lists Instructor as a supported SDK integration. The Instructor-specific docs page describes a manualwrap_openai()workaround for OpenAI-backed Instructor only. Noauto_instrument()support is documented, and non-OpenAI provider backends (Anthropic, Google, Cohere, Mistral, etc.) are not mentioned.Upstream references
Local repo files inspected
py/src/braintrust/integrations/— noinstructor/directory exists onmainpy/src/braintrust/wrappers/— no Instructor wrapperpy/noxfile.py— notest_instructorsessionpy/src/braintrust/integrations/__init__.py— Instructor not listed in integration registrypy/src/braintrust/integrations/versioning.py— no Instructor version matrixpy/pyproject.toml— no Instructor entries in[tool.braintrust.matrix]instructor(case-insensitive) acrosspy/src/braintrust/integrations/— zero matches