---
title: "Create an embedding vector representation corresponding to the input text. This is the endpoint for making requests to embedding models."
method: POST
path: "/v1/embeddings"
tags: ["v1"]
---

# Create an embedding vector representation corresponding to the input text. This is the endpoint for making requests to embedding models.

`POST /v1/embeddings`

## Request body

- EmbeddingRequest
  - `dimensions` integer, nullable — The number of dimensions the resulting output embeddings should have.
  - `encoding_format` string, nullable — The format to return the embeddings in. Can be either `float` or `base64`.
  - `input` union
    - object — A strings to be embedded. For best performance, prepend "query: " in front of query content and prepend "passage: " in front of passage/text
      - `String` string, required — A strings to be embedded. For best performance, prepend "query: " in front of query content and prepend "passage: " in front of passage/text
    - object — An array of strings to be embedded
      - `StringArray` string[], required — An array of strings to be embedded
    - object — A token in integer to be embedded
      - `Ints` integer[], required — A token in integer to be embedded
    - object — An array of tokens in integers to be embedded
      - `IntsArray` array[], required — An array of tokens in integers to be embedded
        - integer[]
  - `model` string — ID of the model to use.
  - `preview` boolean, nullable — Flag to use the new format of the API.
  - `user` string, nullable — A unique identifier representing your end-user, which can help xAI to monitor and detect abuse.

## Response `200`

Success

- EmbeddingResponse
  - `data` Embedding[], required — A list of embedding objects.
    - `embedding` union, required
      - string — Embedding in base64 string.
      - number[] — Embedding as an array of floats.
    - `index` integer, required — Index of the embedding object in the data list.
    - `object` string, required — The object type, which is always `"embedding"`.
  - `model` string, required — Model ID used to create embedding.
  - `object` string, required — The object type of `data` field, which is always `"list"`.
  - `usage` EmbeddingUsage
    - `prompt_tokens` integer, required — Prompt token used.
    - `total_tokens` integer, required — Total token used.

## Other responses

- `400` — Bad request. The request is invalid or an invalid API key is provided.
- `422` — Unprocessable Entity. There are missing fields in the request body.

---

[API](https://skmtc.net/x/apis/xai-s-rest-api.md) · [All operations](https://skmtc.net/x/apis/xai-s-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/x/xai-s-rest-api/versions/8f6014272113/schema)
