> ## 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 message

Anthropic Messages API प्रारूप का उपयोग करके एक संदेश बनाता है। टेक्स्ट, छवियों, PDF, टूल्स और विस्तारित सोच का समर्थन करता है।

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

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

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

## अनुरोध

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

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

<ParamField body="messages" type="object[]" required>
  इनपुट संदेश। प्रत्येक इनपुट संदेश में एक `role` और `content` होता है।

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

    <ParamField body="content" type="string | object[]" required>
      संदेश की सामग्री। एक स्ट्रिंग या सामग्री ब्लॉक की एक सरणी हो सकती है।

      <Expandable title="content block types">
        <ParamField body="type" type="string" required>
          सामग्री ब्लॉक का प्रकार। समर्थित मान: `text`, `image`, `tool_use`, `tool_result`।
        </ParamField>

        <ParamField body="text" type="string">
          टेक्स्ट सामग्री। type `text` होने पर उपयोग किया जाता है।
        </ParamField>

        <ParamField body="source" type="object">
          छवि स्रोत। type `image` होने पर उपयोग किया जाता है।

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

            <ParamField body="media_type" type="string" required>
              छवि का मीडिया प्रकार। जैसे, `image/jpeg`, `image/png`, `image/gif`, `image/webp`।
            </ParamField>

            <ParamField body="data" type="string">
              Base64-एन्कोडेड छवि डेटा। स्रोत प्रकार `base64` होने पर आवश्यक।
            </ParamField>

            <ParamField body="url" type="string">
              छवि URL। स्रोत प्रकार `url` होने पर आवश्यक।
            </ParamField>
          </Expandable>
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="max_tokens" type="integer" required>
  रुकने से पहले उत्पन्न करने के लिए टोकन की अधिकतम संख्या। ध्यान दें कि मॉडल इस अधिकतम तक पहुंचने से पहले रुक सकता है।
</ParamField>

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

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

<ParamField body="temperature" type="number" default={1}>
  प्रतिक्रिया में इंजेक्ट की गई यादृच्छिकता की मात्रा। 0.0 से 1.0 तक की सीमा। विश्लेषणात्मक/बहुविकल्पीय कार्यों के लिए 0.0 के करीब `temperature` का उपयोग करें, और रचनात्मक एवं उत्पादक कार्यों के लिए 1.0 के करीब।
</ParamField>

<ParamField body="top_p" type="number">
  न्यूक्लियस सैंपलिंग का उपयोग करें। न्यूक्लियस सैंपलिंग में, हम घटती प्रायिकता क्रम में प्रत्येक बाद के टोकन के लिए सभी विकल्पों पर संचयी वितरण की गणना करते हैं और `top_p` द्वारा निर्दिष्ट विशेष प्रायिकता तक पहुंचने पर इसे काट देते हैं।
</ParamField>

<ParamField body="top_k" type="integer">
  प्रत्येक बाद के टोकन के लिए केवल शीर्ष K विकल्पों से सैंपल करें। "लंबी पूंछ" कम प्रायिकता प्रतिक्रियाओं को हटाने के लिए उपयोग किया जाता है। केवल उन्नत उपयोग के मामलों के लिए अनुशंसित।
</ParamField>

<ParamField body="stop_sequences" type="string[]">
  कस्टम टेक्स्ट अनुक्रम जो मॉडल को उत्पन्न करना बंद करा देंगे। लौटाए गए टेक्स्ट में स्टॉप अनुक्रम शामिल नहीं होगा।
</ParamField>

<ParamField body="tools" type="object[]">
  उन टूल की परिभाषाएं जिनका मॉडल उपयोग कर सकता है।

  <Expandable title="properties">
    <ParamField body="name" type="string" required>
      टूल का नाम।
    </ParamField>

    <ParamField body="description" type="string">
      यह टूल क्या करता है इसका विवरण।
    </ParamField>

    <ParamField body="input_schema" type="object" required>
      इस टूल के इनपुट के लिए JSON स्कीमा। यह उस `input` के आकार को परिभाषित करता है जिसे आपका टूल स्वीकार करता है।
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="tool_choice" type="object">
  मॉडल को प्रदान किए गए टूल का उपयोग कैसे करना चाहिए।

  <Expandable title="properties">
    <ParamField body="type" type="string" required>
      समर्थित मान: `auto` (डिफ़ॉल्ट, मॉडल निर्णय लेता है), `any` (मॉडल को किसी टूल का उपयोग करना होगा), `tool` (मॉडल को एक विशिष्ट टूल का उपयोग करना होगा)।
    </ParamField>

    <ParamField body="name" type="string">
      उपयोग किए जाने वाले टूल का नाम। type `tool` होने पर आवश्यक।
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="metadata" type="object">
  अनुरोध के बारे में मेटाडेटा का वर्णन करने वाला एक ऑब्जेक्ट।

  <Expandable title="properties">
    <ParamField body="user_id" type="string">
      अनुरोध से संबंधित उपयोगकर्ता के लिए एक बाहरी पहचानकर्ता।
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="thinking" type="object">
  विस्तारित सोच के लिए कॉन्फ़िगरेशन। सक्षम होने पर, मॉडल प्रतिक्रिया देने से पहले सोचेगा।

  <Expandable title="properties">
    <ParamField body="type" type="string" required>
      `enabled` होना चाहिए।
    </ParamField>

    <ParamField body="budget_tokens" type="integer" required>
      सोचने के लिए उपयोग करने वाले टोकन की अधिकतम संख्या। 1024 से अधिक या बराबर होनी चाहिए।
    </ParamField>
  </Expandable>
