Claude Opus 4.7 की API कीमत ऊपर से बहुत सीधी दिखती है: input के लिए $5 और output के लिए $25 प्रति 10 लाख tokens। लेकिन असली बिल तभी सही निकलेगा जब आप input, output, prompt cache write और cache read को अलग-अलग गिनेंगे। Anthropic के अनुसार developers Claude API में model ID claude-opus-4-7 इस्तेमाल कर सकते हैं; CloudPrice और Price Per Token जैसे third-party pricing indexes भी $5 input / $25 output प्रति million tokens का शुरुआती स्तर दिखाते हैं। अगर आप Anthropic API के बजाय किसी अन्य platform या provider से access कर रहे हैं, तो अंतिम bill के लिए उसी provider की billing देखें।[7][
9][
19][
21]
यहां MTok का मतलब है 1,000,000 यानी 10 लाख tokens।
कीमत की परतें: सिर्फ $5 और $25 नहीं
Anthropic की pricing docs में Base Input Tokens, Cache Writes, Cache Hits और Output Tokens अलग-अलग columns में दिए गए हैं। इसलिए cost model भी इन्हें अलग-अलग रखकर बनाना चाहिए।[19]
| खर्च का हिस्सा | दर | कैसे समझें |
|---|---|---|
| Base input tokens | $5 / MTok | सामान्य input tokens, जिन्हें cache write/read के रूप में नहीं गिना गया है।[ |
| Output tokens | $25 / MTok | Claude के जवाब में generated tokens।[ |
| Prompt cache write, 5 मिनट TTL | $6.25 / MTok | reusable prompt cache पहली बार लिखने पर, 5 मिनट TTL के साथ।[ |
| Prompt cache write, 1 घंटा TTL | $10 / MTok | reusable prompt cache पहली बार लिखने पर, 1 घंटे TTL के साथ।[ |
| Cache read / hit | $0.50 / MTok | पहले से cached content पढ़ने यानी cache hit पर।[ |
सीधा निष्कर्ष: total tokens को एक average rate से multiply करना सुरक्षित तरीका नहीं है। अगर आपकी app में prompt caching है, तो input, output, cache write और cache read को अलग-अलग line items की तरह रखें।[19]
लागत का सूत्र: पहले तय करें cache है या नहीं
1. Prompt caching नहीं है
Basic formula:
cost = input_tokens ÷ 10,00,000 × 5 + output_tokens ÷ 10,00,000 × 25
उदाहरण के लिए, किसी request में 2,00,000 input tokens और 20,000 output tokens हैं, तो बिना cache के खर्च होगा: $1.00 + $0.50 = $1.5019]
2. Prompt caching चालू है
Cache के साथ formula को थोड़ा विस्तार देना होगा:
cost = base_input_tokens ÷ 10,00,000 × 5 + output_tokens ÷ 10,00,000 × 25 + cache_write_5m_tokens ÷ 10,00,000 × 6.25 + cache_write_1h_tokens ÷ 10,00,000 × 10 + cache_read_input_tokens ÷ 10,00,000 × 0.50
अगर आप सिर्फ 5 मिनट या सिर्फ 1 घंटे वाली TTL इस्तेमाल कर रहे हैं, तो उसी cache write component को रखें। Anthropic के streaming examples में usage के अंदर input_tokens, output_tokens, cache_creation_input_tokens और cache_read_input_tokens जैसे fields दिखते हैं; pricing docs भी cache write और cache hit को अलग-अलग rate देती हैं।[15][
19]
Token कैसे गिनें: शब्दों या अक्षरों से अनुमान न लगाएं
API cost का अनुमान लगाने के लिए Hindi/English शब्दों की गिनती या character count पर भरोसा न करें। Anthropic का /v1/messages/count_tokens endpoint message भेजने से पहले token count निकालने के लिए बना है। Documentation के अनुसार यह Messages API जैसी structured input स्वीकार करता है, जिसमें system prompts, tools, images और PDFs तक शामिल हो सकते हैं, और response में total input tokens देता है। सभी active models token counting support करते हैं।[18]
व्यावहारिक तरीका यह है: जो payload असल में Messages API को भेजना है, वही payload पहले count_tokens को भेजें। इसमें system prompt, user/assistant messages, tool definitions, images या PDF blocks सब शामिल करें। इससे model call करने से पहले input token cost का बेहतर अंदाजा मिलता है और product में budget limit या warning लगाना आसान होता है।[18]
Request के बाद: असली हिसाब usage से करें
Request complete होने के बाद output text की length देखकर अनुमान लगाने के बजाय response के usage fields log करें। Anthropic के Messages API examples में response usage के अंदर input_tokens और output_tokens जैसे fields दिखते हैं; streaming docs cache-related fields जैसे cache_creation_input_tokens और cache_read_input_tokens भी दिखाती हैं।[15][
17]
Streaming इस्तेमाल कर रहे हैं तो एक आम गलती से बचें: Anthropic docs के अनुसार message_delta event में आने वाले usage token counts cumulative होते हैं, यानी हर event का नया increment नहीं। अगर आप हर delta को जोड़ते चले गए, तो वही tokens बार-बार count हो सकते हैं।[15]
Team billing और month-end reconciliation
Per-request logs real-time monitoring के लिए अच्छे हैं, लेकिन team billing, workspace-level split या लंबे समय की cost analysis के लिए Anthropic का Usage & Cost Admin API ज्यादा उपयुक्त है। Official docs के अनुसार यह API organization के historical API usage और cost data तक programmatic, granular access देता है, और usage report को model, workspace तथा service tier जैसे dimensions से तोड़ा जा सकता है।[16]
इसका practical अर्थ है: app-side logs से per-request guardrails और alerts बनाएं, लेकिन official reconciliation के लिए Usage & Cost Admin API के historical usage/cost data को आधार बनाएं।[16]
Opus 4.7 पर upgrade करने से पहले token budget दोबारा चलाएं
Opus 4.7 में नया tokenizer आया है। Anthropic docs के अनुसार text processing में यह previous models की तुलना में लगभग 1x से 1.35x tokens इस्तेमाल कर सकता है, यानी content के हिसाब से लगभग 35% तक अधिक tokens; इसी वजह से /v1/messages/count_tokens Opus 4.7 और Opus 4.6 के लिए अलग token numbers लौटा सकता है।[20]
इसलिए $5 input और $25 output प्रति MTok की sticker price वही दिखने पर भी आपका वास्तविक bill वैसा ही रहेगा, यह मान लेना ठीक नहीं। अगर आप Opus 4.6 या उससे पुराने Claude model से Opus 4.7 पर जा रहे हैं, तो high-traffic prompts, लंबे context वाले workflows, tool definitions वाले payloads और सबसे महंगे production flows को फिर से /v1/messages/count_tokens पर चलाएं। इसके बाद alerts, rate limits और cost caps update करें।[18][
20]
Quick checklist
- API में model ID
claude-opus-4-7ही इस्तेमाल हो रहा है, यह confirm करें।[9]
- Release से पहले representative payloads पर
/v1/messages/count_tokensचलाएं।[18]
input_tokens,output_tokens, cache write और cache read को अलग-अलग store करें; सिर्फ total token count न रखें।[15][
19]
- Streaming में
message_delta.usagecumulative है, इसलिए हर event को जोड़कर double-counting न करें।[15]
- Team billing, workspace split और historical cost trend के लिए Usage & Cost Admin API देखें।[
16]
- Opus 4.7 पर migration से पहले नए tokenizer का असर अपने real prompts पर test करें।[
20]
संक्षेप में: Claude Opus 4.7 की basic API rate याद रखना आसान है—input $5/MTok और output $25/MTok। लेकिन सही बिलिंग के लिए request से पहले count_tokens, request के बाद usage, और cost model में prompt caching व नए tokenizer—तीनों को साथ रखना जरूरी है।[18][
19][
20]




