---
title: "Anthropic Messages Count Tokens"
method: POST
path: "/anthropic/v1/messages/count_tokens"
tags: ["Chat Completions"]
---

# Anthropic Messages Count Tokens

`POST /anthropic/v1/messages/count_tokens`

## Headers

- `xi-api-key` string, nullable
- `x-api-key` string, nullable

## Request body

- AnthropicTokenCountRequest
  - `model` string, required
  - `messages` object[], required
  - `system` union
    - string
    - AnthropicSystemContent[]
      - `type` 'text', required
      - `text` string, required
  - `tools` AnthropicTool[], nullable
    - `name` string, required
    - `description` string, nullable
    - `input_schema` object, required
  - `thinking` AnthropicThinkingConfig — Anthropic `thinking` config: {type: enabled|disabled|adaptive, budget_tokens}. `enabled` is a legacy pre-spec field this endpoint used to accept; it only applies when `type` is absent.
    - `type` 'enabled' | 'disabled' | 'adaptive', nullable
    - `budget_tokens` integer, nullable
    - `enabled` boolean, nullable
  - `tool_choice` object, nullable

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/deepinfra/apis/deepinfra-api.md) · [All operations](https://skmtc.net/deepinfra/apis/deepinfra-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/deepinfra/deepinfra-api/revisions/1ff37a4f6190/schema)
