Skip to content

feat: support claude token count api /v1/messages/count_tokens#59

Merged
bbbugg merged 5 commits intomainfrom
fix/claude-token-count
Feb 5, 2026
Merged

feat: support claude token count api /v1/messages/count_tokens#59
bbbugg merged 5 commits intomainfrom
fix/claude-token-count

Conversation

@bbbugg
Copy link
Member

@bbbugg bbbugg commented Feb 5, 2026

  • 支持 claude token count 接口 /v1/messages/count_tokens

  • support claude token count api /v1/messages/count_tokens

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for Claude's token counting API endpoint /v1/messages/count_tokens. The implementation translates Claude API requests to Google Gemini's countTokens API format and converts the response back to Claude's expected format.

Changes:

  • Added new endpoint handler processClaudeCountTokens that processes token count requests
  • Refactored common Google request finalization logic into a reusable _finalizeGoogleRequest method
  • Removed redundant debug logging statements that are now captured by the consolidated final request log

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/core/RequestHandler.js Adds processClaudeCountTokens method to handle Claude token count requests by translating to Gemini format and mapping responses
src/core/ProxyServerSystem.js Registers new POST endpoint /v1/messages/count_tokens
src/core/FormatConverter.js Refactors duplicate code into _finalizeGoogleRequest method and removes redundant debug logs
README.md Documents the new count_tokens endpoint in Chinese
README_EN.md Documents the new count_tokens endpoint in English

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bbbugg bbbugg requested a review from Copilot February 5, 2026 16:14
@bbbugg bbbugg changed the title fix: support claude token count api fix: support claude token count api /v1/messages/count_tokens Feb 5, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bbbugg bbbugg merged commit 3fd6d43 into main Feb 5, 2026
6 checks passed
@github-actions
Copy link

github-actions bot commented Feb 5, 2026

🎉 此 PR 的修改已在版本 v0.6.1 中发布。
🎉 The changes in this PR have been released in version v0.6.1.

@bbbugg bbbugg changed the title fix: support claude token count api /v1/messages/count_tokens feat: support claude token count api /v1/messages/count_tokens Feb 5, 2026
@bbbugg bbbugg deleted the fix/claude-token-count branch February 7, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant