---
title: "Count tokens with a supported Algenta tokenizer model"
method: POST
path: "/v1/count_tokens"
tags: ["LLM API"]
---

# Count tokens with a supported Algenta tokenizer model

`POST /v1/count_tokens`

## Request

- Base URL: `https://api.algenta.ai`
- URL: `https://api.algenta.ai/v1/count_tokens`
- Auth: one of:
  - HTTP bearer
  - API key in header `X-API-Key`

Runs the selected tokenizer model and returns the deterministic token count.

## Request body

- CountTokensRequest
  - `model` string: Model identifier from GET /v1/models.
  - `input` string, required: UTF-8 text to count with the selected tokenizer.

## Response `200`

Successful Response

- CountTokensResponse
  - `object` 'token_count'
  - `model` string, required
  - `tokenizer_kind` string, required
  - `token_count` integer, required

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/codna/apis/algenta-api.md) · [All operations](https://skmtc.dev/codna/apis/algenta-api/llms.txt) · [OpenAPI document](https://skmtc.dev/codna/apis/algenta-api/revisions/35d30f84a5df?raw)
