litellm - ✅(Solved) Fix [Feature]: Support Anthropic `task_budget` parameter for Claude Opus 4.7 [2 pull requests, 1 comments, 2 participants]

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…
GitHub stats
BerriAI/litellm#25971Fetched 2026-04-18 05:52:44
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×3cross-referenced ×2commented ×1

Fix Action

Fixed

PR fix notes

PR #25988: Add Anthropic task budget support

Description (problem / solution / changelog)

Title\n\nAdd Anthropic task_budget support for Claude Opus 4.7\n\n## Relevant issues\n\nFixes #25971\n\n## Type\n\n- [x] Enhancement\n- [x] Bug Fix\n- [ ] Documentation\n\n## Changes\n\n- Adds typed Anthropic output_config.task_budget support for Claude Opus 4.7.\n- Adds the task-budgets-2026-03-13 beta header when output_config.task_budget is used.\n- Preserves caller-provided output_config fields when reasoning_effort maps to output_config.effort.\n- Adds focused Anthropic transformation tests for task_budget preservation, validation, beta headers, and public optional param mapping.\n\n## Testing\n\n- uv run pytest tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py -q\n\n## Notes\n\nFormatting commands were not run per request.

Changed files

  • litellm/llms/anthropic/chat/transformation.py (modified, +31/-1)
  • litellm/llms/anthropic/common_utils.py (modified, +29/-0)
  • litellm/types/llms/anthropic.py (modified, +12/-1)
  • litellm/utils.py (modified, +8/-0)
  • tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py (modified, +122/-0)

PR #25990: Add Anthropic task_budget support

Description (problem / solution / changelog)

Summary

  • add typed Anthropic output_config.task_budget support and validation
  • add task-budgets beta header injection for chat and messages pass-through paths
  • add supports_task_budget model metadata for Claude Opus 4.7 and focused tests

Fixes #25971

Tests

  • uv run pytest tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py -q

Note: formatting commands were not run per request.

Changed files

  • litellm/integrations/prometheus.py (modified, +8/-5)
  • litellm/integrations/prometheus_helpers.py (modified, +1/-2)
  • litellm/llms/anthropic/chat/transformation.py (modified, +46/-9)
  • litellm/llms/anthropic/common_utils.py (modified, +29/-0)
  • litellm/llms/anthropic/experimental_pass_through/messages/transformation.py (modified, +8/-0)
  • litellm/llms/github_copilot/authenticator.py (modified, +1/-3)
  • litellm/model_prices_and_context_window_backup.json (modified, +7/-0)
  • litellm/passthrough/utils.py (modified, +3/-1)
  • litellm/types/integrations/prometheus.py (modified, +1/-1)
  • litellm/types/llms/anthropic.py (modified, +13/-1)
  • litellm/types/utils.py (modified, +1/-0)
  • litellm/utils.py (modified, +18/-0)
  • model_prices_and_context_window.json (modified, +7/-0)
  • tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py (modified, +173/-0)
  • tests/test_litellm/llms/bedrock/test_bedrock_common_utils.py (modified, +1/-6)
  • tests/test_litellm/test_utils.py (modified, +1/-0)

Code Example

output_config = {
      "effort": "high",
      "task_budget": {"type": "tokens", "total": 64000}
  }
RAW_BUFFERClick to expand / collapse

Check for existing issues

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

The Feature

Anthropic Claude Opus 4.7 introduced a new public-beta parameter task_budget (inside output_config) that gives the model a soft token budget for an entire agentic loop (thinking + tool calls + tool results + text). The model sees a running countdown and uses it to prioritize work.

Required to use it:

  • Beta header: anthropic-beta: task-budgets-2026-03-13
  • Body shape:
output_config = {
    "effort": "high",
    "task_budget": {"type": "tokens", "total": 64000}
}

Motivation, pitch

Without first-class support, callers using LiteLLM against Claude Opus 4.7 can't use task_budget through the standard abstraction — they'd have to drop down to extra_body and manually wire the beta header (and even then it's unclear whether all paths transit it cleanly across providers like Vertex AI / Bedrock).

task_budget is the recommended way to control cost/latency for long-running agentic workflows on 4.7, so most teams that adopt 4.7 for agents will hit this gap. Surfacing it as a typed kwarg keeps the abstraction useful and avoids each user re-discovering the beta header name.

Happy to submit a PR if this is something the maintainers want :)

What part of LiteLLM is this about?

SDK (litellm Python package)

LiteLLM is hiring a founding backend engineer, are you interested in joining us and shipping to all our users?

No

Twitter / LinkedIn details

No response

extent analysis

TL;DR

Add support for the task_budget parameter in the LiteLLM SDK by introducing a typed keyword argument.

Guidance

  • Introduce a new keyword argument task_budget in the LiteLLM SDK to support the task_budget parameter in Claude Opus 4.7.
  • Update the SDK to include the required beta header anthropic-beta: task-budgets-2026-03-13 when the task_budget argument is provided.
  • Verify that the task_budget argument is correctly passed to the output_config and that the beta header is properly set.
  • Consider adding documentation and examples to demonstrate how to use the task_budget argument in the LiteLLM SDK.

Example

def litellm_function(..., task_budget=None):
    output_config = {
        "effort": "high",
    }
    if task_budget:
        output_config["task_budget"] = task_budget
        # Set beta header
        headers = {"anthropic-beta": "task-budgets-2026-03-13"}
    # ...

Notes

The implementation details may vary depending on the existing architecture of the LiteLLM SDK. This guidance provides a general outline of the steps required to add support for the task_budget parameter.

Recommendation

Apply workaround by introducing a typed keyword argument task_budget in the LiteLLM SDK, as this allows users to utilize the recommended way to control cost/latency for long-running agentic workflows on Claude Opus 4.7.

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 - ✅(Solved) Fix [Feature]: Support Anthropic `task_budget` parameter for Claude Opus 4.7 [2 pull requests, 1 comments, 2 participants]