Skip to content

[fix] extra_headers in messages api bedrock invoke - #17271

Merged
Sameerlite merged 4 commits into
BerriAI:mainfrom
colinlin-stripe:cherry-pick-invoke-headers
Dec 2, 2025
Merged

Sameerlite merged 4 commits into
BerriAI:mainfrom
colinlin-stripe:cherry-pick-invoke-headers

Conversation

@colinlin-stripe

@colinlin-stripe colinlin-stripe commented Nov 28, 2025 •

Copy link
Copy Markdown
Contributor

extra_headers in messages api bedrock invoke

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 Bug Fix
✅ Test

Changes

Extra_headers from litellm config were not being propagated for messages api -> bedrock invoke
the are present in the kwargs but are not being extracted.

motivation is to pass anthropic beta headers to bedrock see docs

Testing

ran poetry run pytest tests/test_litellm/llms/custom_httpx/test_llm_http_handler.py -v

Screenshot 2025-11-28 at 5 27 21 PM

example litellm_config.yaml

- model_name: claude-sonnet-4.5-1m
    litellm_params:
      model: bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0
      extra_headers:
        anthropic-beta: "context-1m-2025-08-07"

example curl

curl -v http://localhost:4000/v1/messages \
  -H 'Authorization: Bearer sk-master' \
  -H 'Content-Type: application/json' \
  -d '{"model": "claude-sonnet-4-5-1m", "max_tokens": 10, "messages": [{"role": "user", "content": "200k+ tokens of content"}]}' \

if request succeeds then anthropic beta header was propagated successfully

@vercel

vercel Bot commented Nov 28, 2025

Copy link
Copy Markdown

@colinlin-stripe is attempting to deploy a commit to the CLERKIEAI Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@colinlin-stripe
colinlin-stripe marked this pull request as ready for review November 28, 2025 22:31
@Sameerlite

Copy link
Copy Markdown
Contributor
image This test is failing

@colinlin-stripe

colinlin-stripe commented Dec 1, 2025 •

Copy link
Copy Markdown
Contributor Author

@Sameerlite Looking at the diff seems like the contents of the list is the same, but the order is different.
is that OK? i ran the same test locally and it passed

poetry run python -m pytest tests/test_litellm/llms/bedrock/test_anthropic_beta_support.py::TestAnthropicBetaHeaderSupport::test_anthropic_beta_all_supported_features -xvs --cache-clear

tests/test_litellm/llms/bedrock/test_anthropic_beta_support.py::TestAnthropicBetaHeaderSupport::test_anthropic_beta_all_supported_features <module 'litellm' from '/Users/colinlin/stripe/litellm/litellm/__init__.py'>
PASSED

@colinlin-stripe
colinlin-stripe force-pushed the cherry-pick-invoke-headers branch from 6bc88db to 661bccb Compare December 1, 2025 19:26
@Sameerlite
Sameerlite merged commit dbf1cd5 into BerriAI:main Dec 2, 2025
3 of 6 checks passed
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…oke-headers

[fix] extra_headers in messages api bedrock invoke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants