> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neosantara.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Count tokens

> Count the number of tokens in a message using the Anthropic-compatible API.



## OpenAPI

````yaml /api-reference/openapi.json post /anthropic/v1/messages/count_tokens
openapi: 3.1.0
info:
  title: Neosantara AI API
  description: OpenAI-compatible LLM Gateway
  version: 1.0.0
servers:
  - url: https://api.neosantara.xyz
    description: Neosantara Production Gateway
security:
  - bearerAuth: []
paths:
  /anthropic/v1/messages/count_tokens:
    post:
      tags:
        - Anthropic
      summary: Count tokens
      description: >-
        Count the number of tokens in a message using the Anthropic-compatible
        API.
      operationId: postAnthropicV1MessagesCountTokens
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                model:
                  type: string
                messages:
                  type: array
                  items: {}
                system:
                  anyOf:
                    - type: string
                    - type: array
                      items: {}
                tools:
                  type: array
                  items: {}
                thinking: {}
              required:
                - model
                - messages
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  input_tokens:
                    type: integer
                    minimum: 0
                required:
                  - input_tokens
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

## Related topics

- [Create batch](/api-reference/batches/create-batch.md)
- [Retrieve batch](/api-reference/batches/retrieve-batch.md)
- [Function Calling (Tools)](/id/gateway/chat-completions/tool-calling.md)
- [Penalaran (Reasoning)](/id/gateway/chat-completions/reasoning.md)
- [Vision Multimodal](/id/gateway/chat-completions/vision.md)
