Repository navigation
test(integration): audio, image and per-unit cost cases - #42024
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ts out Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…sions' into litellm_cost_shard_audio_images Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> # Conflicts: # tests/integration/contracts.json # tests/integration/cost_calculation/cost_tracking_case.py # tests/integration/cost_calculation/cost_tracking_cases.json
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…shard_audio_images
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
TLDR
Problem this solves:
How it solves it:
cost_breakdownwithbreakdown_persisted: falseUser Flow
Before: a proxy admin has no shard proving what transcriptions, speech or images cost
{"text": "hello"}back"input": "hello world"and get MP3 bytes back"size": "1024x1024", "quality": "hd"and get one image URL backtests/integration/run.py costonly covers text endpointsAfter: each of those calls has a scripted case with the exact spend and row pinned
tests/integration/run.py cost/v1/audio/transcriptions,/v1/audio/speech,/v1/images/generationsor/v1/images/edits, receives a literal provider body, and asserts the persisted spend, tokens and, where litellm sends one, the response cost headerRelevant issues
Builds on #41999 (harness fields this data needs). Diff shows both until that one lands, then this rebases to main
Affected release
Linear ticket
Resolves LIT-8193
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Test data only, the proxy code path is unchanged. Proof is the shard against the scripted upstream that the shard itself starts (no provider spend by design)
Before (9bd648b)
tests/integration/run.py cost -k "transcriptions or speech or images"selects nothingAfter (5b97d98)
tests/integration/run.py cost -k "transcriptions or speech or images"against a fresh proxy and empty Redis:16 passed, 366 deselected8 passedmake lintpassesType
✅ Test
Caveats (if any)
Medium
cost_breakdown, so those cases opt out of the breakdown checksx-litellm-response-costheader, so binary cases only check it when presentLow
duration, not the uploaded audio lengthlow/1024-x-1024/entryhello worldas 10 billable charactersLink to Devin session: https://app.devin.ai/sessions/5425681f498543a19de84adcf8daeed8
Open in Devin Desktop: https://app.devin.ai/desktop/session/5425681f498543a19de84adcf8daeed8?variant=devin