Claude Code और Codex API: प्रोटोकॉल, कॉन्फ़िगरेशन और पहला टेस्ट
Claude Code और Codex के अलग API contracts को छोटे, रिकॉर्ड किए गए टेस्ट से जांचने की हिंदी गाइड।
विषय-सूची
Claude Code और Codex API: प्रोटोकॉल, कॉन्फ़िगरेशन और पहला टेस्ट
केवल “OpenAI-compatible” लिखा होना दोनों clients के लिए एक ही setup का प्रमाण नहीं है। Claude Code, Anthropic Messages contract की अपेक्षा करता है; Codex का custom provider OpenAI Responses का उपयोग करता है। कीमत देखने से पहले tool-specific guide, Base URL, authentication field और वर्तमान Model ID जांचें।
BetterToken पर दोनों रास्तों को आजमाने के लिए पहले वर्तमान Claude Code guide और Codex guide खोलें। दोनों में protocol के अनुसार अलग endpoint हैं और API Key आपके अपने account में बनती है। छोटा request चलाने के बाद Dashboard में status, model, input/output/cache token और charge देखे जा सकते हैं।
दो clients, दो अलग contracts
| Client | क्या सत्यापित करना है | BetterToken पर जांचने वाला मान |
|---|---|---|
| Claude Code | Anthropic-compatible Messages access और documented authentication variables | https://bettertoken.ai; Claude Code स्वयं /v1/messages जोड़ता है |
| Codex CLI/App | Chat Completions भर नहीं, Responses वाला custom provider | https://www.bettertoken.ai/v1 तथा wire_api = "responses" |
Claude Code की वर्तमान guide में ANTHROPIC_BASE_URL और ANTHROPIC_AUTH_TOKEN हैं। Base URL में /v1 न जोड़ें, क्योंकि Messages path client जोड़ता है। Codex provider को ~/.codex/config.toml से और key को BETTERTOKEN_API_KEY से पढ़ता है।
Client behavior के लिए OpenAI Codex configuration reference और Claude Code documentation प्राथमिक स्रोत हैं। Provider-specific values को उसके वर्तमान official guide में फिर से जांचना जरूरी है।
न्यूनतम configuration जांच
Codex शुरू करने से पहले Responses pattern की जांच करें:
model_provider = "custom"
model = "YOUR_MODEL_ID"
[model_providers.custom]
base_url = "https://www.bettertoken.ai/v1"
env_key = "BETTERTOKEN_API_KEY"
wire_api = "responses"
requires_openai_auth = false
YOUR_MODEL_ID जानबूझकर placeholder है। Model availability और IDs बदल सकते हैं, इसलिए setup dialog या model catalog से पूरा, वर्तमान ID कॉपी करें; पुराना लेख इस्तेमाल न करें। Custom-provider key को ~/.codex/auth.json में न रखें।
Claude Code में Codex table को दोहराने के बजाय ये protocol variables जांचें:
{
"env": {
"ANTHROPIC_BASE_URL": "https://bettertoken.ai",
"ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY"
}
}
File location और optional fields के लिए current Claude Code guide का पालन करें। API Key को prompt, issue, screenshot या repository में कभी न लिखें।
असली workload से पहले छोटा टेस्ट
- जिस exact client version को चलाना है उसकी current guide खोलें।
- साझा account नहीं, अपना अलग test API Key बनाएं।
- Documentation या Dashboard से Base URL और current Model ID कॉपी करें।
- Claude Code में route और authentication variables जांचें; Codex में provider, environment variable और
wire_api = "responses"जांचें। - Production secrets के बिना खाली या disposable repository से शुरुआत करें।
- छोटा, सीमित task भेजें और केवल config file स्वीकार होने को सफलता न मानें।
- Dashboard में request status, resolved model, input/output/cache token, दिखने वाले retries और final charge रिकॉर्ड करें। फिर समान conditions में एक representative task दोहराएं।
यह क्रम पहले request को diagnostic बनाता है। गलत route, पुराना Model ID और लागत के अंतर को एक ही तुलना में मिलाने से बचता है।
लागत की तुलना और पहली त्रुटि
सिर्फ input-token price किसी agent task की लागत नहीं बताता। Project context, tool output, cache, retries और output length कुल charge बदलते हैं। हर candidate के लिए एक जैसे task पर Model ID, input/output/cache tokens, request count, errors, retries और final charge लिखें। BetterToken के बदलते model और price के लिए current pricing page देखें; पुरानी review के आंकड़े केवल historical हैं।
| लक्षण | पहले क्या जांचें |
|---|---|
401 | Key, documented field और चिपके हुए spaces |
404 / connection failure | सही protocol की Base URL; ऐसा पूरा HTTP path नहीं जो client खुद जोड़ता हो |
model not found | उसी provider और key group का पूरा current Model ID |
| Codex API-mode error | wire_api = "responses"; केवल Chat Completions पर्याप्त नहीं है |
429 | Endpoint limit, Retry-After और request को सुरक्षित रूप से retry किया जा सकता है या नहीं |
| Streaming रुकना | उस protocol की streaming support, network और request status |
| अस्पष्ट charge | Model, token records और usage history में retries |
हर टेस्ट में सिर्फ एक parameter बदलें। तभी URL, key, model या client configuration में वास्तविक कारण अलग दिखेगा।
रिकॉर्ड किए गए टेस्ट से फैसला लें
यह speed, stability या lowest-price ranking नहीं है। यह दो अलग client contracts को सत्यापित करने की विधि है। टेस्ट वाले दिन current documentation फिर पढ़ें, वही repository task चलाएं और configuration result, errors, token record तथा final charge के आधार पर निर्णय लें।
Production work से पहले BetterToken का Claude Code guide या Codex guide खोलें, अलग API Key बनाएं और पहले request को Dashboard में सत्यापित करें।