Skip to content

[Bug]: LiteLLM Proxy Incorrectly Sets max_tokens to 4096 for Claude 3.5/3.7 #8835

Description

@ljk53

What happened?

For Anthropic Claude 3.5 and 3.7 models, the default maximum output token count should be 8192. However, when sending a request without the max_tokens parameter to the LiteLLM proxy, it adds a max_tokens parameter with the default value 4096, which is incorrect for Claude 3.5/3.7.

Send a request to the LiteLLM proxy without specifying max_tokens:

curl -X POST \
http://localhost:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "claude-3-7-sonnet-20250219", "messages": [{"role": "system", "content": "you are a helpful AI assistant"}, {"role": "user", "content": [{"type": "text", "text": "How to write binary search in python?"}]}]}'

Observe the request that LiteLLM sends to the Anthropic API:

POST Request Sent from LiteLLM:
curl -X POST \
https://api.anthropic.com/v1/messages \
-H 'anthropic-version: *****' -H 'x-api-key: sk-********************************************' -H 'accept: *****' -H 'content-type: *****' \
-d '{'model': 'claude-3-7-sonnet-20250219', 'messages': [{'role': 'user', 'content': [{'type': 'text', 'text': 'How to write binary search in python?'}]}], 'system': [{'type': 'text', 'text': 'you are a helpful AI assistant'}], 'max_tokens': 4096}'

Relevant log output

Are you a ML Ops Team?

No

What LiteLLM version are you on ?

v1.61.13-stable

Twitter / LinkedIn details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions