Skip to content
Chapter 2 of 10 · Token economicsToken cost of a single request

Chapter 2 of 10

Token cost of a single request

Cost per request is prompt tokens times the input price plus completion tokens times the output price, and the two terms are obtained differently: the prompt is a string you hold, so its token count is a measurement, while the completion does not exist yet and can only be bounded by a maximum output setting. This chapter works the arithmetic, gives the price grid for prompt and completion sizes you are likely to send, and shows how to choose a cap from a logged distribution, handle truncation, and avoid the retry configuration that costs more than no cap at all.

Token economics — read the current version at https://daviddominguez.dev/learn/en/token-economics/token-cost

Back to top