Skip to content
docs

Embeddings

POST /v1/embeddings turns text into vectors. The request and the response match OpenAI Embeddings, so a client built on the OpenAI SDK connects by changing the base URL and the key.

The endpoint serves only models of the embedding class. GET /v1/models?output_modalities=embeddings returns their list; see Models.

Terminal window
curl https://api.waibee.com/v1/embeddings \
-H "Authorization: Bearer $WAIBEE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/text-embedding-3-small",
"input": ["First text", "Second text"]
}'
{
"object": "list",
"data": [
{"object": "embedding", "embedding": [-0.0171966552734375, -0.015472412109375, -0.0038166046142578125], "index": 0},
{"object": "embedding", "embedding": [-0.006717681884765625, 0.014984130859375, 0.000751495361328125], "index": 1}
],
"model": "text-embedding-3-small",
"usage": {"prompt_tokens": 4, "total_tokens": 4}
}

The vectors here are shortened: with openai/text-embedding-3-small, each has 1536 numbers.

from openai import OpenAI
client = OpenAI(api_key="sk_live_...", base_url="https://api.waibee.com/v1")
response = client.embeddings.create(
model="openai/text-embedding-3-small",
input=["First text", "Second text"],
encoding_format="float",
)
for item in response.data:
print(item.index, len(item.embedding))

Without encoding_format, the SDK requests base64 on its own and decodes the response, so item.embedding holds the same list of numbers.

encoding_format accepts float and base64. Without the field, float applies: the vector arrives as a list of numbers.

With base64, each vector arrives as a string: float32 values in little-endian byte order, the same layout OpenAI uses. After decoding, the numbers match the float response.

If you set encoding_format="base64" in the SDK explicitly, the SDK does not decode the string, so decode it yourself:

import base64
import struct
response = client.embeddings.create(
model="openai/text-embedding-3-small",
input="First text",
encoding_format="base64",
)
raw = base64.b64decode(response.data[0].embedding)
vector = struct.unpack(f"<{len(raw) // 4}f", raw)
print(len(vector))
FieldWhat it sets
modelThe ID of an embedding class model from the catalog
inputA string or an array of 1 to 2048 non-empty strings
encoding_formatfloat or base64. Without the field, float
dimensionsThe vector length, an integer from 1. Passed to the model only if set; not every model supports it
pluginsDLP settings, as in chat requests

The router drops other fields, such as user, and does not pass them to the model.

  • data holds one vector for each element of input, in the same order. index is the element’s position in the input.
  • model names the model that responded.
  • usage has tokens only: prompt_tokens and total_tokens. Embeddings have no output tokens. If the model returned no counters, the response has no usage.
  • plugins.dlp is present if DLP in mask or alert mode found something; see DLP.
  • Text only. Token arrays and multimodal elements in input are rejected with 422 and the code validation_error. So are an empty array, an empty string, and more than 2048 elements.
  • Text volume is limited the same way as for chat: 15 MB for the whole input. Going over returns 413 with the code text_content_too_large; see Limits.
  • Embedding models only. A chat model on this endpoint is rejected with 400 and the code model_endpoint_mismatch, and so is an embedding model on /v1/chat/completions, /v1/messages, or /v1/responses.
  • No waibee/auto. Autorouting picks only among chat models, so waibee/auto is rejected here with 400 and the code feature_not_supported.
  • No streaming. The response always arrives in full.

Your key’s DLP policy and the plugins.dlp field work here the same way as for chat; see Plugins. Since there are no messages here, a few things differ:

  • Each element of input is checked the same way as a user message.
  • A finding names the element: input[1] for an array, input for a string. Its message_index is -1.
  • report_scope narrows nothing: the response has all findings, and block on any element rejects the whole request with 403 and the code dlp_violation.
  • With mask, the model receives a token instead of the value found, and the vector is computed from the text with the token. Nothing is restored in the response: there is nothing to restore in a vector.
A finding in the second input element
{
"category": "pii",
"entity_type": "EMAIL",
"message_index": -1,
"location": "input[1]",
"start": 5,
"end": 21,
"confidence": 0.99
}

Errors come in Chat Completions format: an error object with the fields code, message, and extra. Codes are shared across all endpoints: Errors.