आमंत्रित करें और कमाएँ

आमंत्रण पुरस्कार कैसे काम करते हैं

अपना आमंत्रण लिंक साझा करें। मित्र इसके माध्यम से पंजीकरण करके टॉप-अप करता है तो उसके बाद के टॉप-अप पर आपको दिखाया गया पुरस्कार मिलेगा।

Claude Opus 5.5 API: पहला request और 400 errors ठीक करें

BetterToken API Key बनाकर Claude Opus 5.5 को minimal request भेजें और Model ID, max_tokens, thinking तथा tool_choice से जुड़े 400 errors को क्रम से ठीक करें।

विषय-सूची

सही API Key होने पर भी Claude Opus 5.5 की पहली call 400 Bad Request दे सकती है। Exact Model ID, Messages API के ज़रूरी fields जैसे max_tokens, thinking settings और tool_choice जाँचें। max_tokens का न होना Messages का सामान्य validation error है, Opus 5.5 की नई पाबंदी नहीं; model-specific migration में thinking और forced tool choice के नियम बदलते हैं।

यह guide पहले एक minimal request देती है, फिर 400 errors को क्रम से जाँचती है। ज़रूरी fields के लिए Messages API reference और Opus 5.5 के खास बदलावों के लिए Anthropic migration guide देखें। Current connection और model route जाँचने के लिए minimal request एक बार चलाएँ; fail होने पर returned error body के अनुसार checks करें। BetterToken के जरिए claude-opus-5-5 चलाने से पहले publishing या deployment के दिन exact Model ID को current catalog में जाँचें।

1. पहले API Key, Base URL और Model ID की पुष्टि करें

पहली request के लिए केवल तीन values चाहिए: आपकी अपनी BetterToken API Key, Anthropic-compatible Base URL और उस समय उपलब्ध Model ID।

  1. BetterToken Workspace में sign in करके अपने account में API Key बनाएँ। इसे secret manager या local environment file में रखें; Git या support message में न डालें।
  2. Current model और pricing catalog खोलकर exact ID claude-opus-5-5 की availability देखें। Anthropic इसे बिना date suffix वाली fixed Model ID बताता है, लेकिन BetterToken availability और price dynamic हैं।
  3. Key को application code में hard-code करने के बजाय environment variable से दें।

API Key बनाने के लिए आपका अपना BetterToken account होना चाहिए। BetterToken account बनाएँ

Interface वाले steps के लिए BetterToken Quickstart देखें।

2. Base URL में /v1 न जोड़ें, पर direct HTTP path में रखें

Anthropic SDK के लिए Base URL https://bettertoken.ai है; direct Messages request के लिए पूरी URL https://www.bettertoken.ai/v1/messages है।

https://bettertoken.ai

/messages को Base URL न बनाएँ, और जब SDK resource path खुद जोड़ता हो तो /v1/messages दोबारा न जोड़ें। Current shell में तीन values set करें:

read -rs ANTHROPIC_API_KEY && export ANTHROPIC_API_KEY
export ANTHROPIC_BASE_URL="https://bettertoken.ai"
export CLAUDE_MODEL_ID="claude-opus-5-5"

पहली पंक्ति को अलग से चलाएँ। Terminal छिपे हुए input का इंतज़ार करेगा: उस समय API Key टाइप या paste करें और Enter दबाएँ; कोई character दिखाई नहीं देगा। Key केवल current shell में export होती है, जबकि history में secret नहीं, सिर्फ read command रहती है। Key को command line के साथ न जोड़ें।

claude-opus-5-5 वह Model ID है जिसे Anthropic Claude Platform के लिए document करता है। अगर current BetterToken catalog में यही exact ID नहीं दिखती, तो alias अनुमान लगाने के बजाय availability verify करें।

3. पहले सबसे छोटी उपयोगी request भेजें

पहले test में tools, tool_choice और thinking न भेजें, ताकि advanced options किसी basic connection problem को न छिपाएँ।

curl --fail-with-body "$ANTHROPIC_BASE_URL/v1/messages" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d "{
    \"model\": \"$CLAUDE_MODEL_ID\",
    \"max_tokens\": 4096,
    \"messages\": [
      {\"role\": \"user\", \"content\": \"केवल यह जवाब दें: pong\"}
    ]
  }"

इस request में exact Model ID है, positive max_tokens है, thinking नहीं है और tool call force नहीं की गई है। इस example में max_tokens को 4096 रखा गया है—Anthropic migration example में भी यही value है—ताकि adaptive thinking और छोटा reply दोनों के लिए अधिक जगह रहे। इसे diagnostic starting point मानें, tested guarantee या production recommendation नहीं; production में expected response, effort, cost और latency के अनुसार value चुनें।

--fail-with-body HTTP 4xx या 5xx पर response body को बचाए रखता है। Logs share करने से पहले API Key, पूरा Prompt, model output और अन्य sensitive fields हटा दें।

4. यह न मानें कि content[0] हमेशा text होगा

HTTP 200 और top-level type का message होना बताता है कि endpoint ने request स्वीकार करके process की। इस short-answer test में text block मिलना content generation पूरा होने की पुष्टि करता है। adaptive thinking और response text एक ही max_tokens share करते हैं, इसलिए valid response text आने से पहले limit तक पहुँच सकता है।

