AI Token Counter API

Token counting and cost estimation for 33 models. No API key required.

openai (10)anthropic (9)google (5)mistral (4)meta (5) No auth required MCP ready

Endpoints

POST
/count
Count tokens for text or chat messages. Returns token count + context fit check.
POST
/count/batch
Count tokens for up to 100 texts or message arrays in one request.
GET
/pricing/:model
Input/output price per 1M tokens + cost examples for any supported model.
POST
/estimate-cost
Preflight cost with optional monthly projection. Accepts text, messages, or explicit token counts.
GET
/models
All 33 supported models grouped by provider family.
POST
/mcp
MCP JSON-RPC 2.0 endpoint for AI assistant integration.

Quick examples

# Count tokens in a string curl -sX POST https://api.lazy-mac.com/ai-token-counter/count \ -H "Content-Type: application/json" \ -d '{"model":"gpt-4o","text":"How many tokens is this sentence?"}' # Estimate cost for 1M daily requests curl -sX POST https://api.lazy-mac.com/ai-token-counter/estimate-cost \ -H "Content-Type: application/json" \ -d '{"model":"gpt-4o","input_tokens":500,"output_tokens":200,"requests_per_day":1000000}' # Get Claude Sonnet 4 pricing curl https://api.lazy-mac.com/ai-token-counter/pricing/claude-sonnet-4