---
title: "Token Counter"
method: POST
path: "/utils/token_counter"
tags: ["llm utils"]
---

# Token Counter

`POST /utils/token_counter`

Args:
    request: TokenCountRequest
    call_endpoint: bool - When set to "True" it will call the token counting endpoint - e.g Anthropic or Google AI Studio Token Counting APIs.

Returns:
    TokenCountResponse

## Query parameters

- `call_endpoint` boolean

## Request body

- TokenCountRequest
  - `model` string, required
  - `prompt` string, nullable
  - `messages` object[], nullable
  - `contents` object[], nullable
  - `tools` object[], nullable
  - `system` unknown

## Response `200`

Successful Response

- TokenCountResponse
  - `total_tokens` integer, required
  - `request_model` string, required
  - `model_used` string, required
  - `tokenizer_type` string, required
  - `original_response` object, nullable
  - `error` boolean
  - `error_message` string, nullable
  - `status_code` integer, nullable

## Other responses

- `422` — Validation Error

## Changes

- **2026-09-18** `082b5fabd909` — 2 info
  - added the optional property `detail/items/ctx` to the response with the `422` status
  - added the optional property `detail/items/input` to the response with the `422` status

[Change history](https://skmtc.dev/flock/apis/litellm-api/changes/utils/token_counter/post.md)

---

[API](https://skmtc.dev/flock/apis/litellm-api.md) · [All operations](https://skmtc.dev/flock/apis/litellm-api/llms.txt) · [OpenAPI document](https://skmtc.dev/flock/apis/litellm-api/revisions/c71315002afa?raw)
