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.
First request
Section titled “First request”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.
With the OpenAI SDK
Section titled “With the OpenAI SDK”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.
float and base64
Section titled “float and base64”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 base64import 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))Request
Section titled “Request”| Field | What it sets |
|---|---|
model | The ID of an embedding class model from the catalog |
input | A string or an array of 1 to 2048 non-empty strings |
encoding_format | float or base64. Without the field, float |
dimensions | The vector length, an integer from 1. Passed to the model only if set; not every model supports it |
plugins | DLP settings, as in chat requests |
The router drops other fields, such as user, and does not pass them to the model.
Response
Section titled “Response”dataholds one vector for each element ofinput, in the same order.indexis the element’s position in the input.modelnames the model that responded.usagehas tokens only:prompt_tokensandtotal_tokens. Embeddings have no output tokens. If the model returned no counters, the response has nousage.plugins.dlpis present if DLP inmaskoralertmode found something; see DLP.
Limitations
Section titled “Limitations”- Text only. Token arrays and multimodal elements in
inputare rejected with422and the codevalidation_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 returns413with the codetext_content_too_large; see Limits. - Embedding models only. A chat model on this endpoint is rejected with
400and the codemodel_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, sowaibee/autois rejected here with400and the codefeature_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
inputis checked the same way as ausermessage. - A finding names the element:
input[1]for an array,inputfor a string. Itsmessage_indexis-1. report_scopenarrows nothing: the response has all findings, andblockon any element rejects the whole request with403and the codedlp_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.
{ "category": "pii", "entity_type": "EMAIL", "message_index": -1, "location": "input[1]", "start": 5, "end": 21, "confidence": 0.99}Errors
Section titled “Errors”Errors come in Chat Completions format: an error object with the fields code, message, and extra. Codes are shared across all endpoints: Errors.