litellm - 💡(How to fix) Fix [Bug]: Anthropic batch costs always 0 — transform_file_content_request routes msgbatch_* IDs to wrong endpoint

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

AnthropicFilesConfig.transform_file_content_request in litellm/llms/anthropic/files/transformation.py generates the wrong URL for batch result IDs:

# Current (broken) — always uses the Files API endpoint
return f"{api_base.rstrip('/')}/v1/files/{file_id}/content", {}

Code Example

# Current (broken) — always uses the Files API endpoint
return f"{api_base.rstrip('/')}/v1/files/{file_id}/content", {}


### Steps to Reproduce

1. Send batch to anthropic model
2. Check the costs after the polling has completed
3. Costs remain 0


### Relevant log output
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

Bug Description

When using the Anthropic batch API through LiteLLM, CheckBatchCost always records 0 tokens and $0 cost for completed batches, silently dropping all cost data.

Root Cause

AnthropicFilesConfig.transform_file_content_request in litellm/llms/anthropic/files/transformation.py generates the wrong URL for batch result IDs:

# Current (broken) — always uses the Files API endpoint
return f"{api_base.rstrip('/')}/v1/files/{file_id}/content", {}


### Steps to Reproduce

1. Send batch to anthropic model
2. Check the costs after the polling has completed
3. Costs remain 0


### Relevant log output

```shell

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

v1.83.10

Twitter / LinkedIn details

No response

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

litellm - 💡(How to fix) Fix [Bug]: Anthropic batch costs always 0 — transform_file_content_request routes msgbatch_* IDs to wrong endpoint