{"id":24161,"library":"openinference-instrumentation-instructor","title":"OpenInference Instructor Instrumentation","description":"OpenTelemetry instrumentation for the instructor library (Python), enabling tracing of LLM calls and structured extraction for observability with Phoenix and other OpenInference-compatible backends. Current version: 0.1.14. Release cadence: irregular, part of the openinference monorepo.","status":"active","version":"0.1.14","language":"python","source_language":"en","source_url":"https://github.com/Arize-ai/openinference/tree/main/python/instrumentation/openinference-instrumentation-instructor","tags":["openinference","instructor","opentelemetry","llm","observability","tracing"],"install":[{"cmd":"pip install openinference-instrumentation-instructor","lang":"bash","label":"Latest stable"}],"dependencies":[{"reason":"Instruments the instructor library","package":"instructor","optional":false},{"reason":"Core OpenInference instrumentation package","package":"openinference-instrumentation","optional":true}],"imports":[{"note":"Incorrect import path with hyphens in module name; use dots.","wrong":"from openinference_instrumentation_instructor import InstructorInstrumentor","symbol":"InstructorInstrumentor","correct":"from openinference.instrumentation.instructor import InstructorInstrumentor"}],"quickstart":{"code":"import instructor\nfrom openinference.instrumentation.instructor import InstructorInstrumentor\n\n# Instrument before using instructor\nInstructorInstrumentor().instrument()\n\n# Now use instructor normally\nclient = instructor.from_openai(openai.OpenAI(api_key=os.environ.get('OPENAI_API_KEY', '')))\n# Example: extract structured data\nimport pydantic\nclass User(pydantic.BaseModel):\n    name: str\n    age: int\nuser = client.chat.completions.create(model=\"gpt-4o\", response_model=User, messages=[{\"role\": \"user\", \"content\": \"John Doe is 30\"}])\nprint(user.name, user.age)","lang":"python","description":"Instrument instructor to trace LLM calls and structured extraction. Ensure instructor and openai are installed."},"warnings":[{"fix":"Use: from openinference.instrumentation.instructor import InstructorInstrumentor","message":"The import path uses dots, not hyphens: 'openinference.instrumentation.instructor' not 'openinference_instrumentation_instructor'. Hyphenated package name on PyPI maps to underscore in import but correct is dotted.","severity":"gotcha","affected_versions":"all"},{"fix":"Call InstructorInstrumentor().instrument() at the top of your application, before importing or creating instructor clients.","message":"Instrumentation must be called before any instructor client usage. If you instrument after creating a client, spans will not be captured.","severity":"gotcha","affected_versions":"all"},{"fix":"Update import: from openinference.instrumentation.instructor import InstructorInstrumentor","message":"Breaking change when upgrading from openinference-instrumentation-instructor <0.1.0: The module name changed from openinference_instrumentation_instructor to openinference.instrumentation.instructor.","severity":"breaking","affected_versions":"<0.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use: from openinference.instrumentation.instructor import InstructorInstrumentor","cause":"Using hyphens in module path (incorrect import path).","error":"ImportError: cannot import name 'InstructorInstrumentor' from 'openinference_instrumentation_instructor'"},{"fix":"Install: pip install openinference-instrumentation-instructor. Then import: from openinference.instrumentation.instructor import InstructorInstrumentor","cause":"Package not installed or using incorrect import name (should be dotted).","error":"ModuleNotFoundError: No module named 'openinference_instrumentation_instructor'"},{"fix":"Call InstructorInstrumentor().instrument() before any instructor usage, and configure an OTLP exporter (e.g., phoenix).","cause":"Instrumentation was called after creating the instructor client, or the OpenTelemetry exporter not configured.","error":"Opentelemetry span not created for instructor calls"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}