Relay365Multi-model API relay desk
← All desk bulletins
Spend watchEN1 desk reads

Shift Note: Count the Full Payload Before Sending

Before sending an AI request, check how much text is actually leaving your application. A short question can travel with a long conversation, detailed instructions, tool definitions, and retrieved documents. Counting that complete package helps you catch requests that are too large and estimate their cost before they run.

You do not need to understand the mathematics behind a language model to do this. You need a few terms, a suitable counting method, and enough room for the answer.

A token is a piece of text the model processes

Models process text in units called tokens. A token might represent a whole word, part of a word, punctuation, or whitespace. The exact split depends on the tokenizer used by the model.

That makes word count a rough guide. English prose, source code, numbers, and text in other languages can produce different token counts at similar lengths. Even the same sentence can tokenize differently across model families.

A character count is useful for spotting large inputs, but it is not an exact token count. If you change models, check that your counting method still applies.

Count the request your application actually sends

The message visible in a chat box is often only one part of the input. Before counting, assemble the request as your application will send it, including instructions and any material added automatically.

  • Include system instructions and other application instructions that accompany the user’s message.
  • Include earlier conversation messages that are being sent again, including previous assistant replies.
  • Include retrieved passages, pasted files, tool definitions, and tool results included in the request.
  • Check how the provider accounts for images, audio, and other non-text content, because a text tokenizer cannot fully measure them.

A common surprise appears in longer chats: yesterday’s answer becomes part of today’s input when your application resends the conversation. A small follow-up question can therefore arrive with a substantial token bill.

Use a counting method that matches the selected model

When available, use an official token-counting endpoint or a tokenizer documented as compatible with your selected model. A counting endpoint can account for supported request structures more accurately than copying visible text into a generic counter.

If you are choosing between Claude Haiku 4.5 and Gemini 2.5 Flash, do not assume one counter gives an exact result for both. Check each provider’s documentation and confirm whether your API route exposes the relevant counting capability.

When no compatible counter is available, use an estimate and leave extra room. Treat the result as a planning aid. Request formatting and provider-specific accounting can affect the usage reported after execution.

Reserve space for the answer before dispatch

The context window is the amount of information a model can work with in one request. For many APIs, input and generated output share this allowance, although the exact limits and rules depend on the model.

Suppose a hypothetical model has a 32,000-token context window. If your input uses 28,000 tokens and you request up to 6,000 output tokens, the combined budget exceeds that window. You would need to shorten the input or reduce the requested output, subject to that API’s rules.

Also check the separate maximum output limit. A large context window does not necessarily mean the model can generate an equally large response. Leave a margin when your input count is approximate.

Turn the count into a cost check

Input and output may have different prices. Estimate input cost from the counted tokens and the applicable input rate, then budget separately for the expected reply. The output limit is a ceiling; actual output usage can be lower. Check any separate treatment of cached input or reasoning tokens before estimating charges.

Relay365 is a practical option when you want pay-as-you-go access to multiple model families through one relay service. If that fits your workflow, create a Relay365 account and confirm the selected model’s pricing, limits, and supported counting features before sending a large request.

After the request completes, compare your estimate with the returned usage data. Repeating that check with your own prompts, documents, and tools will make future budgets more useful.

Further desk bulletins

Curious how it runs on your own code? Sign up →