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

टेक्स्ट या मीडिया इनपुट से एम्बेडिंग वेक्टर बनाता है। केवल-टेक्स्ट अनुरोध प्रत्येक इनपुट के लिए एक वेक्टर लौटाते हैं, जो रिट्रीवल, सिमेंटिक सर्च, क्लस्टरिंग, वर्गीकरण और RAG के लिए उपयोगी है। मीडिया (base64 data URI के रूप में इमेज, ऑडियो या वीडियो) वाले अनुरोध **सभी** इनपुट को **एक ही** क्रॉस-मोडल वेक्टर में फ्यूज़ कर देते हैं — यदि आपको प्रत्येक एसेट के लिए एक वेक्टर चाहिए, तो प्रत्येक एसेट को उसके अपने अलग अनुरोध में एम्बेड करें। OpenAI Embeddings API प्रारूप के साथ संगत है। इस एंडपॉइंट पर स्ट्रीमिंग समर्थित नहीं है।

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

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

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

## अनुरोध

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

<ParamField body="model" type="string" required>
  उपयोग किए जाने वाले एम्बेडिंग मॉडल की ID, जैसे `google/gemini-embedding-2`। उपलब्ध एम्बेडिंग मॉडल के लिए [मॉडल पेज](https://sunra.ai/models) देखें।
</ParamField>

<ParamField body="input" type="string | string[]" required>
  एम्बेड करने के लिए इनपुट, एक स्ट्रिंग या स्ट्रिंग्स की एक सरणी के रूप में। केवल-टेक्स्ट इनपुट स्वतंत्र रूप से एम्बेड किए जाते हैं और इनपुट क्रम में प्रत्येक इनपुट के लिए एक वेक्टर लौटाते हैं। मीडिया इनपुट base64 data URI के रूप में पास किए जाते हैं (`data:image/png;base64,…`, `data:audio/mpeg;base64,…`, `data:video/mp4;base64,…`) और इन्हें टेक्स्ट के साथ मिलाया जा सकता है — लेकिन मीडिया वाला कोई भी अनुरोध सभी इनपुट के संयोजन के लिए एक ही फ्यूज़्ड वेक्टर लौटाता है। सीमाएँ (अपस्ट्रीम): प्रति अनुरोध अधिकतम 6 इमेज, वीडियो अधिकतम 120 सेकंड, और सभी मोडैलिटी में कुल 8,192 टोकन का साझा बजट (टेक्स्ट टोकन; प्रत्येक इमेज 258 टोकन, ऑडियो 25 टोकन/सेकंड, वीडियो 66 टोकन/सेकंड के रूप में गिना जाता है)।
</ParamField>

<ParamField body="dimensions" type="integer">
  आउटपुट एम्बेडिंग के लिए आयामों की संख्या। केवल लचीले आउटपुट आयामों वाले मॉडल (Matryoshka Representation Learning) द्वारा समर्थित। `google/gemini-embedding-2` के लिए डिफ़ॉल्ट `3072` है, और `128` से `3072` तक के मान समर्थित हैं। छोटे मान वेक्टर को छोटा कर देते हैं जबकि अधिकांश सिमेंटिक गुणवत्ता बनाए रखते हैं।
</ParamField>

<ParamField body="encoding_format" type="string">
  लौटाए गए एम्बेडिंग का प्रारूप। `float` (डिफ़ॉल्ट) या `base64` में से एक।
</ParamField>

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

<ResponseField name="object" type="string">
  हमेशा `list`।
</ResponseField>

<ResponseField name="data" type="object[]">
  एम्बेडिंग ऑब्जेक्ट्स की एक सूची, प्रत्येक इनपुट के लिए एक, इनपुट क्रम में।

  <Expandable title="embedding object">
    <ResponseField name="object" type="string">
      हमेशा `embedding`।
    </ResponseField>

    <ResponseField name="index" type="integer">
      संबंधित इनपुट का इंडेक्स।
    </ResponseField>

    <ResponseField name="embedding" type="number[]">
      एम्बेडिंग वेक्टर।
    </ResponseField>
  </Expandable>
</ResponseField>

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

<ResponseField name="usage" type="object">
  अनुरोध के लिए टोकन उपयोग। एम्बेडिंग केवल इनपुट टोकन पर बिल की जाती हैं, मोडैलिटी-विशिष्ट दरों के साथ (मूल्य निर्धारण के लिए मॉडल पेज देखें)। मीडिया अनुरोधों में प्रति-मोडैलिटी टोकन गणनाएँ शामिल होती हैं।

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

    <ResponseField name="input_image_tokens" type="integer">
      इमेज इनपुट टोकन (258 प्रति इमेज)। केवल तब मौजूद जब अनुरोध में इमेज शामिल हों।
    </ResponseField>

    <ResponseField name="input_audio_tokens" type="integer">
      ऑडियो इनपुट टोकन (25 प्रति सेकंड)। केवल तब मौजूद जब अनुरोध में ऑडियो शामिल हो।
    </ResponseField>

    <ResponseField name="input_video_tokens" type="integer">
      वीडियो इनपुट टोकन (66 प्रति सेकंड)। केवल तब मौजूद जब अनुरोध में वीडियो शामिल हो।
    </ResponseField>

    <ResponseField name="total_tokens" type="integer">
      सभी मोडैलिटी में कुल इनपुट टोकन (एम्बेडिंग कोई आउटपुट टोकन उत्पन्न नहीं करती)।
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api-llm.sunra.ai/v1/embeddings \
    -H "Authorization: Bearer <SUNRA_KEY>" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "google/gemini-embedding-2",
      "input": [
        "The quick brown fox jumps over the lazy dog.",
        "Sunra is a platform for AI models."
      ],
      "dimensions": 768
    }'
  ```

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

  response = requests.post(
      "https://api-llm.sunra.ai/v1/embeddings",
      headers={
          "Authorization": "Bearer <SUNRA_KEY>",
          "Content-Type": "application/json"
      },
      json={
          "model": "google/gemini-embedding-2",
          "input": [
              "The quick brown fox jumps over the lazy dog.",
              "Sunra is a platform for AI models."
          ],
          "dimensions": 768
      }
  )
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api-llm.sunra.ai/v1/embeddings", {
    method: "POST",
    headers: {
      "Authorization": "Bearer <SUNRA_KEY>",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      model: "google/gemini-embedding-2",
      input: [
        "The quick brown fox jumps over the lazy dog.",
        "Sunra is a platform for AI models."
      ],
      dimensions: 768
    })
  });
  const data = await response.json();
  console.log(data);
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "object": "list",
    "data": [
      {
        "object": "embedding",
        "index": 0,
        "embedding": [0.011253, -0.020551, 0.049236, "..."]
      },
      {
        "object": "embedding",
        "index": 1,
        "embedding": [0.031744, 0.008122, -0.014307, "..."]
      }
    ],
    "model": "google/gemini-embedding-2",
    "usage": {
      "prompt_tokens": 18,
      "total_tokens": 18
    }
  }
  ```
</ResponseExample>
