A request's price is its input tokens and its output tokens, priced separately
The outdoor shop's support assistant gets 120,000 questions a day, 3.6 million a month. Each request is the same shape as before: 1,800 tokens of instructions and catalog, a 60-token question, and an answer of about 250 tokens.
Running the model on a rented GPU was one way to serve it. Calling a provider's API is the other, and the shop pays by the token. Prices change often, so every price here is dated, and the method is what lasts.
Anthropic lists Claude Sonnet 5.5 at $2 per million input tokens and $10 per million output tokens. OpenAI lists gpt-6.2-sol at the same $2 and $10. A million tokens is written MTok on both price pages.
A request costs its input tokens at the input price plus its output tokens at the output price. request_cost adds the two, and you'll write it in the next step.
# $ per million tokens. The write and read prices are for caching, two steps on.
SONNET = {"input": 2.00, "output": 10.00, "write_5m": 2.50, "write_1h": 4.00, "read": 0.10}
HAIKU = {"input": 0.10, "output": 0.50, "write_5m": 0.125, "write_1h": 0.20, "read": 0.01}
print(f"input ${1860 * SONNET['input'] / 1e6:.5f}, output ${250 * SONNET['output'] / 1e6:.5f}")
print(f"${request_cost(SONNET, 1860, 250):.5f} a request, ${request_cost(SONNET, 1860, 250) * 3_600_000:,.0f} a month")
Output tokens cost 5 times as much as input tokens. Which part of the shop's request costs more?