Official OpenAI authentication के साथ Astra API setup
Updated 2026-09-05
Documented gpt-6-astra model ID, OpenAI Platform key और official endpoint का उपयोग करें। Account access, request handling और agent verification को स्पष्ट रखें।
Provider और billing account से शुरुआत करें
अपने OpenAI Platform key के साथ OpenAI API से gpt-6-astra उपयोग करें। Application के लिए नीचे दिए Responses example से शुरुआत करें। Local coding work के लिए Codex CLI login और model-selection commands उपयोग करें। दोनों paths आपके Platform account का उपयोग करते हैं और लागू OpenAI rates पर API charges लगाते हैं।
Request चलाने से पहले confirm करें कि Platform project का owner कौन है, उसकी key model access कर सकती है या नहीं और कौन-से billing controls लागू हैं। ChatGPT या Codex में model दिखने से हर API project का access नहीं मिलता। Run notes में subscription login और API-key login अलग रखें। Limit diagnose करने या बाद में charges reconcile करने में यह distinction essential है।

Trusted environment में key और client तैयार करें
OpenAI dashboard में API key बनाएँ और private environment या secret manager के माध्यम से उसे OPENAI_API_KEY के रूप में दें। Official SDK इस variable को पढ़ता है। Key को browser JavaScript, public repository, screenshot या shared terminal transcript में कभी embed न करें। Credentials संभालते समय shell tracing से बचें।
नीचे JavaScript example के लिए अपने project में npm install openai के साथ official openai package install करें। Installed version को lockfile में record करें। Explicit baseURL inherited custom endpoint के बजाय OpenAI चुनता है। Existing agent configuration भी review करें: provider override और किसी दूसरे service का credential केवल इसलिए compatible नहीं हो जाते कि दोनों Authorization header स्वीकार करते हैं।
| Setting | Official direct configuration | चलाने से पहले जाँच |
|---|---|---|
| Credential | OPENAI_API_KEY | Your OpenAI Platform project |
| Base URL | https://api.openai.com/v1 | No unintended provider override |
| Model | gpt-6-astra | Selected key के लिए access |
| Request API | Responses | Client response shape support करता है |
Responses request भेजें और answer पढ़ें
नीचे दिए code के साथ astra-example.mjs बनाएँ, फिर node astra-example.mjs चलाएँ। Prompt छोटी checklist माँगती है, ताकि बड़े workflow से connect करने से पहले returned answer inspect कर सकें। इस first request में automatic SDK retries disabled हैं, जिससे connection या account errors diagnose करना आसान होगा।
जब status completed हो, response.output_text SDK का combined text output रखता है। उसे standard output पर print करें, ताकि दूसरा program consume कर सके या file में redirect किया जा सके। Response metadata को standard error पर भेजें, ताकि answer से अलग रहे। Incomplete responses में incomplete_details और usage सुरक्षित रखें और nonzero exit code लौटाएँ।
import OpenAI from 'openai'
const client = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
baseURL: 'https://api.openai.com/v1',
maxRetries: 0,
})
const response = await client.responses.create({
model: 'gpt-6-astra',
input: 'List three checks for a small code change.',
})
console.error(JSON.stringify({
id: response.id,
model: response.model,
status: response.status,
usage: response.usage,
incomplete_details: response.incomplete_details,
}))
if (response.status === 'completed') {
console.log(response.output_text)
} else {
process.exitCode = 1
}Local Codex के लिए API-key authentication चुनें
OpenAI local Codex work के लिए API-key login document करता है। CLI में credentials बदलने से पहले codex login status inspect करें। नीचे दिया documented stdin command secret को command argument में paste करने से बचाता है। Login के बाद active authentication method फिर check करें और CLI model flag से exact model चुनें।
अंतिम command Astra selected वाली interactive session खोलती है। Project directory से शुरू करें, ताकि agent सही files और repository instructions पढ़ सके। Existing provider overrides review करें और active account confirm करें। API-key mode local work support करता है; Codex cloud के लिए ChatGPT authentication चाहिए। जिस cloud task को local जारी रखना है, उसके लिए पहले working files और remaining work का छोटा summary local project में लाएँ।
codex login status
printenv OPENAI_API_KEY | codex login --with-api-key
codex login status
codex --model gpt-6-astraCapabilities को client path से मिलाएँ
Astra Responses और Chat Completions support करता है, लेकिन tool calling के लिए Responses चाहिए। Functions या custom tools execute करने वाले agent के लिए Responses उपयोग करें। Chat choices पढ़ने वाला client केवल URL बदलने से Responses output parse नहीं कर सकता, और text-only smoke tool loop exercise नहीं करता।
Application के छोटे example से एक-एक capability जोड़ें। Tools के लिए arguments validate करें, application में function चलाएँ और matching call_id के साथ result Responses से लौटाएँ। Structured output में schema validate करें और incomplete responses handle करें। Streaming में completion और cancellation events के साथ text process करें। Features जोड़ते समय simple text request को diagnostic path की तरह उपलब्ध रखें।
Access, rate और completion failures को अलग diagnose करें
Retry करने से पहले HTTP status और structured error fields उपयोग करें। OpenAI error guide invalid authentication, exhausted credits, enforced spend limits और request-rate pressure में अंतर बताती है। विशेष रूप से 429 response अकेले remedy चुनने के लिए पर्याप्त नहीं; error.code और relevant account settings inspect करें।
Temporary rate pressure में Retry-After मौजूद हो तो उसका सम्मान करें और bounded retries रखें। Billing या spend-limit failures को account decision चाहिए, repeated requests नहीं। Incomplete Responses result अलग condition है और tokens consume कर चुका हो सकता है। Redacted error information और usage सुरक्षित रखें; timeout या missing receipt को successful अथवा free attempt न मानें।
| Observable signal | जाँचने योग्य अर्थ | Next action |
|---|---|---|
| HTTP 401 | Authentication या account configuration | Key और project check करें |
| HTTP 429; credit_balance_exhausted | Prepaid credits समाप्त | Platform billing review करें |
| HTTP 429; project_spend_limit_exceeded | Enforced project spend limit | Approved budget review करें |
| HTTP 429; slow_down | Request rate बहुत तेजी से बढ़ी | Requests pace करें; Retry-After मानें |
| status: incomplete | Generation पूरी नहीं हुई | incomplete_details और usage inspect करें |
Provider availability और evidence: 5 सितंबर 2026
OpenAI ने GPT-6 Astra announce किया है और उसका model reference official API document करता है। यहाँ के examples उन्हीं sources follow करते हैं; इस guide के लिए कोई paid request या Codex authentication switch नहीं चलाया गया। 5 सितंबर 2026 की public APIsRouter catalog check में HTTP 200, success: true और 34 models मिले, जिनमें Astra या GPT-6 entry नहीं थी।
ऊपर दिखाए official endpoint के साथ केवल OpenAI credentials उपयोग करें। APIsRouter catalog को उसके अपने offerings के लिए live check करें। बाद में Astra listing आए तो भी application को चाहिए exact model ID, price और client features जाँचने के बाद ही उसे उपयोग करें।
Response को उपयोगी local workflow से जोड़ें
ऐसा local task चुनें जिसका concrete result हो, जैसे function समझाना और test propose करना। Agent को relevant file path, expected behavior और test command दें। Code change के बाद diff inspect करें और focused tests चलाएँ। Original input और returned answer साथ रखें, ताकि revisions आसानी से compare हों।
Application में completed text को review screen या document pipeline में भेजें। अगला step machine-readable data माँगता हो तो structured output उपयोग करें और store करने से पहले required fields validate करें। Request identity और usage को task के साथ रखें तथा bounded retry policy तय करें। Basic input, response handling और completion checks साथ काम करने लगें, तब workflow बढ़ाएँ।
अक्सर पूछे जाने वाले प्रश्न
Astra के लिए कौन-सा model ID उपयोग करूँ?
Official OpenAI model reference में दिए exact नाम gpt-6-astra का उपयोग करें। Selected OpenAI API key को उस model का access भी होना चाहिए।
Example में कौन-सी key चाहिए?
https://api.openai.com/v1 के साथ OPENAI_API_KEY में अपनी OpenAI Platform key उपयोग करें।
क्या API key से local Codex में Astra उपयोग कर सकता हूँ?
हाँ, जब आपकी key को model access हो। CLI API-key command से sign in करें, login status check करें और --model के साथ gpt-6-astra चुनें।
क्या Astra tool calls के लिए Chat Completions उपयोग कर सकता हूँ?
नहीं। Astra Chat Completions support करता है, लेकिन tool calling के लिए Responses चाहिए। Responses-aware client उपयोग करें और function results लौटाते समय call_id सुरक्षित रखें।
क्या Astra APIsRouter से उपलब्ध है?
5 सितंबर 2026 की catalog check में Astra absent था। ये examples official OpenAI access उपयोग करते हैं; APIsRouter offerings के लिए live catalog जाँचें।