diff --git a/src/Instrumentation/OpenAIPHP/src/OpenAIPHPInstrumentation.php b/src/Instrumentation/OpenAIPHP/src/OpenAIPHPInstrumentation.php index 8be64d0db..8511a583f 100644 --- a/src/Instrumentation/OpenAIPHP/src/OpenAIPHPInstrumentation.php +++ b/src/Instrumentation/OpenAIPHP/src/OpenAIPHPInstrumentation.php @@ -193,7 +193,7 @@ private static function hookApi(CachedInstrumentation $instrumentation, $class, private static function recordUsage(SpanInterface $span, object $response, ContextInterface $context) { - if (!property_exists($response, 'usage') || !method_exists($response->usage, 'toArray')) { + if (!property_exists($response, 'usage') || !isset($response->usage) || !method_exists($response->usage, 'toArray')) { return; }