Documentation Index
Fetch the complete documentation index at: https://docs.nano-gpt.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
UsePOST /api/v1/messages/count_tokens to estimate the number of input tokens for an Anthropic Messages-format request.
This endpoint is useful for request planning, context budgeting, and cost control. The result is an estimate and may not exactly match a provider tokenizer.
Endpoint
Authentication
Use either header:Authorization: Bearer YOUR_API_KEYx-api-key: YOUR_API_KEY
Request Body
Supported Content
The request uses Anthropic message format and supports:- text blocks
- image and document-like blocks
- tool use blocks
- tool result blocks
systemtoolstool_choice
Response
Example
Notes
- This is an estimate for planning and cost control.
- It may not exactly match a provider tokenizer.
- For generation, use
POST /api/v1/messages.