litellm/tests/test_litellm/proxy/utils
Yucheng He e7442c7232 fix(spend_tracking): re-key spend log rows a reused provider response id would drop
LiteLLM_SpendLogs.request_id is the provider's response id and the flush inserts with
skip_duplicates, so a self-hosted OpenAI-compatible server that answers every request
with the same completion id had every request after the first served and charged but
never logged. The flush now reads back, from the writer, the identity of the rows
create_many skipped and re-inserts the ones that belong to a different request keyed on
their own litellm_call_id, with the provider id kept in metadata.response_id. Rows the
flush already stored (a replay after a transport retry, under either key) and rows keyed
on a stored object's id (batch polls, file uploads, the zero-priced object reads) stay
skipped, and a read-back the database rejects leaves the rows skipped instead of
requeueing the flush.

request_id keeps meaning the id the caller was shown, so GET /spend/logs?request_id=
by response id, the Logs page search, and Responses API previous_response_id session
lookups behave as before.
2026-09-15 11:25:22 -07:00
..
helpers fix(db): carry DATABASE_SSLMODE/DATABASE_SSLROOTCERT into the assembled writer and reader URLs (#40815) 2026-09-12 02:14:39 +00:00
prisma_and_spend fix(spend_tracking): re-key spend log rows a reused provider response id would drop 2026-09-15 11:25:22 -07:00
proxy_logging fix(proxy): attribute gate-rejected requests to their endpoint in cache analytics (#40824) 2026-09-12 16:03:38 -07:00
__init__.py test(proxy/utils): pin bottom-of-file helper behavior (#29509) 2026-06-02 17:45:19 -07:00