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

# Count Anthropic Tokens

> Count input tokens for an Anthropic-format request without running the model.



## OpenAPI

````yaml /api-reference/v3-openapi.json post /v3/v1/messages/count_tokens
openapi: 3.1.0
info:
  title: Eden AI API V3
  version: 3.0.0
servers:
  - url: https://api.edenai.run
    description: Production server
security: []
paths:
  /v3/v1/messages/count_tokens:
    post:
      tags:
        - Anthropic Messages
      summary: Count Anthropic Tokens
      description: >-
        Count input tokens for an Anthropic-format request without running the
        model.
      operationId: count_anthropic_tokens_v3_v1_messages_count_tokens_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnthropicCountTokensBody'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicCountTokensResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - AuthBearer: []
components:
  schemas:
    AnthropicCountTokensBody:
      properties:
        model:
          type: string
          title: Model
        messages:
          items:
            $ref: '#/components/schemas/AnthropicMessage'
          type: array
          title: Messages
        system:
          anyOf:
            - type: string
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          title: System
        tools:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          title: Tools
        tool_choice:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Tool Choice
      additionalProperties: true
      type: object
      required:
        - model
        - messages
      title: AnthropicCountTokensBody
      description: >-
        Body for /v1/messages/count_tokens — same fields as messages but
        max_tokens is optional.
    AnthropicCountTokensResponse:
      properties:
        input_tokens:
          type: integer
          title: Input Tokens
          description: Number of input tokens the request would consume.
      type: object
      required:
        - input_tokens
      title: AnthropicCountTokensResponse
      description: Response body for POST /v1/messages/count_tokens.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AnthropicMessage:
      properties:
        role:
          type: string
          enum:
            - user
            - assistant
            - system
          title: Role
        content:
          anyOf:
            - type: string
            - items:
                $ref: '#/components/schemas/AnthropicContentBlock'
              type: array
          title: Content
      additionalProperties: true
      type: object
      required:
        - role
        - content
      title: AnthropicMessage
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    AnthropicContentBlock:
      properties:
        type:
          type: string
          title: Type
        text:
          anyOf:
            - type: string
            - type: 'null'
          title: Text
        id:
          anyOf:
            - type: string
            - type: 'null'
          title: Id
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
        input:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Input
        tool_use_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Tool Use Id
        content:
          anyOf:
            - type: string
            - items: {}
              type: array
            - type: 'null'
          title: Content
        is_error:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Is Error
        source:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Source
        thinking:
          anyOf:
            - type: string
            - type: 'null'
          title: Thinking
        signature:
          anyOf:
            - type: string
            - type: 'null'
          title: Signature
      additionalProperties: true
      type: object
      required:
        - type
      title: AnthropicContentBlock
  securitySchemes:
    AuthBearer:
      type: http
      scheme: bearer

````