इन संकेतों की जाँच करें:

  • top-level type का value message हो और model requested model से मिले;
  • short test सामान्य रूप से पूरा हो तो stop_reason end_turn हो और content array में कम से कम एक block का type text हो;
  • अगर stop_reason max_tokens है, response valid है लेकिन truncate हुई है: max_tokens बढ़ाकर retry करें; यदि high effort explicitly set है और deep reasoning जरूरी नहीं है, तो effort घटा सकते हैं;
  • अगर text block नहीं है और stop_reason max_tokens भी नहीं है, तो Key या Base URL बदलने से पहले पूरा response सुरक्षित रखें और उस stop reason की जाँच करें; केवल text न होना connection failure का प्रमाण नहीं है;
  • parser हर block को type से चुने, हमेशा content[0].text न पढ़े;
  • usage में input और output Token counts हों;
  • BetterToken Dashboard में expected time पर model, status, input/output/cache Token और charge वाला record दिखे।

Official Anthropic Messages API reference response structure बताती है, और stop_reason guide truncated responses संभालने का तरीका बताती है। Dashboard request और usage record मिलाने में उपयोगी है; इसे पूरे prompt या response के guaranteed storage की तरह न बताएँ।

5. Messages के सामान्य errors और Opus 5.5 के बदलाव जाँचें

Request अभी भी पुराना model name इस्तेमाल करती है

पुराने ID या अनुमानित dated alias को claude-opus-5-5 से बदलें। Anthropic इसे बिना date suffix वाली fixed ID बताता है। Cloud platforms अपने IDs इस्तेमाल कर सकते हैं; इस BetterToken Anthropic-compatible example में current BetterToken catalog वाला exact ID इस्तेमाल होना चाहिए।

max_tokens नहीं दिया गया

हर Messages request में positive max_tokens दें। Field का न होना Messages API का सामान्य validation error है, Opus 5.5 migration का नया बदलाव नहीं। यह total output की hard limit है, जिसमें thinking और final text दोनों आते हैं। Smoke test में भी दोनों के लिए पर्याप्त जगह चाहिए; अगर stop_reason max_tokens है, तो call को connection failure न मानें—limit बढ़ाकर retry करें।

Payload thinking बंद करती है या manual budget देती है

सबसे आसान fix है पूरा thinking field हटा देना। Opus 5.5 हमेशा adaptive thinking चलाता है। Anthropic migration guide इन दोनों पुराने forms को 400 के साथ rejected बताती है:

{"thinking": {"type": "disabled"}}
{"thinking": {"type": "enabled", "budget_tokens": 10000}}

Field explicitly देना हो तो {"thinking": {"type": "adaptive"}} इस्तेमाल करें। Reasoning depth को output_config.effort से control करें; supported levels low, medium, high, xhigh और max हैं, default medium है। Minimal connectivity request में इन fields की जरूरत नहीं है।

Payload tool_choice force करती है

tool_choice के लिए केवल {"type": "auto"} या {"type": "none"} इस्तेमाल करें। Opus 5.5 {"type": "any"} और {"type": "tool", "name": "..."} को reject करता है। Tool workflow में model को auto पर चुनने दें, Prompt में बताएँ कि tool कब इस्तेमाल हो, और strict tool use enable करने से पहले हर schema validate करें।

6. दूसरे status codes में configuration बदलने से पहले body पढ़ें

Statusपहले क्या जाँचेंक्या न करें
400Valid JSON; model, max_tokens, messages, thinking settings और tool_choiceKey को बिना कारण बदलना या वही invalid payload बार-बार भेजना
401 / 403पूरी Key, सही account या key group और सही Base URLपूरी Key support को भेजना
404Direct HTTP call में /v1/messages होना चाहिए/messages को complete route मानना
429Response का wait instruction, balance, limits और request historyबिना pause के loop में retry करना

दूसरे provider की पुरानी variables को दोबारा setup करने से पहले साफ करें:

unset ANTHROPIC_API_KEY
unset ANTHROPIC_BASE_URL
unset CLAUDE_MODEL_ID

एक fix के बाद वही minimal request दोहराएँ। Model, endpoint, Prompt और advanced parameters एक साथ बदलेंगे तो यह पता लगाना मुश्किल होगा कि problem किस बदलाव से सुलझी।

7. Anthropic list price और BetterToken current price अलग रखें

Anthropic की 22 सितंबर 2026 launch page ने Claude Platform के लिए प्रति million Input Token $4, Output Token $20, cache reads $0.20 और cache writes $5 बताया था। ये Anthropic के publicly listed launch-time platform prices हैं। BetterToken pricing dynamic है, इसलिए current pricing page देखें और अपनी एक छोटी request को Dashboard record से खुद verify करें।

Thinking Token को Output Token की तरह bill किया जाता है, और max_tokens में thinking plus final text दोनों आते हैं। इसलिए किसी ऐसे workload का output-token profile बदल सकता है जो पहले thinking बंद करता था, भले Prompt वही रहे। Production से पहले current BetterToken pricing page देखें और एक छोटी request को Dashboard record से मिलाएँ।

SDK, streaming या production traffic पर जाने से पहले Model ID फिर जाँचें, Key को source code से बाहर रखें, max_tokens सही size करें, content को block type से parse करें, forced tool choice से बचें और diagnosis के लिए redacted error body रखें। आगे BetterToken API Reference और official Opus 5.5 migration guide देखें।

अपना LLM वर्कफ़्लो बेहतर बनाना चाहते हैं?

एक API से मॉडल जोड़ें, कुंजियाँ प्रबंधित करें और AI खर्च नियंत्रित करें।

मुफ़्त शुरू करें