curl --request POST \
--url https://trylimitless.ai/v1/messages/count_tokens \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{
"content": "<string>"
}
]
}
'import requests
url = "https://trylimitless.ai/v1/messages/count_tokens"
payload = {
"model": "<string>",
"messages": [{ "content": "<string>" }]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: '<string>', messages: [{content: '<string>'}]})
};
fetch('https://trylimitless.ai/v1/messages/count_tokens', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"input_tokens": 1
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}Count input tokens
Count a Messages-shaped input without generating output or recording a billable inference event. Requires inference:write. The current backend may use an estimate when its tokenizer is unavailable.
curl --request POST \
--url https://trylimitless.ai/v1/messages/count_tokens \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{
"content": "<string>"
}
]
}
'import requests
url = "https://trylimitless.ai/v1/messages/count_tokens"
payload = {
"model": "<string>",
"messages": [{ "content": "<string>" }]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: '<string>', messages: [{content: '<string>'}]})
};
fetch('https://trylimitless.ai/v1/messages/count_tokens', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"input_tokens": 1
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}{
"type": "error",
"error": {
"code": "<string>",
"message": "<string>",
"type": "<string>",
"param": "<string>",
"request_id": "<string>",
"doc_url": "<string>"
}
}Authorizations
Project customer key. Requires the permission for the requested endpoint.
Headers
Messages protocol version.
Model-supported beta protocol flags.
512Optional cache-affinity hint, isolated to this organization and project. X-Abliteration-Session-ID is accepted for compatibility.
1 - 512Body
Model-dependent request fields. Read the compatibility guide for supported combinations and limits.
1 - 2001Show child attributes
Show child attributes
Chat: function tools. Responses: functions and supported web_search aliases. Messages: custom functions, web_search_2025_03_05 and web_fetch_2025_03_05. See the tools guide.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Response
Successful response.
x >= 0