Skip to content

[Bug]: BedrockError: {"message":"The additional field max_tokens conflicts with the existing field maxTokens. Remove max_tokens and try again."} #13841

@Co1lin

Description

@Co1lin

What happened?

The following code works three days before. But somehow now it shows an incompatible issue with bedrock. Maybe the behavior of bedrock changed.

import litellm

r = litellm.completion(
    model='bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0',
    messages=[{'role': 'user', 'content': 'Hello! Tell me a joke.'}],
    max_completion_tokens=128, # this works before, but now it cannot
    # max_tokens=2048, # now this can work
    reasoning_effort='low',
)

print(r)

Relevant log output

Traceback (most recent call last):
  File "/ephnvme/colin/code/coderig/.venv/lib/python3.12/site-packages/litellm/llms/bedrock/chat/converse_handler.py", line 442, in completion
    response = client.post(
               ^^^^^^^^^^^^
  File "/ephnvme/colin/code/coderig/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/http_handler.py", line 576, in post
    raise e
  File "/ephnvme/colin/code/coderig/.venv/lib/python3.12/site-packages/litellm/llms/custom_httpx/http_handler.py", line 558, in post
    response.raise_for_status()
  File "/ephnvme/colin/code/coderig/.venv/lib/python3.12/site-packages/httpx/_models.py", line 829, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://bedrock-runtime.us-east-1.amazonaws.com/model/us.anthropic.claude-3-7-sonnet-20250219-v1%3A0/converse'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400

Are you a ML Ops Team?

No

What LiteLLM version are you on ?

v1.67.5 (also tried the latest stable one v1.75.9)

Twitter / LinkedIn details

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions