Models don't read words. They read tokens, small pieces of text, often part of a word. Providers charge by the token, for both what you send, and what the model writes.
Every reply has usage metadata, with the input tokens, the output tokens, and the total. Here we compare a short prompt with a long one. Run it. The longer prompt uses many more input tokens. Long histories and big documents are what make calls expensive.
usage.pypython
from langchain.chat_models import init_chat_modelmodel = init_chat_model("google_genai:gemini-flash-lite-latest", temperature=0)short = "Name one fruit."long = "Here is some background. " * 50 + "Name one fruit."for name, prompt in [("short", short), ("long", long)]: usage = model.invoke(prompt).usage_metadata print(f"{name}: {usage['input_tokens']} in, {usage['output_tokens']} out")
Some rules of thumb. In English, a token is about three quarters of a word, so a thousand tokens is roughly seven hundred and fifty words. Output tokens usually cost more than input tokens. And every message in the history is sent again, and paid for again, on every call.
Tokens are pieces of text, and you pay for them in and out. Usage metadata tells you exactly how many each call used. Next, switching to a different model provider.