AICOMBO
EN
  • CN
  • EN
EN
  • CN
  • EN
EN
  • CN
  • EN
  1. Native Anthropic Format
  • User Guide
  • Audio
    • Text to Speech
      POST
    • Gemini Native
      POST
  • Chat
    • Native OpenAI Format
      • ChatCompletions Format
      • Responses Format
      • Responses Async Task Retrieval
      • Responses Async Task Deletion
      • Responses Async Task Retrieval (Streaming)
    • Native Gemini Format
      • Gemini Chat
    • Native Vertex AI Format
      • Gemini Chat
    • Native Anthropic Format
      • Native Claude Format
        POST
      • Native Claude Format - Token Count
        POST
  • Completions
    • Native OpenAI Format
      POST
  • Images
    • Gemini Format
      • Responses Format
      • OpenAI Compatible
  • Models
    • List Models
      • Native OpenAI Format
      • Native Gemini Format
  1. Native Anthropic Format

Native Claude Format - Token Count

POST
https://api.aicombo.com/v1/messages/count_tokens
Count the number of tokens in a message.
The Token Count API can be used to count the number of tokens in a message, including tools, images, and documents, without creating a message.
Unsupported fields are automatically filtered out.
Currently only claude-opus-4-8 and claude-opus-4-7 are supported.

请求参数

Header 参数

Body 参数application/json必填

示例
{
    "model": "claude-haiku-4-5",
    "messages": [
        {
            "role": "user",
            "content": "Hello"
        }
    ]
}

请求示例代码

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location 'https://api.aicombo.com/v1/messages/count_tokens' \
--header 'Authorization: Bearer ' \
--header 'anthropic-version: 2023-06-01' \
--header 'Content-Type: application/json' \
--data '{
    "model": "claude-haiku-4-5",
    "messages": [
        {
            "role": "user",
            "content": "Hello"
        }
    ]
}'

返回响应

🟢200Success
application/json
Bodyapplication/json

示例
{
    "input_tokens": 8
}
上一页
Native Claude Format
下一页
Native OpenAI Format
Built with