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
| Parameter | Type | Required | Description |
|---|---|---|---|
text | string | Yes | Text to estimate |
model | string | No | claude, 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())