A token is a text fragment. For ordinary English prose, roughly three-quarters of a word on average — but the average conceals wide variation. Code, unusual names, non-Latin scripts and numbers all tokenise less efficiently, sometimes dramatically so. If your content is not English prose, measure rather than assume, because a budget built on the rule of thumb can be out by a factor of two.
The window covers everything. System prompt, conversation history, retrieved passages, tool definitions, tool results and the output being generated all share it. A large window fills faster than people expect, and the first thing to overflow is usually the retrieved context that the answer depended on.
Input and output are priced differently, usually with output several times more expensive. A system that sends large context and generates short answers has a very different cost profile from one that does the reverse, and optimising the wrong side is common.
Conversations grow quadratically in cost. Each turn re-sends the whole history. A twenty-turn conversation is not twenty times the cost of one turn; it is considerably more. Summarising or truncating history is a design decision, and leaving it to the default is how a bill surprises somebody.