Tokens & context windows
Language models read and write tokens — chunks of text roughly ¾ of a word. You’re billed per token for chat and embeddings; understanding them makes cost and limits predictable.
How AIx estimates tokens
Before a call, AIx tokenizes your input with tiktoken o200k_base (the GPT-4o family
encoding). It’s a strong cross-model approximation — far more accurate than the naive
“characters ÷ 4” rule — and falls back to that heuristic only if the tokenizer fails to load.
The estimate is used only for the pre-flight credit hold and the per-minute (TPM) check.
Real billing settles on the provider’s reported usage — the exact prompt_tokens /
completion_tokens returned by the upstream. See Billing model.
max_tokens
max_tokens caps the output length (default 256). It does not affect input cost. Set
it deliberately for coding tasks — long completions cost more and can be truncated mid-answer
if set too low.
Context windows
The context window is the total tokens (input + output) a model can consider at once. It’s model-specific — small models hold a few thousand tokens, frontier models hundreds of thousands. AIx forwards your messages to the provider; if you exceed the model’s window the provider rejects the call. Keep prompts within the target model’s window (the models page lists ids; consult the model’s own docs for its exact window).
Cost math
For token-priced models, price is quoted per 1M tokens:
cost = (prompt_tokens + completion_tokens) / 1{,}000{,}000 × price_per_1M
Embeddings are billed on input tokens only. Images bill per image (n × price), TTS by
input tokens, and transcription by measured audio minutes. Image and transcription
billing do not use chat-token accounting.
Request size limits
To protect the service, JSON requests are bounded:
| Limit | Value |
|---|---|
| Max messages per request | 100 |
| Max single message length | 50,000 chars |
| Max prompt length | 10,000 chars |
| Max JSON body | 1 MB |
| Max upload (audio file) | 25 MB |
Exceeding these returns 400 invalid_request_error. Large binaries (audio) go through the
multipart upload path, not the JSON body.
Prompts are treated as data — including code. AIx does not strip backticks, $,
angle brackets or other code characters during sanitisation (only NUL bytes are removed), so
your source and shell snippets reach the model intact.