Overview
embed is a convenience helper for embedding a single text value. It provides a provider-agnostic façade over any EmbeddingModel implementation with automatic retry logic and unified return objects.
Basic usage
embed.py
Parameters
Return value
EmbedResult exposes:
embedding: The embedding vector (list of floats)value: The original input textusage: Token usage statistics (if available)provider_metadata: Provider-specific metadata
Examples
Basic embedding
With custom parameters
Error handling
Custom providers
Implement theEmbeddingModel ABC to bring your own model: