Claude API पर पहला अनुरोध: Key, Base URL और जाँच
BetterToken API Key बनाएँ, Anthropic-compatible Messages endpoint पर पहला request भेजें और Workspace में response, token usage व cost verify करें।
यह guide आपको पहले से मौजूद API Key से एक verified Claude-compatible request तक ले जाती है। अगर आप अभी access और billing route चुन रहे हैं, तो पहले Claude API overview देखें; नीचे के steps केवल technical first request पर केंद्रित हैं।
Claude-compatible API connection के लिए तीन अलग चीजें चाहिए: provider account, उस provider की जारी की हुई API Key और protocol के अनुसार endpoint। इस guide में आप BetterToken API Key बनाते हैं। Request Anthropic Messages format इस्तेमाल करती है, लेकिन यह key official Anthropic API Key नहीं है।
1. अपनी BetterToken API Key बनाएँ
- BetterToken Workspace में sign in करें।
- Documentation में बताए Claude-compatible key group के लिए नई API Key बनाएँ।
- Key को एक बार copy करके secret manager या Git से excluded local environment file में सुरक्षित रखें।
- Current Model ID और availability की पुष्टि करने के लिए मौजूदा API documentation और pricing page खोलें।
Key को source code, prompt, screenshot, support message या public repository में paste न करें। BetterToken users अपने account और keys इस्तेमाल करते हैं; service Anthropic Console key जारी नहीं करती और shared Claude.ai account का access नहीं बेचती।
2. Anthropic-compatible endpoint इस्तेमाल करें
Anthropic SDK या Claude Code के लिए BetterToken Base URL है:
इस Base URL में /v1 न जोड़ें। Raw HTTP Messages request के लिए पूरा resource path अलग है:
यह अंतर जरूरी है: SDK resource path खुद जोड़ते हैं, जबकि raw curl command को पूरा URL चाहिए। OpenAI-compatible tools दूसरा Base URL इस्तेमाल करते हैं और उन्हें अपनी setup guide का पालन करना चाहिए।
3. पहला request भेजें
BetterToken key को local environment variable में set करें। Variable का नाम Anthropic SDK convention के अनुसार है, लेकिन उसमें value आपकी BetterToken API Key ही रहती है।
दोनों placeholders को केवल अपनी local shell में replace करें। BetterToken Docs या pricing page से exact current Model ID लें; model names और availability बदल सकते हैं।
4. Response और usage record verify करें
Successful request HTTP 200 और JSON message object लौटाती है। जाँचें:
typeकी valuemessageहो;contentमें model response हो;usageमें input और output token counts हों।
Official Anthropic Messages reference protocol का shape बताती है। यह reference BetterToken की जारी key को Anthropic key नहीं बनाती; यह केवल compatible request और response format को document करती है।
इसके बाद BetterToken Workspace खोलें और request को समय के आधार पर match करें। Model, status, जहाँ लागू हो वहाँ input/output/cache tokens, और संबंधित cost की पुष्टि करें। Workspace usage metadata और billing records के लिए है; यह मानकर न चलें कि वहाँ पूरा prompt या response store होता है।
5. पहले request की आम errors ठीक करें
- 404 या गलत route: raw HTTP में
/v1/messagesचाहिए; केवल/messagesअधूरा है। - 400:
anthropic-version,content-type, Model ID,max_tokensऔरmessagesarray जाँचें। - 401 या 403: BetterToken key, key group, Base URL और accidental whitespace जाँचें। Key support को न भेजें।
- 429: response body पढ़ें, बताए गए delay का पालन करें और retry से पहले concurrent requests तथा current limits जाँचें।
- Workspace record नहीं मिला: पुष्टि करें कि request ने environment में बचे किसी दूसरे provider के बजाय BetterToken Base URL इस्तेमाल किया था।
अगर shell में किसी दूसरे provider की values बची हैं, तो दोबारा शुरू करने से पहले उन्हें साफ करें:
फिर current BetterToken setup information से तीनों values दोबारा set करें और केवल एक request भेजें—retry loop नहीं।
अगला कदम
Minimal request सफल होने के बाद key को application के secret store में रखें, finite timeout set करें और केवल temporary failures के लिए bounded retries जोड़ें। Current BetterToken Docs देखें, फिर पहली वास्तविक integration test करते समय Workspace खुला रखें।