LLM Context-Window Token Cost & Latency Sizer
LLM requestのcontext window適合性、入力・出力token費用、prefill/decode latency、同時実行sequencesのKV cache memoryを見積もります。価格とthroughputはユーザー入力であり、providerの見積もりやbenchmarkではありません。
結果
context windowの状態
requestあたりの推定費用
30日間の推定token費用
推定prefill + decode時間
sequenceあたりのKV cache
同時実行sequences分のKV cache
context windowの残りtokens
context windowの超過tokens
使い方 ツール
- system promptやtool contextを含むprompt tokens、生成tokens、model context windowを入力します。
- 入力・出力価格(GBP/100万tokens)、1日あたりrequests、実測prefill/decode throughputを入力します。
- KV cacheについてTransformer layers、KV heads、head dimension、elementあたりbytes、同時実行sequences数を入力します。
- context適合性、token費用、直列prefill + decode時間、KV cache容量を確認し、実測serving挙動と比較します。
前提条件
- prompt tokensは全入力contextを含み、output tokensはcontext window適合性とKV cache長の確認に加算します。
- KV cacheは全layerで同じbytes/elementを使う一般的なdense K/V cacheとします。weights、allocator/page-table overhead、quantization metadata、prefix sharing、sliding-window layers、fragmentationは含みません。
- latencyは実測throughputによるprefillと直列decode時間の単純合計です。queueing、batching効果、network、TTFT overhead、speculative decodingは除外します。
- token価格はGBP/100万tokensの固定ユーザー入力です。provider価格feed、税、cache割引、段階料金は含みません。
技術的な詳細:各項目の意味
- requestあたりのprompt tokens
promptTokens - 平均requestの全入力tokensです。system prompt、retrieved context、tool descriptionを含めます。
- requestあたりの生成tokens
outputTokens - requestあたりの平均生成tokensです。
- context window
contextWindowTokens - 選択したdeploymentとconfigurationにおける最大context tokensです。
- 1日あたりのrequests
requestsPerDay - 1日に課金される平均requestsです。月間予測は30日で計算します。
- 入力token 100万個あたりの価格
inputPricePerMillionTokensGbp - providerまたは内部cost modelの入力token価格をGBP/100万tokensで入力します。
- 出力token 100万個あたりの価格
outputPricePerMillionTokensGbp - 生成token価格をGBP/100万tokensで入力します。
- 実測prefill throughput
prefillThroughputTokensPerSecond - modelとdeploymentで実測したprompt prefill throughputです。vendorのpeak値ではありません。
- 実測decode throughput
decodeThroughputTokensPerSecond - 見積もるbatchとserving構成でsequenceあたりに実測したdecode throughputです。
- Transformer layers
modelLayers - KV cache見積もりに使うTransformer layer数です。
- KV heads
kvHeads - query headsではなくkey/value attention headsの数です。model configurationのKV headsを使います。
- head dimension
headDimension - 各attention headのelement数です。
- KV cache elementあたりのbytes
bytesPerElement - KV cache elementあたりのstorage bytesです。FP16/BF16なら2 bytesです。
- 同時実行sequences
concurrentSequences - KV cacheをmemoryに保持する必要がある同時active sequences数です。
方法論
request費用 = (prompt tokens × 入力価格 + output tokens × 出力価格) ÷ 1,000,000。30日費用 = request費用 × requests/日 × 30。推定直列latency = prompt tokens ÷ 実測prefill tokens/s + output tokens ÷ 実測decode tokens/s。sequenceあたりKV cache bytes = 2 (KとV) × layers × KV heads × head dimension × bytes/element × (prompt tokens + output tokens)。同時実行分はsequences数を掛けます。MiB/GiBは1024の累乗です。
計算例
8,192-token context、1日5,000 requests、同時実行8 sequences
入力項目: requestあたりのprompt tokens: 4096 tokens, requestあたりの生成tokens: 1024 tokens, context window: 8192 tokens, 1日あたりのrequests: 5000 requests/day, 入力token 100万個あたりの価格: 2 GBP/1M tokens, 出力token 100万個あたりの価格: 8 GBP/1M tokens, 実測prefill throughput: 800 tokens/s, 実測decode throughput: 60 tokens/s, Transformer layers: 32 layers, KV heads: 8 heads, head dimension: 128 elements, KV cache elementあたりのbytes: 2, 同時実行sequences: 8 sequences
結果: requestは3,072 context tokensを残して収まります。推定費用は£0.01638/request、30日で£2,457.60です。直列prefill + decodeは22.19秒、KV cacheはsequenceあたり640 MiB、8 sequencesで5.00 GiBです。
実用的なアドバイス
- 正確なmodel configurationを使ってください。KV heads、head dimension、layers、cache data typeはvariantやquantization modeで異なります。
- production容量の見積もり前に、実際のserving batch、caching policy、providerでprefill/decode throughputとtoken価格を測定してください。
よくある間違い
- grouped-query attentionでquery headsをKV headsの代わりに使うこと。
- system、retrieval、tool tokensを省き、ユーザーに見えるprompt textだけをcontext windowに数えること。
- KV cache見積もりをmodel VRAM全体とみなすこと。model weightsとruntime overheadは含みません。
よくある質問
providerのlatencyを予測しますか?
いいえ。入力した実測prefill/decode速度を合計するだけで、queueing、batching、network、provider schedulingはモデル化しません。
KV cacheはcontext window全体を使いますか?
いいえ。未使用の残りではなく、各active sequenceのprompt + generated tokensを使います。
最終確認日: 2026-10-18
1つのmodel configurationと平均requestについてのユーザー入力見積もりです。model仕様、価格、provider制限、live serving telemetryを取得しません。
このツール 上記の前提条件に基づく参考値を提示します。
テーマとツールの設定、保存済みリストと最近使用したリストは、このブラウザー内にのみ保存されます。