Embeddings
The Embeddings endpoint turns text into vectors you can store and compare, for search, clustering or recommendations. It is OpenAI-compatible: same request, same response.
Create embeddings
Response:
Vectors are shortened here. data[i].index matches the position of the input.
Models
The price book currently sells text-embedding-3-small and text-embedding-3-large. Call models.list() for the live list. A model that is not priced returns 403 with code model_not_priced. A model that is not an embedding model returns 400 with code model_not_found.
Use dimensions to get shorter vectors from the text-embedding-3 models:
Encoding format
When you leave out encoding_format, the SDK asks for compact base64 on the wire and decodes it into number[] for you. OpenAI's SDK does the same. Base64 responses are smaller than JSON floats.
If you set encoding_format, the SDK sends it unchanged and does not decode:
"float":embeddingis anumber[]."base64":embeddingis a base64 string of little-endian float32 values. The return type isCreateEmbeddingResponse<string>.
Over plain HTTP (curl), the API returns floats unless you send "encoding_format": "base64". The gateway passes either format through untouched.
Method
glexir.embeddings.create()
POST /embeddings. options are the per-request options described in Client configuration.
modelEmbeddingModelrequired- An embedding model ID. The type suggests text-embedding-3-small, text-embedding-3-large and text-embedding-ada-002 and accepts any string; only priced models work.
inputstring | string[] | number[] | number[][]required- Text, a list of texts, or token arrays. Each input at most 8,192 tokens, at most 2,048 inputs, at most 300,000 tokens per request. Missing input returns 400.
dimensionsnumberoptional- Output vector size. text-embedding-3 models only.
encoding_format"float" | "base64"optional- Leave it out to get decoded number[] vectors. See Encoding format above.
userstringoptional- Your end user's ID. Glexir replaces it with an identifier derived from your organization and this value before forwarding, so OpenAI's abuse checks apply to the right customer.
EmbeddingCreateParams also accepts other keys, which are sent as-is.
Response
object"list"required- Always list.
dataEmbedding<TVector>[]required- One entry per input, in input order.
modelstringrequired- The model that produced the vectors.
usage{ prompt_tokens: number; total_tokens: number }required- Tokens billed for the request.
_request_idstring | nulloptional- SDK only. The x-request-id header.
object"embedding"required- Always embedding.
indexnumberrequired- Position of the matching input.
embeddingTVectorrequired- The vector: number[] by default, string when you asked for base64.
Billing
Embeddings are billed per input token at the model's embedding rate, from usage.prompt_tokens. There is no output charge. Before the call, Glexir reserves an estimate of the input cost as a hold and settles it against the real usage when the response arrives. See Credits & billing and Pricing.
Through Batches (/v1/embeddings), embeddings cost half the standard rate.
Errors
| Status | Code | When |
|---|---|---|
| 400 | model_not_found | model is missing or is not an embedding model. |
| 400 | none | input is missing, or the body is not a JSON object. |
| 402 | credit_balance_exhausted | Your balance cannot cover the hold. |
| 402 | spend_limit_exceeded | The request would pass a monthly spend limit. |
| 403 | model_not_priced | The model is not sold on Glexir. |
| 429 | rate_limit_exceeded, concurrency_limit_exceeded | Too many requests per minute, or too many in flight. |
See HTTP error codes for the full list.