mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-25 22:20:43 +00:00
* fix(responses): bill the provider-reported input on a cut bridged stream A /v1/responses stream that runs through the chat bridge and is cut mid-answer now bills the input and cache counts the provider sent before the cut, and the spend row carries the 499 ClientDisconnected marker that /v1/responses reads from litellm_metadata * fix(responses): bill cut Claude streams on relayed providers and build the partial off the event loop * fix(responses): log the cost of the provider-reported usage on a cut stream The cut partial took its usage from the rebuild over every kept chunk but kept the response_cost the first build stamped from the estimate, and the logger uses a stamped cost before it prices the usage. The partial now carries the rebuild's cost along with its usage. * fix(responses): drop the message_start placeholder on every stream Anthropic's parser reads Anthropic's stream parser marks its message_start chunk, and the placeholder reset reads that mark instead of a provider list plus a Claude model name. Bedrock application inference profile ARNs and OpenCode Go's non-Claude models stream Anthropic's events too, and kept the 1-token output placeholder on a cut stream before. * fix(responses): bill a stream cut before its first relayed chunk A client that drops a bridged /v1/responses stream after the provider's first usage event but before any text logged no spend row, since the partial response was built only from relayed chunks. The partial now falls back to the chunks the stream wrapper kept, so the row bills the provider's input and cache counts with no output text * fix(responses): bill a cut background cancel or fallback once A cancelled background response whose stream teardown had already billed the cut also logged a second, failed 499 row. The background task now skips its own failure log once the teardown billed. A client cut after a mid-stream fallback billed both deployments' tokens at the fallback's price with no cache split, and now sums both partials' tokens, cache counts and cost the way MCP rounds are billed * fix(responses): charge the fixed cost margin once on a cut fallback stream Each deployment's partial price already includes the fixed fee from cost_margin_config, so adding the first deployment's price to the fallback's charged that fee twice. The sum now takes off one fee, and the logged cost breakdown matches the billed total * test: annotate the new disconnect test bindings as Final * fix(router): bill a cut fallback's first deployment at its own price A client cut after a mid-stream fallback now prices the first deployment's partial when the fallback starts, before the fallback changes the shared logging object's model, so its tokens keep their own price. An unpriced deployment bills nothing and keeps the other side's cost breakdown. The fixed fee is charged once at the final round's amount, and a fallback that fails after the cut leaves no breakdown from the first deployment's partial. * fix(router): bill the first deployment at its own price when a client cuts while the fallback connects * fix(router): report a cut fallback's billed cost as its usage cost --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| litellm_completion_transformation | ||
| mcp | ||
| __init__.py | ||
| test_additional_tools.py | ||
| test_custom_tool_call.py | ||
| test_input_items_query.py | ||
| test_instructions_length.py | ||
| test_metadata_codex_callback.py | ||
| test_no_duplicate_spend_logs.py | ||
| test_null_test_fix.py | ||
| test_responses_api_bridge_flag.py | ||
| test_responses_api_lifecycle.py | ||
| test_responses_api_request_body.py | ||
| test_responses_prompt_management.py | ||
| test_responses_router_cooldown.py | ||
| test_responses_streaming_iterator.py | ||
| test_responses_supported_endpoints_passthrough.py | ||
| test_responses_utils.py | ||
| test_responses_websocket_all_providers.py | ||
| test_rust_bridge_websocket.py | ||
| test_sse_output_recovery.py | ||
| test_streaming_iterator.py | ||
| test_streaming_iterator_error_events.py | ||
| test_text_format_conversion.py | ||