Characters, bytes and tokens measure different things
A short-looking multilingual prompt, escaped text or a large embedded data string can exceed a byte limit unexpectedly. These input-validation limits are not the model's advertised context window, and increasing max_tokens or max_credits does not override them. The service's quote input bound is also not an exact tokenizer count.
What to do next
- 01
Measure the actual content
Calculate UTF-8 byte length for every message and sum it. Exclude no message merely because its role is system or assistant; all content contributes to the limit.
- 02
Remove unnecessary material
Trim repeated history, raw documents and accidental base64 data. Keep the essential task requirements and distinguish summaries from source material when reducing context.
- 03
Validate the complete envelope
Serialize the final JSON body and check its total size and message count before quoting. Preserve that exact approved body for retries so later context expansion does not change it.
A concrete example
Illustrative failure: a request contains ten short-looking messages in a language whose characters use multiple UTF-8 bytes. It crosses the text-byte ceiling despite a modest visual character count. A byte measurement identifies the real restriction.
Before you call it ready
- UTF-8 bytes are measured.
- Message count and JSON size are checked separately.
- No attachment data is hidden inside text.
When to stop or choose another method
If the task needs substantially more source material, divide it into meaningful supported steps or choose another service. Do not disguise oversized data as a single message.
