Skip to main content
POST
/
v1
/
tokenize
Tokenization
curl --request POST \
  --url http://localhost:8000/v1/tokenize \
  --header 'Content-Type: application/json' \
  --data '
{
  "prompt": "What is generative AI?"
}
'
import requests

url = "http://localhost:8000/v1/tokenize"

payload = { "prompt": "What is generative AI?" }
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({prompt: 'What is generative AI?'})
};

fetch('http://localhost:8000/v1/tokenize', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "http://localhost:8000/v1/tokenize"

payload := strings.NewReader("{\n \"prompt\": \"What is generative AI?\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
{
  "tokens": [
    128000,
    3923,
    374,
    1803,
    1413,
    15592,
    30
  ]
}
Convert text input into token IDs.

Body

application/json
prompt
string
required

Input text prompt to tokenize.

Example:

"What is generative AI?"

model
string | null

Routes the request to a specific adapter.

Example:

"(adapter-route)"

Response

Successfully tokenized the text.

tokens
integer[]
required

A list of token IDs.

Last modified on June 9, 2026