</ParamField>

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

सफल संदेश प्रतिक्रिया।

<ResponseField name="id" type="string">
  अद्वितीय संदेश पहचानकर्ता, जैसे `msg_01XFDUDYJgAACzvnptvVoYEL`।
</ResponseField>

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

<ResponseField name="role" type="string">
  उत्पन्न संदेश की वार्तालाप भूमिका। हमेशा `assistant`।
</ResponseField>

<ResponseField name="content" type="object[]">
  मॉडल द्वारा उत्पन्न सामग्री। यह सामग्री ब्लॉक की एक सरणी है।

  <Expandable title="properties">
    <ResponseField name="type" type="string">
      सामग्री ब्लॉक का प्रकार। `text`, `tool_use`, या `thinking` हो सकता है।
    </ResponseField>

    <ResponseField name="text" type="string">
      उत्पन्न टेक्स्ट। type `text` होने पर मौजूद।
    </ResponseField>

    <ResponseField name="id" type="string">
      टूल उपयोग ब्लॉक का ID। type `tool_use` होने पर मौजूद।
    </ResponseField>

    <ResponseField name="name" type="string">
      टूल का नाम। type `tool_use` होने पर मौजूद।
    </ResponseField>

    <ResponseField name="input" type="object">
      टूल का इनपुट। type `tool_use` होने पर मौजूद।
    </ResponseField>

    <ResponseField name="thinking" type="string">
      सोच की सामग्री। type `thinking` होने पर मौजूद।
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="model" type="string">
  अनुरोध को संभालने वाला मॉडल।
</ResponseField>

<ResponseField name="stop_reason" type="string | null">
  मॉडल के रुकने का कारण। यह `end_turn` (मॉडल एक स्वाभाविक रुकने के बिंदु पर पहुंचा), `max_tokens` (`max_tokens` या मॉडल की अधिकतम सीमा पार हुई), `stop_sequence` (आपके कस्टम स्टॉप अनुक्रमों में से एक उत्पन्न हुआ), या `tool_use` (मॉडल ने एक या अधिक टूल का आह्वान किया) हो सकता है।
</ResponseField>

<ResponseField name="stop_sequence" type="string | null">
  कौन सा कस्टम स्टॉप अनुक्रम उत्पन्न हुआ, यदि कोई हो।
</ResponseField>

<ResponseField name="usage" type="object">
  बिलिंग और दर-सीमा उपयोग। तीनों इनपुट बकेट परस्पर अनन्य हैं — देखें [टोकन उपयोग](/hi/llm/token-usage)।

  <Expandable title="properties">
    <ResponseField name="input_tokens" type="integer">
      उपयोग किए गए ताज़ा इनपुट टोकन की संख्या। दोनों कैश बकेट को शामिल नहीं करता।
    </ResponseField>

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

    <ResponseField name="total_tokens" type="integer">
      सभी इनपुट बकेट और `output_tokens` का जोड़। streaming प्रतिक्रियाओं पर छोड़ दिया जाता है।
    </ResponseField>

    <ResponseField name="cache_creation_input_tokens" type="integer">
      कैश प्रविष्टि बनाने के लिए उपयोग किए गए इनपुट टोकन की संख्या।
    </ResponseField>

    <ResponseField name="cache_read_input_tokens" type="integer">
      कैश से पढ़े गए इनपुट टोकन की संख्या।
    </ResponseField>

    <ResponseField name="sunra_usage_semantics" type="string | null">
      जब Sunra ने इस प्रतिक्रिया को सामान्यीकृत किया हो तो `anthropic.exclusive.v1` के रूप में मौजूद। संख्याओं से परिपाटी का अनुमान लगाने के बजाय इस मान पर assert करें। देखें [टोकन उपयोग](/hi/llm/token-usage)।
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api-llm.sunra.ai/v1/messages \
    -H "Authorization: Bearer <SUNRA_KEY>" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "anthropic/claude-sonnet-4-20250514",
      "max_tokens": 1024,
      "messages": [
        {
          "role": "user",
          "content": "Hello, how are you?"
        }
      ]
    }'
  ```

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

  response = requests.post(
      "https://api-llm.sunra.ai/v1/messages",
      headers={
          "Authorization": "Bearer <SUNRA_KEY>",
          "Content-Type": "application/json"
      },
      json={
          "model": "anthropic/claude-sonnet-4-20250514",
          "max_tokens": 1024,
          "messages": [
              {"role": "user", "content": "Hello, how are you?"}
          ]
      }
  )
  print(response.json())
  ```

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

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "msg_01XFDUDYJgAACzvnptvVoYEL",
    "type": "message",
    "role": "assistant",
    "content": [
      {
        "type": "text",
        "text": "Hello! I'm doing well, thank you for asking. How can I help you today?"
      }
    ],
    "model": "anthropic/claude-sonnet-4-20250514",
    "stop_reason": "end_turn",
    "stop_sequence": null,
    "usage": {
      "input_tokens": 12,
      "output_tokens": 19,
      "total_tokens": 31,
      "sunra_usage_semantics": "anthropic.exclusive.v1"
    }
  }
  ```
</ResponseExample>
