Docs/Text Utils/GET /v1/token-count

GET /v1/token-countEstimate token count for LLM models

Text Utils lf-text-utils

Estimates how many tokens a piece of text will cost when sent to a language model. Estimate token count for LLM models

Query Parameters

ParameterTypeRequiredDescription
textstringYesText to estimate
modelstringNoclaude, gpt-4, gpt-3.5, llama, or default

Response Schema

tokens (integer): Estimated token count
chars (integer): Character count
model (string): Model used
estimated_cost_input (string): Estimated input cost

cURL Example

curl 'https://lf-text-utils.laminarforge.dev/v1/token-count?text=<text>' -H 'Authorization: Bearer lf_YourApiKey'

Python Example

import requests
url = 'https://lf-text-utils.laminarforge.dev/v1/token-count'
headers = {'Authorization': 'Bearer lf_YourApiKey'}
params = {'text': '<text>'}
response = requests.get(url, headers=headers, params=params)
print(response.json())