---
title: "Count tokens"
method: POST
path: "/messages/count_tokens"
tags: ["Messages"]
---

# Count tokens

`POST /messages/count_tokens`

## Request

- Base URL: `https://api.munito.ai/inference/v1`
- URL: `https://api.munito.ai/inference/v1/messages/count_tokens`
- Auth: one of:
  - HTTP bearer
  - API key in header `x-api-key`

Count the input tokens a Messages request would consume, without running it. Same request shape as POST /messages (minus `max_tokens`); free.

## Headers

- `munito-service-tier` 'priority' | 'standard' | 'flex'
- `munito-affinity` string

## Request body

- object
  - `model` string, required: Model id from GET /models.
  - `messages` object[], required: The conversation as Anthropic-style messages: `content` is a string or an array of content blocks.
    - `role` 'user' | 'assistant'
    - `content` union
      - string
      - object[]: Content blocks: `text`, `image`, `tool_use`, `tool_result` and `thinking`.
  - `system` union: System prompt (top-level, Anthropic-style): a string or an array of `text` blocks.
    - string
    - object[]: `text` blocks.

## Response `200`

The input-token count.

---

[API](https://skmtc.dev/munito/apis/munito-ai-api.md) - [All operations](https://skmtc.dev/munito/apis/munito-ai-api/llms.txt) - [OpenAPI document](https://skmtc.dev/munito/apis/munito-ai-api/revisions/d4ccbe8844df?raw)
