Radondocs

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.

embed.ts
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.

ProviderEmbeddingsDefault embedding model
openaitext-embedding-3-small
googletext-embedding-004
mistralmistral-embed
togetherBAAI/bge-base-en-v1.5
ollamanomic-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.

providerstring

The provider that produced the embeddings.

modelstring

The embedding model used.

usageUsage | undefined

Token accounting, when the provider reports it.

rawunknown

The 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

On this page