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

Creates embedding vectors from text or media inputs. Text-only requests return one vector per input, useful for retrieval, semantic search, clustering, classification, and RAG. Requests containing media (images, audio, or video as base64 data URIs) fuse **all** inputs into a **single** cross-modal vector — embed each asset in its own request when you need one vector per asset. Compatible with the OpenAI Embeddings API format. Streaming is not supported on this endpoint.

## Authentication

<ParamField header="Authorization" type="string" required>
  Bearer token. Use your API key as the bearer token in the Authorization header.

  Format: `Bearer <SUNRA_KEY>`
</ParamField>

## Request

This endpoint expects an object.

<ParamField body="model" type="string" required>
  ID of the embedding model to use, e.g. `google/gemini-embedding-2`. See the [models page](https://sunra.ai/models) for available embedding models.
</ParamField>

<ParamField body="input" type="string | string[]" required>
  Inputs to embed, as a single string or an array of strings. Text-only inputs are embedded independently, returning one vector per input in input order. Media inputs are passed as base64 data URIs (`data:image/png;base64,…`, `data:audio/mpeg;base64,…`, `data:video/mp4;base64,…`) and may be mixed with text — but any request containing media returns a single fused vector for all inputs combined. Limits (upstream): at most 6 images per request, video up to 120 seconds, and a combined budget of 8,192 tokens across all modalities (text tokens; images count 258 tokens each, audio 25 tokens/second, video 66 tokens/second).
</ParamField>

<ParamField body="dimensions" type="integer">
  The number of dimensions for the output embeddings. Only supported by models with flexible output dimensions (Matryoshka Representation Learning). For `google/gemini-embedding-2` the default is `3072`, and values from `128` to `3072` are supported. Smaller values truncate the vector while preserving most semantic quality.
</ParamField>

<ParamField body="encoding_format" type="string">
  The format of the returned embeddings. Either `float` (default) or `base64`.
</ParamField>

## Response

<ResponseField name="object" type="string">
  Always `list`.
</ResponseField>

<ResponseField name="data" type="object[]">
  A list of embedding objects, one per input, in input order.

  <Expandable title="embedding object">
    <ResponseField name="object" type="string">
      Always `embedding`.
    </ResponseField>

    <ResponseField name="index" type="integer">
      The index of the corresponding input.
    </ResponseField>

    <ResponseField name="embedding" type="number[]">
      The embedding vector.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="model" type="string">
  The model used to create the embeddings.
</ResponseField>

<ResponseField name="usage" type="object">
  Token usage for the request. Embeddings are billed on input tokens only, with modality-specific rates (see the model page for pricing). Media requests include per-modality token counts.

  <Expandable title="usage object">
    <ResponseField name="prompt_tokens" type="integer">
      Number of text input tokens.
    </ResponseField>

    <ResponseField name="input_image_tokens" type="integer">
      Image input tokens (258 per image). Present only when the request contains images.
    </ResponseField>

    <ResponseField name="input_audio_tokens" type="integer">
      Audio input tokens (25 per second). Present only when the request contains audio.
    </ResponseField>

    <ResponseField name="input_video_tokens" type="integer">
      Video input tokens (66 per second). Present only when the request contains video.
    </ResponseField>

    <ResponseField name="total_tokens" type="integer">
      Total input tokens across all modalities (embeddings produce no output tokens).
    </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>
