Welcome to Portkey Forum

Updated 5 days ago

Troubleshooting Issues with Bedrock Sonnet Model and Gateway Version Upgrade

Hi everyone!
A few days ago we moved from Gateway 1.5.3 to 1.9.8 and having issues with Bedrock Sonnet model.
With Gateway 1.5.3 we were setting max_tokens=200_000, since max_tokens parameter was required so we decided to set it to a big number.
Now with Gateway 1.9.8 we're getting the following error:
Plain Text
Error code: 400 - {\'error\': {\'message\': \'bedrock error: The maximum tokens you requested exceeds the model limit of 4096. Try again with a maximum tokens value that is lower than 4096.\', \'type\': None, \'param\': None, \'code\': None}, \'provider\': \'bedrock\'}

If we remove the max_tokens param or set it to 4096 or lower, the request is successful.
If we downgrade to Gateway 1.5.3 then even if we set max_tokens=200_000 the request passes successfully.
So we wonder why is the request failing in Gateway 1.9.8? It seems that there is a logic somewhere that checks if max_tokens_val > max_tokens_max_allowed_val.

Also we deduced that the problem starts happening in Gateway 1.8.0 where changes involving max_tokens took place.
s
a
5 comments
Hey @artyabra whew that's some edge case you got
so we migrated from model specific transforms to using bedrocks unified converse API, this is a limitation from bedrock's end
unfortunately as far as I know, there's no option but to send the correct value now
we don't maintain model specific max_token counts
So if the request is sent through bedrock unified converse API, this API has this check max_tokens_val > max_tokens_max_allowed_val?
But if the request is sent through model specific API this check is not happening?
Add a reply
Sign up and join the conversation on Discord