---
title: "Tokenize"
method: POST
path: "/v1/tokenize"
tags: ["Tokenizer"]
---

# Tokenize

`POST /v1/tokenize`

## Headers

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

## Request body

- TokenizeIn
  - `model` string, required — model name
  - `prompt` string, nullable — text to tokenize (completion form)
  - `messages` object[], nullable — chat messages to tokenize (chat form)
  - `return_token_strs` boolean, nullable — also return the per-token strings (vLLM)

## Response `200`

Successful Response

- TokenizeOut
  - `count` integer, required — number of tokens
  - `max_model_len` integer, required — the model's maximum context length
  - `tokens` integer[], required — token ids
  - `token_strs` string[], nullable — per-token strings, if requested (vLLM)

## 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/versions/2df28210837a/schema)
