MEDIUM SEVERITYCONFIRMED

getattr(dict, "ended") always returns time.time() — dict key ignored

Package
litellm
Version
1.82.6
Verified
2026-03-28

Description

litellm uses `getattr(completion_response, 'ended', time.time())` where `completion_response` is a plain dict. `getattr` on a dict does not access dict keys — it only accesses object attributes. The `ended` key is always ignored, returning the current wall-clock time instead of the stored value.

Reproduction

import time
completion_response = {'created': 1000.0, 'ended': 1005.0}
end_time = getattr(completion_response, 'ended', time.time())
# Returns time.time() (~1774692895), NOT 1005.0
# total_time = ~1774691895s instead of 5s
← All bugsScan your code →