BazaarLinkBazaarLink
साइन इन
दस्तावेज़API संदर्भSDK संदर्भएजेंटिक उपयोगAI स्किल्स
विषय-सूची

Responses API

Responses API

An OpenAI प्रतिक्रियाएँ API-स्टेटलेस मल्टी-टर्न वार्तालाप, टूल कॉलिंग और मल्टीमॉडल इनपुट के लिए संगत समापन बिंदु। एजेंटों और फ्रेमवर्क के लिए आदर्श जो client.responses.create() के साथ OpenAI Python SDK ≥ 1.x का उपयोग करते हैं।

POST/v1/responses
Note
Chat Completions के समान प्रमाणीकरण और मॉडल रूटिंग को स्वीकार करता है।

अनुरोध बॉडी

modelआवश्यक
string
GET /v1/models में सूचीबद्ध id या alias इस्तेमाल करें, जैसे "claude-sonnet-4.6" या "anthropic/claude-sonnet-4.6"।
inputआवश्यक
string | Item[]
User इनपुट - एक सादा स्ट्रिंग (एकल संदेश) या मल्टी-टर्न / मल्टीमॉडल वार्तालापों के लिए इनपुट आइटम की एक सरणी।
instructions
string
सिस्टम-स्तरीय निर्देश, सिस्टम संदेश के समतुल्य। प्रत्येक अनुरोध पर पुनः भेजा जाना चाहिए।
stream
boolean
यदि सत्य है, तो प्रतिक्रियाएँ API SSE स्ट्रीम इवेंट लौटाता है। इवेंट प्रकार: प्रतिक्रिया.निर्मित, प्रतिक्रिया.आउटपुट_टेक्स्ट.डेल्टा, प्रतिक्रिया.पूर्ण।
max_output_tokens
integer
उत्पन्न करने के लिए आउटपुट टोकन की अधिकतम संख्या (ओ-श्रृंखला मॉडल के लिए तर्क टोकन शामिल हैं)।
temperature
number
Sampling मान बिना range validation के भेजे जाते हैं। Model समर्थित सीमा से बाहर के मानों को सीमित या अनदेखा कर सकता है।
top_p
number
न्यूक्लियस नमूना संभाव्यता द्रव्यमान। डिफ़ॉल्ट: 1
tools
Tool[]
टूल (फ़ंक्शन) परिभाषाएँ — Chat Completions जैसा ही JSON Schema प्रारूप (फ़्लैट Responses रूप और नेस्टेड रूप दोनों स्वीकार्य)। OpenAI के अपने अंतर्निहित होस्टेड टूल (web_search_preview, file_search, computer_use_preview) समर्थित नहीं हैं; वेब सर्च plugins: [{id:"web"}] से उपलब्ध है — केवल कुछ मॉडल रूट पर समर्थित।
tool_choice
string | object
कंट्रोल्स टूल का उपयोग: "ऑटो", "कोई नहीं", या विशिष्ट टूल
parallel_tool_calls
boolean
उपकरण उपलब्ध कराए जाने पर समानांतर फ़ंक्शन कॉलिंग सक्षम करें। डिफ़ॉल्ट: सत्य. केवल OpenAI-पारिवारिक मॉडल - नीचे नोट देखें।
response_format
object
Force संरचित JSON आउटपुट। संरचित आउटपुट अनुभाग देखें
previous_response_id
string
यह एंडपॉइंट स्टेटलेस है — गैर-null मान भेजने पर तुरंत 400 (invalid_prompt) लौटता है, यह कभी स्वीकार होकर अनदेखा नहीं होता। इसके बजाय स्टेटलेस मोड का उपयोग करें: input सरणी में पूरा बातचीत इतिहास भेजें।

अनुरोध स्कीमा (TypeScript)

type ResponsesRequest = {
  model: string;                    // Listed id or alias from GET /v1/models
  input: string | InputItem[];      // string or multi-turn array

  // Optional
  instructions?: string;            // System-level message
  stream?: boolean;                 // Default: false
  max_output_tokens?: number;
  temperature?: number;
  top_p?: number;
  tools?: Tool[];
  tool_choice?: "auto" | "none" | "required" | object;
  parallel_tool_calls?: boolean;    // Default: true
  previous_response_id?: string;    // Not supported — use full input array
};

type InputItem =
  | { type?: "message"; role: "user" | "assistant" | "system" | "developer"; content: string | ContentBlock[] }
  | { type: "function_call_output"; call_id: string; output: string }   // tool result
  | { type: "function_call"; call_id: string; name: string; arguments: string };

type ContentBlock =
  | { type: "input_text"; text: string }
  | { type: "input_image"; image_url: string; detail?: "auto" | "low" | "high" };

उदाहरण अनुरोध

curl https://api.bazaarlink.ai/v1/responses \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5.4-mini",
    "instructions": "You are a helpful assistant.",
    "input": "What is the capital of Taiwan?"
  }'

प्रतिक्रिया प्रारूप

BazaarLink मानकीकृत response लौटाता है और upstream-विशिष्ट फ़ील्ड हटा देता है। response में अपारदर्शी BazaarLink request ID x-request-id के समान होता है; इसे GET /v1/generation के साथ उपयोग करें। non-streaming response में वही ID x-generation-id में भी आता है। usage.cost ग्राहक से वसूली गई USD राशि है। आँकड़े पूरा होने के कुछ सेकंड बाद मिल सकते हैं; 404 पर थोड़ी देर retry करें।

// Non-streaming response object
type ResponsesResponse = {
  id: string;             // Opaque BazaarLink request id; format may change
  object: "response";
  created_at: number;
  completed_at: number;
  status: "completed" | "failed" | "incomplete";
  model: string;
  output: OutputItem[];
  usage: {
    input_tokens: number;   // equivalent to prompt_tokens
    output_tokens: number;  // equivalent to completion_tokens
    total_tokens: number;
    cost?: number;          // USD amount charged to the customer for this request
  } | null;
  error: null | { code: string; message: string };
};

type OutputItem =
  | {
      type: "message";
      id: string;
      role: "assistant";
      status: "completed";
      content: Array<{ type: "output_text"; text: string; annotations: [] }>;
    }
  | { type: "function_call"; id: string; call_id: string; name: string; arguments: string; status: "completed" };

Chat Completions से माइग्रेट हो रहा है

संदेशों को इनपुट (स्ट्रिंग या ऐरे) से बदलें, सिस्टम-रोल संदेश के बजाय निर्देशों का उपयोग करें, और विकल्पों[0].message.content के बजाय आउटपुट[0].content[0].text पढ़ें।

# Chat Completions (before)
response = client.chat.completions.create(
    model="openai/gpt-5.4-mini",
    messages=[
        {"role": "system", "content": "You are helpful."},
        {"role": "user",   "content": "Hello"},
    ]
)
text = response.choices[0].message.content

# Responses API (after)
response = client.responses.create(
    model="openai/gpt-5.4-mini",
    instructions="You are helpful.",
    input="Hello"
)
text = response.output[0].content[0].text

सीमाएँ

  • previous_response_id या store: true को 400 (त्रुटि कोड invalid_prompt) के साथ अस्वीकार किया जाता है — स्वीकार होकर अनदेखा नहीं होता। हमेशा स्टेटलेस मोड का उपयोग करें: input सरणी में पूरा बातचीत इतिहास भेजें।
  • OpenAI के अपने अंतर्निहित होस्टेड टूल (web_search_preview, file_search, computer_use_preview) समर्थित नहीं हैं। वेब सर्च plugins: [{id:"web"}] से उपलब्ध है — केवल कुछ मॉडल रूट पर समर्थित।
  • background: true स्वीकार किया जाता है लेकिन अनदेखा कर दिया जाता है — हर अनुरोध पूरा होने तक सिंक्रोनस रूप से चलता है।
Support
Hi! How can we help you?
Send a message and we'll get back to you soon.
Responses API | BazaarLink