---
title: "Create embeddings"
method: POST
path: "/v1/embeddings"
tags: ["Completions"]
---

# Create embeddings

`POST /v1/embeddings`

## Request

- Base URL: `https://api.us-east-1.langdb.ai`
- URL: `https://api.us-east-1.langdb.ai/v1/embeddings`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/langdb/apis/ai-gateway-api-2/docs/v1/embeddings/post.ts> (a function with typed inputs; its response is checked against the schema)

Creates an embedding vector representing the input text or token arrays.

## Request body

- EmbeddingsRequest
  - `model` string, required: ID of the model to use for generating embeddings.
  - `input` union, required
    - string: The text to embed.
    - string[]: Array of text strings to embed.
  - `encoding_format` 'float' | 'base64': The format to return the embeddings in.
  - `dimensions` integer: The number of dimensions the resulting embeddings should have.

## Response `200`

Successful response with embeddings

- EmbeddingsResponse
  - `data` object[], required
    - `embedding` union, required
      - number[]: The embedding vector, returned when encoding_format=float.
      - string: The base64-encoded embedding vector, returned when encoding_format=base64.
    - `index` integer, required: The index of this embedding in the input array.
  - `model` string, required: The model used for generating the embeddings.
  - `usage` object, required
    - `prompt_tokens` integer, required: The number of tokens in the prompt.
    - `total_tokens` integer, required: The total number of tokens used (same as prompt_tokens since there is no completion).

---

[API](https://skmtc.dev/langdb/apis/ai-gateway-api-2.md) - [All operations](https://skmtc.dev/langdb/apis/ai-gateway-api-2/llms.txt) - [OpenAPI document](https://skmtc.dev/langdb/apis/ai-gateway-api-2/revisions/2fc3660bf759?raw)
