> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sunra.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a response

OpenAI Responses API प्रारूप का उपयोग करके स्ट्रीमिंग या नॉन-स्ट्रीमिंग प्रतिक्रिया बनाता है।

## प्रमाणीकरण

<ParamField header="Authorization" type="string" required>
  Bearer टोकन। Authorization हेडर में अपनी API कुंजी को bearer टोकन के रूप में उपयोग करें।

  प्रारूप: `Bearer <SUNRA_KEY>`
</ParamField>

## अनुरोध

यह एंडपॉइंट एक ऑब्जेक्ट स्वीकार करता है।

<ParamField body="model" type="string" required>
  प्रतिक्रिया उत्पन्न करने के लिए उपयोग किया जाने वाला मॉडल ID। उपलब्ध मॉडल [sunra.ai/models](https://sunra.ai/models) पर देखें।
</ParamField>

<ParamField body="input" type="string | object[]">
  प्रतिक्रिया अनुरोध के लिए इनपुट। एक स्ट्रिंग या इनपुट आइटम की एक सरणी हो सकती है।

  <Expandable title="properties (when array)">
    <ParamField body="type" type="string">
      इनपुट आइटम का प्रकार। समर्थित मान: `message`, `item_reference`।
    </ParamField>

    <ParamField body="role" type="string">
      संदेश लेखक की भूमिका। समर्थित मान: `user`, `assistant`, `system`।
    </ParamField>

    <ParamField body="content" type="string | object[]">
      इनपुट संदेश की सामग्री। एक स्ट्रिंग या सामग्री भागों की सरणी हो सकती है।
    </ParamField>

    <ParamField body="id" type="string">
      आइटम का ID। वार्तालाप इतिहास में `assistant` संदेशों के लिए आवश्यक।
    </ParamField>

    <ParamField body="status" type="string">
      आइटम की स्थिति। वार्तालाप इतिहास में `assistant` संदेशों के लिए आवश्यक।
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="instructions" type="string | null">
  मॉडल के संदर्भ में पहले आइटम के रूप में एक सिस्टम (या डेवलपर) संदेश सम्मिलित करता है। `input` के साथ उपयोग करने पर, निर्देश इनपुट की शुरुआत में डाले जाते हैं।
</ParamField>

<ParamField body="stream" type="boolean" default={false}>
  यदि `true` पर सेट किया जाता है, तो प्रतिक्रिया server-sent events (SSE) का उपयोग करके स्ट्रीम की जाएगी।
</ParamField>

<ParamField body="max_output_tokens" type="integer">
  आउटपुट टोकन की संख्या के लिए एक ऊपरी सीमा, जिसमें दृश्य आउटपुट टोकन और तर्क टोकन शामिल हैं।
</ParamField>

<ParamField body="temperature" type="number" default={1}>
  0 और 2 के बीच सैंपलिंग तापमान। उच्च मान यादृच्छिकता बढ़ाते हैं।
</ParamField>

<ParamField body="top_p" type="number" default={1}>
  न्यूक्लियस सैंपलिंग पैरामीटर। तापमान के साथ सैंपलिंग का एक विकल्प।
</ParamField>

<ParamField body="frequency_penalty" type="number" default={0}>
  -2.0 और 2.0 के बीच की संख्या। सकारात्मक मान नए टोकन को पाठ में उनकी मौजूदा आवृत्ति के आधार पर दंडित करते हैं।
</ParamField>

<ParamField body="presence_penalty" type="number" default={0}>
  -2.0 और 2.0 के बीच की संख्या। सकारात्मक मान नए टोकन को इस आधार पर दंडित करते हैं कि वे पहले से पाठ में दिखाई दिए हैं या नहीं।
</ParamField>

<ParamField body="tools" type="object[]">
  उन टूल की सरणी जिन्हें मॉडल कॉल कर सकता है।

  <Expandable title="properties">
    <ParamField body="type" type="string" required>
      टूल का प्रकार। समर्थित मान: `function`, `web_search_preview`।
    </ParamField>

    <ParamField body="name" type="string">
      फ़ंक्शन का नाम। type `function` होने पर आवश्यक।
    </ParamField>

    <ParamField body="description" type="string">
      फ़ंक्शन का विवरण।
    </ParamField>

    <ParamField body="parameters" type="object">
      फ़ंक्शन पैरामीटर को परिभाषित करने वाला JSON Schema ऑब्जेक्ट।
    </ParamField>

    <ParamField body="strict" type="boolean" default={false}>
      सख्त स्कीमा पालन सक्षम है या नहीं।
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="tool_choice" type="string | object">
  टूल चयन व्यवहार को नियंत्रित करता है। समर्थित स्ट्रिंग मान: `none`, `auto`, `required`। एक विशेष फ़ंक्शन भी निर्दिष्ट कर सकते हैं।
</ParamField>

<ParamField body="parallel_tool_calls" type="boolean" default={true}>
  मॉडल को समानांतर में टूल कॉल चलाने की अनुमति देनी है या नहीं।
</ParamField>

<ParamField body="text" type="object">
  टेक्स्ट प्रतिक्रिया प्रारूप के लिए कॉन्फ़िगरेशन।

  <Expandable title="properties">
    <ParamField body="format" type="object">
      टेक्स्ट प्रारूप कॉन्फ़िगरेशन।

      <Expandable title="properties">
        <ParamField body="type" type="string" required>
          प्रारूप प्रकार। समर्थित मान: `text`, `json_object`, `json_schema`।
        </ParamField>

        <ParamField body="name" type="string">
          प्रतिक्रिया प्रारूप का नाम। type `json_schema` होने पर आवश्यक।
        </ParamField>

        <ParamField body="schema" type="object">
          JSON स्कीमा। type `json_schema` होने पर आवश्यक।
        </ParamField>

        <ParamField body="strict" type="boolean">
          सख्त स्कीमा पालन सक्षम है या नहीं।
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="reasoning" type="object">
  तर्क आउटपुट के लिए कॉन्फ़िगरेशन।

  <Expandable title="properties">
    <ParamField body="effort" type="string">
      तर्क पर प्रयास को सीमित करता है। समर्थित मान: `low`, `medium`, `high`।
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="store" type="boolean" default={true}>
  बाद में पुनर्प्राप्ति के लिए उत्पन्न प्रतिक्रिया को संग्रहीत करना है या नहीं।
</ParamField>

<ParamField body="metadata" type="object">
  16 कुंजी-मान जोड़े का सेट जो प्रतिक्रिया से जोड़ा जा सकता है। कुंजियां अधिकतम 64 वर्णों वाली स्ट्रिंग हैं। मान अधिकतम 512 वर्णों वाली स्ट्रिंग हैं।
</ParamField>

<ParamField body="user" type="string">
  आपके अंतिम-उपयोगकर्ता का प्रतिनिधित्व करने वाला एक अद्वितीय पहचानकर्ता। अधिकतम 128 वर्ण।
</ParamField>

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

सफल प्रतिक्रिया ऑब्जेक्ट।

<ResponseField name="id" type="string">
  अद्वितीय प्रतिक्रिया पहचानकर्ता।
</ResponseField>

<ResponseField name="object" type="string">
  ऑब्जेक्ट प्रकार। हमेशा `response`।
</ResponseField>

<ResponseField name="created_at" type="number">
  प्रतिक्रिया बनाए जाने का Unix टाइमस्टैम्प (सेकंड में)।
</ResponseField>

<ResponseField name="status" type="string">
  प्रतिक्रिया की स्थिति। संभावित मान: `completed`, `failed`, `in_progress`, `cancelled`।
</ResponseField>

<ResponseField name="model" type="string">
  प्रतिक्रिया उत्पन्न करने के लिए उपयोग किया गया मॉडल।
</ResponseField>

<ResponseField name="output" type="object[]">
  मॉडल द्वारा उत्पन्न सामग्री आइटम की सरणी।

  <Expandable title="properties">
    <ResponseField name="type" type="string">
      आउटपुट आइटम का प्रकार। जैसे, `message`।
    </ResponseField>

    <ResponseField name="id" type="string">
      आउटपुट आइटम का अद्वितीय ID।
    </ResponseField>

    <ResponseField name="role" type="string">
      भूमिका। हमेशा `assistant`।
    </ResponseField>

    <ResponseField name="status" type="string">
      संदेश की स्थिति। जैसे, `completed`।
    </ResponseField>

    <ResponseField name="content" type="object[]">
      आउटपुट संदेश की सामग्री।

      <Expandable title="properties">
        <ResponseField name="type" type="string">
          सामग्री प्रकार। जैसे, `output_text`।
        </ResponseField>

        <ResponseField name="text" type="string">
          उत्पन्न टेक्स्ट सामग्री।
        </ResponseField>

        <ResponseField name="annotations" type="object[]">
          सामग्री के लिए एनोटेशन (जैसे, वेब खोज से उद्धरण)।
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="usage" type="object">
  प्रतिक्रिया के लिए टोकन उपयोग आँकड़े।

  <Expandable title="properties">
    <ResponseField name="input_tokens" type="integer">
      इनपुट टोकन की संख्या।
    </ResponseField>

    <ResponseField name="output_tokens" type="integer">
      आउटपुट टोकन की संख्या।
    </ResponseField>

    <ResponseField name="total_tokens" type="integer">
      कुल टोकन की संख्या।
    </ResponseField>

    <ResponseField name="input_tokens_details" type="object">
      इनपुट टोकन का विवरण।

      <Expandable title="properties">
        <ResponseField name="cached_tokens" type="integer">
          कैश किए गए टोकन की संख्या।
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="output_tokens_details" type="object">
      आउटपुट टोकन का विवरण।

      <Expandable title="properties">
        <ResponseField name="reasoning_tokens" type="integer">
          तर्क टोकन की संख्या।
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="temperature" type="number">
  उपयोग किया गया सैंपलिंग तापमान।
</ResponseField>

<ResponseField name="top_p" type="number">
  उपयोग किया गया न्यूक्लियस सैंपलिंग मान।
</ResponseField>

<ResponseField name="max_output_tokens" type="integer | null">
  उपयोग की गई अधिकतम आउटपुट टोकन सेटिंग।
</ResponseField>

<ResponseField name="error" type="object | null">
  यदि जनरेशन विफल हुआ तो एक त्रुटि ऑब्जेक्ट।
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api-llm.sunra.ai/v1/responses \
    -H "Authorization: Bearer <SUNRA_KEY>" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "openai/gpt-4o",
      "input": [
        {
          "type": "message",
          "role": "user",
          "content": "Hello, how are you?"
        }
      ]
    }'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://api-llm.sunra.ai/v1/responses",
      headers={
          "Authorization": "Bearer <SUNRA_KEY>",
          "Content-Type": "application/json"
      },
      json={
          "model": "openai/gpt-4o",
          "input": [
              {
                  "type": "message",
                  "role": "user",
                  "content": "Hello, how are you?"
              }
          ]
      }
  )
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api-llm.sunra.ai/v1/responses", {
    method: "POST",
    headers: {
      "Authorization": "Bearer <SUNRA_KEY>",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      model: "openai/gpt-4o",
      input: [
        {
          type: "message",
          role: "user",
          content: "Hello, how are you?"
        }
      ]
    })
  });
  const data = await response.json();
  console.log(data);
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "resp-abc123",
    "object": "response",
    "created_at": 1704067200,
    "status": "completed",
    "model": "openai/gpt-4o",
    "output": [
      {
        "type": "message",
        "id": "msg_abc123",
        "role": "assistant",
        "status": "completed",
        "content": [
          {
            "type": "output_text",
            "text": "Hello! I'm doing well, thank you for asking. How can I help you today?",
            "annotations": []
          }
        ]
      }
    ],
    "temperature": 1.0,
    "top_p": 1.0,
    "max_output_tokens": null,
    "usage": {
      "input_tokens": 15,
      "output_tokens": 18,
      "total_tokens": 33,
      "input_tokens_details": {
        "cached_tokens": 0
      },
      "output_tokens_details": {
        "reasoning_tokens": 0
      }
    },
    "error": null
  }
  ```
</ResponseExample>
