Embeddings
Create normalized vectors with an explicit physical embedding model.
Use an enabled embedding model with provider credentials and gateway execute permission. Discover models through nirmos.models.list({ capability: "embeddings" }). Use a provider-qualified model identifier; embedding requests do not select routes or virtual aliases.
const response = await nirmos.gateway.embeddings.create({
model: "configured/embedding-model",
input: ["Nirmos provides model routing.", "Prompt releases are versioned."],
encoding: "float",
});
for (const embedding of response.embeddings) {
console.log(embedding.index, embedding.values?.length, embedding.base64);
}Model names beginning with configured/ are placeholders. Replace them with an accessible provider-qualified identifier from model discovery. The snippets reuse the server client from the quickstart.
Request and response
EmbeddingCreateParams requires model and input (one string or a readonly array). Optional fields are dimensions, encoding (float or base64), user and provider. Dimensions and encoding support depend on the provider/model; Google returns float embeddings only.
EmbeddingResponse contains model, ordered/indexed embeddings, normalized usage and request metadata. Each Embedding is either numeric values or base64, never both in the declared union. Preserve indices when mapping a batch back to input. Missing provider usage becomes zero in SDK normalization.
Vector-space safety
fallbackModels and routingStrategy remain exported for compatibility but are deprecated and rejected by current runtime. Do not switch embedding models on failure: different models create different vector spaces. SDK POST transport does not retry automatically without eligibility; runtime same-model retries are a separate layer.
For document ingestion/retrieval, Knowledge and Memory persist model/dimension configuration. The SDK does not provide a general standalone vector storage or vector math library.
Gateway reference · Embedding types · Model discovery
OpenRouter and Workers AI
Seeded OpenRouter text-embedding-3-small/large and Cloudflare BGE Base/Large use this existing method. Cloudflare requires account ID plus API token; BGE Base is fixed at 768 dimensions and BGE Large at 1024. Read catalog dimensions before choosing a Knowledge or Memory vector space. Groq does not provide an embedding path. See provider configuration.