mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
fix(anthropic): propagate and format custom api_base in count_tokens endpoint
This commit is contained in:
parent
30f33a949b
commit
955f6d8cae
1 changed files with 12 additions and 2 deletions
|
|
@ -66,8 +66,18 @@ class AnthropicCountTokensHandler(AnthropicCountTokensConfig):
|
|||
|
||||
verbose_logger.debug("Transformed request: %s", request_body)
|
||||
|
||||
# Get endpoint URL
|
||||
endpoint_url: Final = api_base or self.get_anthropic_count_tokens_endpoint()
|
||||
# Construct clean endpoint URL handling custom proxy destinations
|
||||
if api_base:
|
||||
if api_base.endswith("/messages/count_tokens"):
|
||||
endpoint_url = api_base
|
||||
elif api_base.endswith("/v1/messages"):
|
||||
endpoint_url = f"{api_base.rstrip('/')}/count_tokens"
|
||||
elif api_base.endswith("/v1"):
|
||||
endpoint_url = f"{api_base.rstrip('/')}/messages/count_tokens"
|
||||
else:
|
||||
endpoint_url = f"{api_base.rstrip('/')}/v1/messages/count_tokens"
|
||||
else:
|
||||
endpoint_url = self.get_anthropic_count_tokens_endpoint()
|
||||
|
||||
verbose_logger.debug("Making request to: %s", endpoint_url)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue