---
title: "Embeddings"
method: POST
path: "/dedicated/v1/embeddings"
tags: ["Dedicated.Embeddings"]
---

# Embeddings

`POST /dedicated/v1/embeddings`

## Request

- Base URL: `https://api.friendli.ai`
- URL: `https://api.friendli.ai/dedicated/v1/embeddings`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/friendli/apis/friendli-suite-api-reference/docs/dedicated/v1/embeddings/post.ts> (a function with typed inputs; its response is checked against the schema)

Creates an embedding vector representing the input text.

## Headers

- `X-Friendli-Team` string, nullable: ID of team to run requests as (optional parameter).

## Request body

- DedicatedEmbeddingsBody
  - `model` string, required: ID of target endpoint. If you want to send request to specific adapter, use the format "YOUR_ENDPOINT_ID:YOUR_ADAPTER_ROUTE". Otherwise, you can just use "YOUR_ENDPOINT_ID" alone.
  - `input` union: Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. Either `input` or `tokens` field is required.
    - string
    - string[]
  - `tokens` integer[], nullable: The tokenized prompt (i.e., input tokens). Either `input` or `tokens` field is required.
  - `encoding_format` 'float' | 'base64', nullable: The format to return the embeddings in. Can be either `float` or [`base64`](https://pypi.org/project/pybase64/).

## Response `200`

Successfully generated embeddings.

- DedicatedEmbeddingsSuccess
  - `id` string, required: A unique ID of the embeddings.
  - `model` string, nullable: The model to generate the embeddings. For dedicated endpoints, it returns the endpoint id.
  - `object` 'list', required: The object type, which is always set to `list`.
  - `data` EmbeddingObject[], required: A list of embedding objects.
    - `index` integer, required: The index of the embedding in the list of embeddings.
    - `object` 'embedding', required: The object type, which is always set to `embedding`.
    - `embedding` union, required: The embedding vector, which is a list of floats or a base64-encoded string. The length of vector depends on the model.
      - number[]
      - string, binary
  - `usage` TextUsage, required
    - `prompt_tokens` integer, required: Number of tokens in the prompt.
    - `completion_tokens` integer, required: Number of tokens in the generated completions.
    - `total_tokens` integer, required: Total number of tokens used in the request (`prompt_tokens` + `completion_tokens`).
    - `prompt_tokens_details` PromptTokensDetails
      - `cached_tokens` integer, nullable: Cached tokens present in the prompt.
  - `created` integer, required: The Unix timestamp (in seconds) for when the embeddings were created.

## Other responses

- `422`: Unprocessable Entity

---

[API](https://skmtc.dev/friendli/apis/friendli-suite-api-reference.md) - [All operations](https://skmtc.dev/friendli/apis/friendli-suite-api-reference/llms.txt) - [OpenAPI document](https://skmtc.dev/friendli/apis/friendli-suite-api-reference/revisions/38fb43993a11?raw)
