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

# Create an Embedding

Creates text embeddings.

<RequestExample>
  ```py Python theme={null}
  from openai import OpenAI
  import os

  # 💥 Create an OpenAI client, pointed at Muna
  openai = OpenAI(
    api_key=os.environ["MUNA_API_KEY"],
    base_url="https://inference.muna.ai/v1"
  )

  # 🔥 Create a text embedding
  embedding = openai.embeddings.create(
    model="@nomic/nomic-embed-text-v1.5",
    input="What is the capital of France?"
  )

  # 🚀 Use the embedding
  print(embedding.data[0].embedding)
  ```

  ```ts JavaScript theme={null}
  import OpenAI from "openai"

  // 💥 Create an OpenAI client, pointed at Muna
  const openai = new OpenAI({
    apiKey: process.env.MUNA_API_KEY,
    baseURL: "https://inference.muna.ai/v1"
  });

  // 🔥 Create a text embedding
  const embedding = await openai.embeddings.create({
    model: "@nomic/nomic-embed-text-v1.5",
    input: "What is the capital of France?"
  });

  // 🚀 Use the embedding
  console.log(embedding.data[0].embedding);
  ```

  ```bash curl theme={null}
  curl https://inference.muna.ai/v1/embeddings \
    -H "Authorization: Bearer $MUNA_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "@nomic/nomic-embed-text-v1.5",
      "input": "What is the capital of France?"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "object": "list",
    "model": "@nomic/nomic-embed-text-v1.5",
    "data": [
      {
        "object": "embedding",
        "index": 0,
        "embedding": [0.0123, -0.0456, 0.0789]
      }
    ],
    "usage": {
      "prompt_tokens": 8,
      "total_tokens": 8
    }
  }
  ```
</ResponseExample>

### Body

<ParamField body="model" type="string" required>
  Model tag.
</ParamField>

<ParamField body="input" type="string | string[]" required>
  Input text to embed. Pass a list of texts to embed them in a single request.
</ParamField>

<ParamField body="dimensions" type="integer">
  Number of embedding dimensions, for models that support Matryoshka representation learning.
</ParamField>

<ParamField body="encoding_format" type="string">
  Embedding encoding format: `float` or `base64`. Defaults to `float`.
</ParamField>

### Response

<ResponseField name="object" type="string" required>
  Object type, always `list`.
</ResponseField>

<ResponseField name="model" type="string" required>
  Model tag.
</ResponseField>

<ResponseField name="data" type="Embedding[]" required>
  Embeddings, one for each input text.

  <Expandable title="properties">
    <ResponseField name="object" type="string" required>
      Object type, always `embedding`.
    </ResponseField>

    <ResponseField name="index" type="integer" required>
      Index of the input text.
    </ResponseField>

    <ResponseField name="embedding" type="number[] | string" required>
      Embedding vector, or a base64 string when `encoding_format` is `base64`.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="usage" type="Usage" required>
  Token usage.

  <Expandable title="properties">
    <ResponseField name="prompt_tokens" type="integer" required>
      Number of tokens in the input.
    </ResponseField>

    <ResponseField name="total_tokens" type="integer" required>
      Total number of tokens.
    </ResponseField>
  </Expandable>
</ResponseField>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.