mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-16 09:22:22 +00:00
A streamed /v1/chat/completions or /v1/completions request that a post_call guardrail cut mid-stream wrote its failure spend row with 0 tokens and $0, while the same block at the end of the stream billed the provider's usage. When the proxy cuts a stream before the deferred success dispatch was parked, both the iterator hook and the per-chunk hook now rebuild the usage and cost from the chunks already streamed (the provider's usage chunk when it arrived, else a token count) before the failure row is written. /v1/completions on a chat model reaches the inner stream through TextCompletionStreamWrapper.source_stream |
||
|---|---|---|
| .. | ||
| helpers | ||
| prisma_and_spend | ||
| proxy_logging | ||
| __init__.py | ||