Skip to content

Commit 81b58cd

Browse files
authored
fix(openai): parse usage details from response API response chunk (#1525)
1 parent ab18ba1 commit 81b58cd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

langfuse/openai.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,8 @@ def _extract_streamed_response_api_response(chunks: Any) -> Any:
591591
for raw_chunk in chunks:
592592
chunk = raw_chunk.__dict__
593593
if raw_response := chunk.get("response", None):
594-
usage = chunk.get("usage", None)
594+
usage = chunk.get("usage", None) or getattr(raw_response, "usage", None)
595+
595596
response = raw_response.__dict__
596597
model = response.get("model")
597598

0 commit comments

Comments
 (0)