Create

Sign in to ReadmeX

or

How we handle your data: Privacy Policy

ReadmeX

Your AI reading companion

What would you like to catch up on?

Pick a briefing, or ask your own question.

Your community and people briefings stay personal to you.

Story

How to Read LLM API Token Bills

AI summary

An article explains why total_tokens alone cannot determine LLM API costs and breaks usage into ordinary input, cache-write, cache-read and output tokens. It compares OpenAI-style and Anthropic-style usage fields, noting that OpenAI prompt tokens include cached reads while Anthropic input tokens exclude them, so directly adding all fields can cause double billing. It provides a four-component cost formula and a per-call logging table. The example prices and token-price ratios are illustrative, so reconciliation should use current provider pricing and billing records.

In-depth insight

Separating usage fields and applying provider-specific pricing helps teams understand and control LLM API spending while avoiding double-counted cache charges.

total_tokens 不能拿来算钱。

它把几种单价差好几倍的东西加成了一个数。你拿这个数乘任何单价,结果都没意义——跟把打车费和饭钱加在一起,再问"一共花了多少"一个道理。

一次 API 调用,拆开看是四笔钱:普通输入、缓存写入、缓存读取、输出。前三项是"读",最后一项是"写"。写比读贵,这是整本账的底座。

3008fe4d8eed20c14e00f992be97484f.jpg

一、四笔钱分别是什么

输入是你发给模型的全部内容。你的问题、系统提示词、前几轮对话、贴进去的文档,都算。分词器会把它们切成小块,中文大概 1 个字 1 到 1.5 个 token,英文 1 个词 1.3 个左右。不同模型差别不小,这个数只用来估量级,别拿它对账。

#OpenAI#Anthropic#Langfuse#Helicone

Original · 5 min readRead the original
Group chat

No comments yet. Start the conversation.