Skip to content

Support Anthropic messages count_tokens API - #1477

Merged
shihaobai merged 4 commits into
mainfrom
bsh/anthropic-count-tokens
Aug 21, 2026
Merged

Support Anthropic messages count_tokens API#1477
shihaobai merged 4 commits into
mainfrom
bsh/anthropic-count-tokens

Conversation

@shihaobai

Copy link
Copy Markdown
Collaborator

Summary

  • add POST /v1/messages/count_tokens compatibility endpoint
  • reuse the existing Anthropic request translation, chat-template rendering, tool selection, and multimodal handling
  • reuse LightLLM's token counting path and return the vLLM-compatible context_management.original_input_tokens field

Validation

  • python -m py_compile lightllm/server/api_anthropic.py lightllm/server/api_http.py lightllm/server/api_openai.py
  • git diff --check

pytest is unavailable in the current environment.

@shihaobai
shihaobai marked this pull request as ready for review August 21, 2026 06:16
@shihaobai
shihaobai merged commit 1f659be into main Aug 21, 2026
1 check passed
@shihaobai
shihaobai deleted the bsh/anthropic-count-tokens branch August 21, 2026 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant