---
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

---

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