Embeddings

Submit an embedding request

Changed on

Submits an embedding request to the embeddings router

post/embeddings

Request

  • Base URL
    https://openrouter.ai/api/v1
  • Auth
    HTTP bearer

Request body

object required

Embeddings request input

dimensions, integer

The number of dimensions for the output embeddings

encoding_format, 'float' | 'base64'

The format of the output embeddings

input, union required

Text, token, or multimodal input(s) to embed

input_type, string

The type of input (e.g. search_query, search_document). Document-chunk input (string[][]) is only valid with a document input type.

model, string required

The model to use for embeddings

provider, intersection

Provider routing preferences for the request.

session_id, string

A unique identifier for grouping related requests (e.g., a conversation or agent workflow). Used for observability grouping in Broadcast and private logging; never sent to the provider. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.

trace, TraceConfig

Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.

user, string

A unique identifier for the end-user

Example request

{
  "dimensions": 1536,
  "input": "The quick brown fox jumps over the lazy dog",
  "model": "openai/text-embedding-3-small"
}

Response

Embedding response

object required

Embeddings response containing embedding vectors

data, object[] required

List of embedding objects

id, string

Unique identifier for the embeddings response

model, string required

The model used for embeddings

object, 'list' required
usage, object

Token usage statistics

Example response

{
  "data": [
    {
      "embedding": [
        0.0023064255,
        -0.009327292,
        0.015797347
      ],
      "index": 0,
      "object": "embedding"
    }
  ],
  "model": "openai/text-embedding-3-small",
  "object": "list",
  "usage": {
    "prompt_tokens": 8,
    "total_tokens": 8
  }
}

Changes

    • info

      added the new optional request property provider/allOf[#/components/schemas/ProviderPreferences]/options/celeris

    • info

      added the new Celeris enum value to the request property provider/allOf[#/components/schemas/ProviderPreferences]/ignore/items/anyOf[#/components/schemas/ProviderName]

    • info

      added the new Celeris enum value to the request property provider/allOf[#/components/schemas/ProviderPreferences]/only/items/anyOf[#/components/schemas/ProviderName]

    1 more change in this revision