Embedding options including model, input text(s), and optional provider/key overrides.
A promise resolving to the embedding vectors, provider metadata, and token usage.
When provider resolution fails (missing API key, unknown provider, etc.).
When the call resolves to a provider with no embeddings embedText can send to (Anthropic, Groq, Together AI, xAI, MiniMax, the image providers and the CLIs), whatever its base URL and with or without a model; its key is not read and no request is sent.
When the call resolves to a provider agentos does not know and no base URL is set, on the call or on the global default; no request is sent.
When the embedding API returns a non-2xx status.
import { embedText } from '@framers/agentos';
// Single input
const { embeddings } = await embedText({
provider: 'openai',
model: 'text-embedding-3-small',
input: 'Hello world',
});
console.log(embeddings[0].length); // 1536
// Batch with reduced dimensions
const batch = await embedText({
provider: 'openai',
model: 'text-embedding-3-small',
input: ['Hello', 'World'],
dimensions: 256,
});
console.log(batch.embeddings.length); // 2
console.log(batch.embeddings[0].length); // 256
Generates embedding vectors for one or more text inputs using a provider-agnostic
provider:modelstring.Resolves credentials via the standard AgentOS provider pipeline, then dispatches to the provider's own embedding endpoint (OpenAI, OpenRouter, Mistral, Requesty, Ollama or Gemini) or to the base URL the caller set; a provider's key goes to no other host. Returns raw float arrays suitable for vector similarity search, clustering, or any downstream ML pipeline.