Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

fix(python-sdk): instrument Responses.parse in openai instrumentor (#1383)

silvercondora19c9dd574d4
diff --git a/sdk/python/src/openlit/instrumentation/openai/__init__.py b/sdk/python/src/openlit/instrumentation/openai/__init__.py
index 90ddfbf1..1405df4a 100644
--- a/sdk/python/src/openlit/instrumentation/openai/__init__.py
+++ b/sdk/python/src/openlit/instrumentation/openai/__init__.py
@@ -217,6 +217,22 @@ class OpenAIInstrumentor(BaseInstrumentor):
async_responses(*sa),
)
+ # responses parse (may not exist in older SDK versions).
+ # parse() posts to /responses directly instead of delegating to
+ # create(), so it needs its own wrapper. ParsedResponse subclasses
+ # Response and parse() never streams, so the create wrapper's
+ # non-streaming path handles it unchanged.
+ _safe_wrap(
+ "openai.resources.responses.responses",
+ "Responses.parse",
+ responses(*sa),
+ )
+ _safe_wrap(
+ "openai.resources.responses.responses",
+ "AsyncResponses.parse",
+ async_responses(*sa),
+ )
+
# responses retrieve (may not exist in older SDK versions)
_safe_wrap(
"openai.resources.responses.responses",