Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content
Endpoints / Vectors
POSThttps://api.lazu.ai/v1/embeddings

Embeddings

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

modelstringrequired

Embedding model ID from /api/models/catalog, for example BAAI/bge-m3.

inputstring | string[] | integer[] | integer[][]required

One 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.

dimensionsintegernullable

Output 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_formatstringnullable

Output encoding. Models that list it in unsupported_params always return floats.

floatbase64
userstringnullable

Your end-user identifier, passed through for abuse monitoring.

Response

objectstring

Always list.

dataobject[]

One item per input, in input order.

data[].indexinteger

Position of the input this vector belongs to.

data[].embeddingnumber[] | string

The vector, or a base64 string when encoding_format is base64 and the model supports it.

modelstring

The model ID you sent, whichever provider served the request.

usage.prompt_tokensinteger

Input tokens billed for this request.

usage.total_tokensinteger

Same as prompt_tokens: embeddings have no output tokens.

usage.costnumber

Amount 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_limit is the most tokens one input may hold (8192 for BAAI/bge-m3). A longer input is refused with 400 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

ModelDimensionsMax input tokensCustom dimensionsNotes
BAAI/bge-m310248192NoOpen weights, 100+ languages
text-embedding-3-small15368191YesOpenAI, low cost
text-embedding-3-large30728191YesOpenAI, highest quality
gemini-embedding-00130722048Yes (768, 1536)Google

Which of these your key can call depends on the deployment; the catalog is the source of truth.

See also

Sent from your browser to api.lazu.ai · key stays in this tab
RequestPOST /v1/embeddings
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?", "如何重置密码?"]
  }'
ResponseExample
{
  "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 receiptIllustrative example
$0.0001200 · 842 ms
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