Embeddings
Turn text into vectors with ai.embed() — a Pro feature. Which providers support it, batching, dimensions, and the normalized EmbedResult.
Pro Embeddings turn text into a numeric vector you can use for
semantic search, clustering, or retrieval-augmented generation. ai.embed()
returns the same normalized shape on every provider that supports it.
Embeddings are a Pro feature on any provider — set a licenseKey and call
await ai.init() first. See Free vs. Pro.
const { embeddings } = await ai.embed({
provider: "openai",
input: ["hello world", "goodbye world"],
});
embeddings[0]; // number[] — the vector for "hello world"
embeddings[1]; // number[] — the vector for "goodbye world"Vectors come back in input order, one per input string.
Single or batch input
input takes one string or an array. A single string still returns an array with
one vector.
const one = await ai.embed({ provider: "openai", input: "just one string" });
one.embeddings[0]; // number[]Which providers support embeddings
Not every provider has an embeddings endpoint. Those that don't report
capabilities.embeddings: false and throw
UnsupportedOperationError from embed() — never a silent
empty result.
| Provider | Embeddings | Default embedding model |
|---|---|---|
openai | ✅ | text-embedding-3-small |
google | ✅ | text-embedding-004 |
mistral | ✅ | mistral-embed |
together | ✅ | BAAI/bge-base-en-v1.5 |
ollama | ✅ | nomic-embed-text |
anthropic | ❌ | — (recommends a dedicated embeddings provider) |
groq | ❌ | — |
deepseek | ❌ | — |
xai | ❌ | — |
openrouter | ❌ | — (gateway routes chat, not embeddings) |
Mix providers freely
You can configure one provider for chat and another for embeddings in the same
RadonAI — e.g. anthropic for chat plus openai for embeddings. Each call names
its own provider.
Choosing the model
Set model per call, or defaultEmbeddingModel per provider in config. Otherwise
the provider's default embedding model (above) is used.
await ai.embed({
provider: "openai",
model: "text-embedding-3-large",
input: "custom model per call",
});Reducing dimensions
Where the provider supports truncation, dimensions requests a smaller vector.
await ai.embed({
provider: "openai",
input: "shorter vector, please",
dimensions: 256,
});dimensions maps to OpenAI's dimensions and Gemini's outputDimensionality.
Providers that don't support truncation ignore it — check the provider's docs for
which models allow it.
The result
embeddingsnumber[][]One embedding vector per input string, in the same order as input.
providerstringThe provider that produced the embeddings.
modelstringThe embedding model used.
usageUsage | undefinedToken accounting, when the provider reports it.
rawunknownThe untouched provider response.
Guarding against unsupported providers
Check the capability before calling if the provider is dynamic:
import { UnsupportedOperationError } from "@radonsdk/ai";
const provider = await ai.provider("groq");
if (provider.capabilities.embeddings) {
await ai.embed({ provider: "groq", input: text });
} else {
// groq has no embeddings endpoint — use openai/google/mistral/together/ollama
}Next steps
Tool calling
Define one tool schema and it works on every provider. The request-run-respond loop, toolChoice, parsed toolCalls, parallel calls, and InvalidToolArgumentsError.
Vision
Send images to multimodal models with content parts — a Pro feature. URL vs. inline base64, the Gemini URL caveat, and choosing a vision-capable model.