Skip to content

Embeddings

POST /v1/embeddings with model: "embed" returns dense vectors from BGE-M3: 1 024 dimensions, trained on more than 100 languages, strong on Polish. Only input tokens are billed.

from openai import OpenAI
import os
client = OpenAI(base_url="https://api.siema-ai.pl/v1", api_key=os.environ["SIEMA_API_KEY"])
r = client.embeddings.create(
model="embed",
input=[
"Umowa o pracę na czas nieokreślony",
"Umowa zlecenie",
"Faktura korygująca",
],
)
vectors = [d.embedding for d in r.data] # three lists of 1024 floats, in input order
print(r.usage.prompt_tokens)

input is a string or a non-empty array of strings. There’s no documented maximum number of strings per request. Two real limits apply instead: the request body itself is capped at 20 MiB by default (over that, 400 invalid_request), and a model server reply the gateway can’t relay because it exceeds 64 MiB comes back as 502 upstream_unavailable. Split a very large batch into smaller requests if you hit either one.

Each individual string can be up to the model’s context_length — 8 192 tokens for embed, provisional; read it from GET /v1/models rather than hard-coding it. A longer input is rejected by the model server itself, as 400 context_length_exceeded or a plain 400 invalid_request, depending on the message the model server returns.

Sending a chat-only alias (for example polish-pro) to /v1/embeddings returns 400 invalid_request with param: "model"; use embed.

encoding_format is float (the default) — each embedding comes back as an array of numbers — or base64, where each embedding is a base64-encoded string of little-endian float32 values. The official OpenAI SDKs can request either; some request base64 by default and decode it back into a list of floats for you before you ever see it. Both forms are fully supported; pick whichever your client library sends.

  • Compare with cosine similarity. If your vector store expects unit vectors, normalise client-side.
  • Embed queries and documents with the same alias. Mixing embedding models produces meaningless distances.
  • BGE-M3 also supports sparse and multi-vector outputs; siema_ai exposes the dense output only in V1.

Embeddings have no output tokens, so cost comes from input tokens alone. usage.prompt_tokens in the response is what you’re charged for, when the model server reports it. See Billing for how a request’s cost is computed.