https://api.lazu.ai/v1/embeddingsEmbeddings
Turn text into vectors for semantic search, RAG, clustering and deduplication with any OpenAI-compatible client. The model catalog lists which models serve embeddings, their per-input token limit and the parameters they ignore.
BillingUsage tokens at the selected model and lane price; other billable dimensions may apply. Pricing & lanes ↗
Request body
modelstringrequiredEmbedding model ID from /api/models/catalog, for example
BAAI/bge-m3.
inputstring | string[] | integer[] | integer[][]requiredOne text, an ordered batch of texts, or input that is already tokenized (an array of token ids, or a batch of them). The response keeps the input order. Token ids are counted one token each; not every model accepts them.
dimensionsintegernullableOutput size for models that can shorten their vectors, such as
text-embedding-3-*. Models with a fixed size list
dimensions in the catalog's unsupported_params
and always return their native size.
encoding_formatstringnullableOutput encoding. Models that list it in unsupported_params
always return floats.
floatbase64userstringnullableYour end-user identifier, passed through for abuse monitoring.
Response
objectstringAlways list.
dataobject[]One item per input, in input order.
data[].indexintegerPosition of the input this vector belongs to.
data[].embeddingnumber[] | stringThe vector, or a base64 string when encoding_format is
base64 and the model supports it.
modelstringThe model ID you sent, whichever provider served the request.
usage.prompt_tokensintegerInput tokens billed for this request.
usage.total_tokensintegerSame as prompt_tokens: embeddings have no output tokens.
usage.costnumberAmount charged in USD. The x-lazu-cost-usd response header
carries the same value.
{
"object": "list",
"data": [
{ "object": "embedding", "index": 0, "embedding": [-0.0338, 0.0174, -0.0461] },
{ "object": "embedding", "index": 1, "embedding": [-0.0412, 0.0209, -0.0397] }
],
"model": "BAAI/bge-m3",
"usage": { "prompt_tokens": 14, "total_tokens": 14, "cost": 0.000001 }
}Example: semantic search
Embed the documents once, embed each query, and rank by cosine similarity.
BAAI/bge-m3 maps more than 100 languages into one space, so an English query
finds Chinese or Japanese documents without translation.
import numpy as np
from openai import OpenAI
client = OpenAI(base_url="https://api.lazu.ai/v1", api_key="YOUR_LAZU_KEY")
docs = [
"Reset your password from Settings → Security.",
"账单每月 1 日生成,可在控制台下载发票。",
"API キーはプロジェクトごとに発行できます。",
]
def embed(texts):
resp = client.embeddings.create(model="BAAI/bge-m3", input=texts)
vectors = np.array([item.embedding for item in resp.data])
return vectors / np.linalg.norm(vectors, axis=1, keepdims=True)
doc_vectors = embed(docs)
query_vector = embed(["Where can I download my invoice?"])[0]
scores = doc_vectors @ query_vector
for index in scores.argsort()[::-1]:
print(f"{scores[index]:.3f} {docs[index]}")Limits
- Per-input token limit. The catalog's
input_limitis the most tokens one input may hold (8192 forBAAI/bge-m3). A longer input is refused with400 context_length_exceeded(LZ-1005) and costs nothing. Split long documents into chunks below the limit; a few hundred to a thousand tokens per chunk usually retrieves better anyway. - Batches. Send an array to embed several texts in one request. For large jobs, send batches of tens to a few hundred inputs and retry a failed batch rather than one huge request.
- Empty input. An empty string is refused by most models; drop empty chunks before sending.
Billing
Embeddings bill input tokens only, at the model's input price on
Pricing & lanes. When the provider reports how many tokens
it read, that count is billed. When it does not, Lazu counts the input with a
standard tokenizer; that count can differ by a few percent from the model's own
tokenizer, in either direction depending on the language. Failed requests are
not charged. Each request's billed tokens and amount are in usage and in the
request detail.
Common models
| Model | Dimensions | Max input tokens | Custom dimensions | Notes |
|---|---|---|---|---|
BAAI/bge-m3 | 1024 | 8192 | No | Open weights, 100+ languages |
text-embedding-3-small | 1536 | 8191 | Yes | OpenAI, low cost |
text-embedding-3-large | 3072 | 8191 | Yes | OpenAI, highest quality |
gemini-embedding-001 | 3072 | 2048 | Yes (768, 1536) |
Which of these your key can call depends on the deployment; the catalog is the source of truth.
See also
curl https://api.lazu.ai/v1/embeddings \
-H "Authorization: Bearer $LAZU_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6-luna",
"input": ["How do I reset my password?", "如何重置密码?"]
}'
{
"object": "list",
"data": [
{ "object": "embedding", "index": 0, "embedding": [-0.0338, 0.0174, -0.0461] },
{ "object": "embedding", "index": 1, "embedding": [-0.0412, 0.0209, -0.0397] }
],
"model": "BAAI/bge-m3",
"usage": { "prompt_tokens": 14, "total_tokens": 14, "cost": 0.000001 }
}
- Request ID
- req_demo_01
- Model · Lane
- text-embedding-3-small · stable
- Tokens · input
- 1,200
- Key
- demo-key
Example only — not a quote and not the result of your request. Send the request above to see your own receipt.
Read a real request receipt →Catalog filter
supported_endpoint_types includes embeddings