Embeddings
Give the server an embedding model and a namespace can embed one text attribute itself: rows are written without vectors, and queries rank by text. Embeddings are cached, so repeated texts and queries skip the provider.
Embedding is an opt-in convenience. Writes and queries always accept vectors you compute yourself: without an embedding section in the server config, or in namespaces without an embed attribute, vectors are sent as usual, and even in a namespace that embeds, any row may carry its own vector and any query may rank by vector instead of text.
Configuring a model
The server talks to providers through Rig, so one config shape covers every provider:
provider | API | Example model |
|---|---|---|
openai | OpenAI, or any OpenAI-compatible endpoint: Azure OpenAI, vLLM, Ollama, LiteLLM | text-embedding-3-small |
cohere | Cohere v1/embed | embed-v4.0 |
gemini | Google Gemini | gemini-embedding-001 |
bedrock | Amazon Bedrock: Titan Text Embeddings v2, Cohere Embed v3 and v4 | amazon.titan-embed-text-v2:0, cohere.embed-v4:0 |
# cluster.yaml
embedding:
provider: openai
model: text-embedding-3-small
api_key: { source: env, name: OPENAI_API_KEY } # or source: file
dimensions: 512 # optional: shorter vectors
# endpoint: http://ollama:11434/v1 # optional API root
batch_size: 96 # texts per request
timeout: 30 # seconds
cache:
capacity: 67108864 # bytes; 0 disables
max_input_chars: 24573 # optional: longest text sent to the model
split: # passages of documents written without any
max_chars: 8000 # optional
overlap_chars: 0api_key is read on every request, so a rotated key file applies without a restart. Endpoints that need no key, such as a local Ollama, can leave it out. Without dimensions, the server learns the model's vector length by embedding one probe text the first time it needs it. dimensions shortens vectors for models that support it: OpenAI's text-embedding-3-*, Gemini, Titan v2 (256, 512 or 1024), and Cohere Embed v4 on Bedrock (256, 512, 1024 or 1536). Cohere's own API embeds at a fixed size, so dimensions is rejected for cohere.
Cohere models, on Cohere's API or Bedrock, embed documents and queries differently: rows are embedded as search_document and query texts as search_query. The other models embed both the same way.
Amazon Bedrock
Bedrock authenticates with the AWS credential chain rather than api_key: an IAM role (IRSA or EKS Pod Identity on Kubernetes), the usual AWS_* environment variables, or a Bedrock API key in AWS_BEARER_TOKEN_BEDROCK. region picks the runtime endpoint, and defaults to the chain's region. endpoint doesn't apply.
embedding:
provider: bedrock
model: amazon.titan-embed-text-v2:0
region: us-east-1
dimensions: 512 # optional: 256, 512 or 1024 (the default)embedding:
provider: bedrock
model: us.cohere.embed-v4:0 # or cohere.embed-english-v3, cohere.embed-multilingual-v3
region: us-east-2
dimensions: 1024 # optional, v4 only: 256, 512, 1024 or 1536 (the default)The supported models are Titan Text Embeddings v2 and Cohere Embed v3 (English or multilingual) and v4; model can also be a cross-region inference profile id or ARN for one of them, such as us.cohere.embed-v4:0 or global.cohere.embed-v4:0. Where Bedrock serves a model only through inference profiles, as it does Cohere Embed v4 in most regions, the bare model id fails with "on-demand throughput isn't supported" and model must be a profile. The role then needs bedrock:InvokeModel on the profile and on the foundation model in every region the profile routes to. Namespaces pin the foundation model id without the profile, so moving between profiles of one model keeps existing namespaces usable. Application inference profiles aren't supported, because their ARNs don't name the model. Titan embeds one text per request, so a batch is sent as consecutive requests. Cohere models take up to 96 texts per request, so batch_size can't exceed 96 for them. Cohere Embed v3 embeds at a fixed 1024 dimensions, and Bedrock rejects v3 texts over 2,048 characters, which the server's input limit keeps them under.
On Kubernetes
Set spec.config.embedding on the Vector resource. The operator copies the key from apiKeySecretRef into the config Secret and points the servers at it:
apiVersion: telemetry.plural.sh/v1alpha1
kind: Vector
metadata:
name: vector
spec:
config:
embedding:
provider: cohere
model: embed-v4.0
apiKeySecretRef: { name: cohere, key: api-key }
cacheSize: 128Mi # per replica; 0 disables
split: { maxChars: 4000, overlapChars: 200 } # optional; also maxInputCharsFor Bedrock, leave out apiKeySecretRef and give the pods AWS credentials instead, for example an IAM role allowed bedrock:InvokeModel, through the ServiceAccount:
spec:
serviceAccount:
annotations:
eks.amazonaws.com/role-arn: arn:aws:iam::123456789012:role/vector
config:
embedding:
provider: bedrock
model: cohere.embed-v4:0
region: us-east-1Every writer and reader gets the same model: writers embed rows, and readers embed query texts. Rotating the key Secret reaches running pods when the kubelet refreshes their Secret volume, without a restart. Changing the model, endpoint, or any other field restarts them.
Embedding an attribute
Mark one string attribute embed in a namespace's schema. A namespace created this way can leave out dimensions and take the model's:
curl -X POST localhost:8080/api/v1/namespaces/articles/write \
-H 'content-type: application/json' \
-d '{
"schema": { "body": { "type": "string", "embed": true, "full_text_search": true } },
"upsert_rows": [
{ "id": 1, "title": "Rotating credentials", "body": "Rotate keys every 90 days…" },
{ "id": 2, "title": "Draft", "body": "…", "vector": [0.1, 0.2, …] }
]
}'Rows are embedded only when they are written without a vector:
- Upserts and documents. A row or passage without a vector gets the embedding of its
embedattribute. A row with neither is rejected with400. A passage can inherit the attribute from its document'sattributes, and a document without passages is split into them. - Patches. A patch that sets the
embedattribute re-embeds the row, unless it setsvectortoo. Removing the attribute withnullkeeps the old vector. - Explicit vectors. A
vectorin the request is always used as given, for example to import vectors computed elsewhere with the same model.
The texts of one request are embedded together, in batches of batch_size. With the cache enabled, that happens before the namespace's write lock is taken, so a slow provider doesn't hold up other writes to the namespace. A provider failure fails the write with 502. Upserted rows and documents are embedded before any operation applies; patches are re-embedded as they apply, after the operations before them.
An embedded attribute is stored like any other, so it can also be returned, filtered, and declared full_text_search for hybrid search.
Input limits and splitting
The server sizes text for the model, so clients don't need to know its context window.
Every text is cut to the model's input limit before it's embedded: rows, passages, patches, and query texts alike. The attribute is still stored whole; only the text sent to the model is cut. The limit is max_input_chars, or without it the model's own:
| Model | Default limit, in characters |
|---|---|
| OpenAI and OpenAI-compatible endpoints | 24,573 (8,191 tokens) |
| Cohere v3 models, on Cohere's API | 1,536 (512 tokens) |
| Cohere v3 models, on Bedrock | 2,048, Bedrock's cap |
| Cohere Embed v4, on either API | 384,000 (128k tokens) |
| Gemini | 6,144 (2,048 tokens) |
| Titan Text Embeddings v2 | 24,576 (8,192 tokens) |
Limits given in tokens are converted at 3 characters per token, which leaves room for code and JSON, as they tokenize more densely than prose. Models served by OpenAI-compatible endpoints such as vLLM or Ollama are assumed to take as much as OpenAI's; set max_input_chars for ones that take less.
Documents written without passages are split by the server. The document's embed attribute is split into passages of at most split.max_chars characters (8,000 by default, or the input limit if that's smaller), and each passage row holds its part of the text in that attribute alongside the document's other attributes. Splits fall at the coarsest boundary that fits: paragraphs, then lines, sentences, words, and as a last resort mid-word. With split.overlap_chars, each passage starts with up to that much of the previous one's end, so text near a boundary can be found from either side.
curl -X POST localhost:8080/api/v1/namespaces/articles/write \
-H 'content-type: application/json' \
-d '{
"upsert_documents": [{
"id": "kb-42",
"attributes": { "title": "Rotating credentials", "body": "A long article…" }
}]
}'The document is stored as rows kb-42#0, kb-42#1, …, which queries collapse back to documents with limit.per. Sending passages instead keeps the split up to the client, as before. Upserting the document again re-splits it and drops passages beyond the new count. Changing the split settings applies to documents written afterwards.
Querying by text
ANN and kNN take a text in place of a vector in a namespace with an embed attribute:
{
"rank_by": { "op": "ANN", "text": "how often should keys rotate?" },
"filters": { "op": "Gte", "attribute": "year", "value": 2025 },
"top_k": 5
}Exactly one of vector and text is allowed. In a multi-query, the texts of every sub-query are embedded in one provider request, which makes hybrid search one round trip to the provider:
{
"queries": [
{ "rank_by": { "op": "ANN", "text": "rotate credentials" } },
{ "rank_by": { "op": "BM25", "attribute": "body", "query": "rotate credentials" } }
],
"rrf": {}
}Models and namespaces
Vectors from different models can't be compared, so a namespace never mixes them. When a namespace first gets an embed attribute, it pins the configured model as its embedding_model, for example openai:text-embedding-3-small:512 (provider, model, and requested dimensions). The model's vector length must equal the namespace's dimensions.
From then on, embedding in that namespace requires the server to be configured with the same model. After a model change, or with the embedding section removed, writes that need embedding and text queries in namespaces pinned to the old model fail with 400, while writes with explicit vectors and vector queries still work. To move to a new model, create a new namespace, rewrite the rows into it (they are embedded with the new model), and switch clients over.
Caching
Each replica caches embeddings in memory with foyer, up to cache.capacity bytes (64 MiB by default, about 21,000 vectors of 768 dimensions). On Kubernetes, without cacheSize, the operator sizes it from each pod's memory limit; see memory and cache sizing. Entries are keyed by a hash of the model, the input kind (document or query), and the exact text. A row upserted again with the same text, a patch that sets the text back, and a repeated query all skip the provider. Within one request, duplicate texts are sent once.
| Metric | Meaning |
|---|---|
vector_embedding_cache_hits_total | Texts served from the cache |
vector_embedding_cache_misses_total | Distinct texts sent to the provider |
vector_embedding_request_duration_seconds | Provider request latency |
vector_embedding_request_errors_total | Failed provider requests |