litellm/tests/integration/cost_calculation
devin-ai-integration[bot] 91ae7d1b7d
fix(cost): bill Responses API image generation and usage reported web search as tool usage cost (#41877)
* fix(cost): bill Responses API image_generation_call tool usage

Price completed image_generation_call output items from tool_usage.image_gen token counts when present, otherwise per image from the quality and size on the item, with the image model taken from tools[].model (default gpt-image-1). Add the result into tool_usage_cost alongside web search and file search, and read tool_usage from the top level or usage.tool_usage. Squashed and rebased onto main

* style(cost): annotate read-only views and mark casts for the type discipline gate

* fix(cost): price Responses image tool from tools[].model only, no default model or provider

* refactor(cost): drop redundant status check, unread usage fields and unused output_type literal

* test(cost): integration case for Responses image_generation tool token billing

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-15 20:18:17 -07:00
..
bridge_cost_parity test(cost): cover custom deployment aliases, off-peak pricing, bridge usage shapes and duplicate spend rows (#46708) 2026-10-15 10:44:51 -07:00
cases fix(cost): bill Responses API image generation and usage reported web search as tool usage cost (#41877) 2026-10-15 20:18:17 -07:00
stream_parity test(cost): add BridgeCostParityTestCase with a gpt-6-sol /v1/messages to Responses pair (#46130) 2026-10-13 02:51:55 +00:00
assertions.py test(integration): assert the streamed usage.cost matches the spend row on every cost case (#46762) 2026-10-15 22:34:42 +00:00
catalog.py test(cost): cover custom deployment aliases, off-peak pricing, bridge usage shapes and duplicate spend rows (#46708) 2026-10-15 10:44:51 -07:00
conftest.py test(cost): cover custom deployment aliases, off-peak pricing, bridge usage shapes and duplicate spend rows (#46708) 2026-10-15 10:44:51 -07:00
cost_map.py test(cost): cover custom deployment aliases, off-peak pricing, bridge usage shapes and duplicate spend rows (#46708) 2026-10-15 10:44:51 -07:00
cost_tracking_case.py test(cost): cover custom deployment aliases, off-peak pricing, bridge usage shapes and duplicate spend rows (#46708) 2026-10-15 10:44:51 -07:00
test_base_model_cross_provider_spend.py fix(cost_calculator): honour base_model when the deployment provider row has no rates, with a live-proxy integration test (#46318) 2026-10-13 17:10:10 -07:00
test_batch_realtime_cost.py test(integration): move the openai cost tracking cases from cost_tracking_cases.json to CostTrackingTestCase literals (#45879) 2026-10-10 23:29:23 +00:00
test_bridged_previous_response_id_spend.py test(cost): cover turn-2 usage shapes, bridged previous_response_id, cached streams, passthrough cache writes (#46703) 2026-10-15 10:37:15 -07:00
test_cost_tracking.py test(integration): assert the streamed usage.cost matches the spend row on every cost case (#46762) 2026-10-15 22:34:42 +00:00