anything can be done about max_tokens issues? sonn...
# questions
g
anything can be done about max_tokens issues? sonnet 3.5
Copy code
BadRequestError: litellm.BadRequestError: Error code: 400 - {\'error\': {\'message\': \'litellm.BadRequestError: AnthropicException - {"type":"error","error":{"type":"invalid_request_error","message":"max_tokens: 16384 > 8192, which is the maximum allowed number of output tokens for claude-3-5-sonnet-20241022"}}. Received Model Group=coding\\nAvailable Model Group Fallbacks=None\', \'type\': None, \'param\': None, \'code\': \'400\'}}
kimi2
Copy code
'BadRequestError: litellm.BadRequestError: Error code: 400 - {\'error\': {\'message\': \'litellm.BadRequestError: GroqException - {"error":{"message":"`max_tokens` must be less than or equal to `16384`, the maximum value for `max_tokens` is less than the `context_window` for this model","type":"invalid_request_error"}}\\n. Received Model Group=coding\\nAvailable Model Group Fallbacks=None\', \'type\': None, \'param\': None, \'code\': \'400\'}}'
c
please set a max_output_tokens in config.toml or as env var
l
What version of OpenHands are you using? I think this might be fixed in the most recent version
g
0.50.0
l
Hmm, that should be fixed…
I think that you shouldn’t be getting these errors typically, so maybe you have a configuration that sets it to
max_tokens: 16384
g
it does get fixed by that in ENV, but if i add that into litellm - no dice... pain in the ass if i want to switch models quicky
or is there something new in config where i can specify llm per conversation?
c
You can use a different LLM per session, if you use CLI mode or headless?
g
no - i use API
c
Sorry, just to understand, could you elaborate a bit, you use the web API on a local system?
g
yes - i use REST API on local ohapp
c
The API/web is very restrictive and a bit broken on this. I added this issue here Could you tell what exactly was the env var name that you used?
l
Hey @gorgeous-horse-69467, sorry about the late reply. I think you don’t need to set it at all. Currently it should just default to the actual limit for that model
g
but it errors out without specifying it....
l
What error is it?
g
the 2 examples at the top....
how are you able to determine actual limit for that model?
if i use high-perf endpoints like groq or cerberas
dont they have their own settings
l
I think that if you don’t set the maximum then most API endpoints will just use the default maximum. I guess that maybe the maximum is being set for you somehow, e.g. through an environment variable or something in config.toml