Glossary

LLM Cost per Token

Model APIs sell tokens, not requests. Knowing how input, output, cached and batched tokens are priced is what lets you predict what a chat agent costs per conversation and whether running your own model would be cheaper.

General definition

LLM Cost per Token is how hosted model APIs charge: a rate per million tokens, with separate rates for the tokens you send (input, including the system prompt, the conversation history and any retrieved documents) and the tokens the model generates (output). Output tokens are priced higher than input tokens because generating them is sequential and slower. A token is roughly three quarters of an English word, as explained under tokenization, so a 1,000-word system prompt is about 1,300 tokens on every request that includes it.

  • Input tokens: everything in the prompt, resent on every turn of a conversation
  • Output tokens: the model’s reply, usually priced several times higher than input
  • Cached input tokens: a repeated prefix such as a long system prompt or document set, billed at a reduced rate when prompt caching applies
  • Batch tokens: requests submitted for asynchronous processing within hours, at a discount, for jobs that are not interactive
  • Context size: some providers charge a higher rate once a request exceeds a context threshold

Estimating a chat agent is arithmetic once you know the shape of a conversation. Count the fixed input per turn (system prompt plus retrieved context), the growing history, and a typical reply length; multiply by turns per conversation and conversations per month. In most support and assistant workloads the fixed input dominates, which is why a long system prompt or an oversized retrieval window costs more than the answers do, and why prompt caching and trimming retrieval are the first optimisations. Cheaper models for simple turns, chosen through model routing, are the second.

Self-hosting changes the unit from tokens to hours: a GPU server costs the same whether it is busy or idle. The break-even is a utilisation calculation. Measure the tokens per second a server achieves on your model with batching, work out the tokens it could produce in a month if kept busy, and compare the monthly server cost with what those tokens would cost from an API. At low or spiky volume the API is cheaper; at steady high volume, or when the data may not leave your network at all, self-hosted AI wins. Techniques such as the KV cache and continuous batching raise the throughput side of that equation.

In the Ethora ecosystem

Ethora agents can sit on either side of the calculation. Each agent in the AI SDK has its own model name and the AI service talks to any OpenAI-compatible endpoint, so you can pay per token to a cloud provider for one agent and run another against a model you host, choosing per use case rather than for the whole platform. Per-agent knowledge bases and system prompts mean the fixed input per turn is something you control: a tightly scoped agent costs less per reply than a general one.

The self-hosted route is a documented path, not a diagram. The official Ollama example switches the AI service to a local model with four environment variables, retrieval runs on Postgres with pgvector, and the measured baseline is a 3B model on a 4 vCPU, 8 GB CPU-only virtual machine answering short replies in 6 to 8 seconds: slow for a busy helpdesk, fine for a pilot, and a GPU host moves the throughput side of the break-even. On a dedicated or self-hosted deployment the server cost is the whole model bill, and nothing is priced per token.

Get started

Build AI agents on your own stack

Ethora’s AI SDK brings agents, RAG and self-hosted LLMs into your product. Talk to our team.

Start Free
Free tier available Enterprise SLA No vendor lock-in