Overview
Embeddings is used to turn text into vectors that capture semantic meaning, so similar texts end up close together in vector space. This makes it useful for search, clustering, recommendations, classification, anomaly detection, and semantic similarity checks like finding duplicate or related content. In practice, you often use it in retrieval-augmented generation (RAG): embed your documents, embed the user’s question, compare the vectors, and return the most relevant passages to a model. It’s also commonly used for text search and “find things like this” workflows rather than simple keyword matching. Embeddings support the same API as langchain’s embeddings abstractions, and may be used as a direct replacement for running inside Orchestrate.Initialization patterns
From Instance Credentials (Standalone/Runs-Elsewhere Mode)
PYTHON
Direct initialization (Standalone/Runs-Elsewhere Mode) (Advanced)
See ‘Advanced Configuration’ section for all available parameters.PYTHON
From RunnableConfig (Runtime/Runs-On Mode) (recommended)
PYTHON
From Execution Context (Runtime/Runs-On Mode)
PYTHON
Usage examples
Basic Embeddings
PYTHON
Async Embeddings
PYTHON
Semantic Search with Vector Store
PYTHON
RAG (Retrieval-Augmented Generation)
PYTHON
Similarity Calculation
PYTHON
Advanced Configuration
Note: additional params can be passed via direct initialization (WxOEmbeddings.__init__()) or any of the helpers (from_instance_credentials, from_runnable_config, from_execution_context, from_session).
PYTHON
Supported methods
OpenAIEmbeddings supports the following methods:embed_query(text)- Embed a single text queryembed_documents(texts)- Embed multiple documentsaembed_query(text)- Async embed a single text queryaembed_documents(texts)- Async embed multiple documents
Class methods
Embeddings supports the following class methods:from_instance_credentials(instance_url, api_key, model, **kwargs)- Create from instance credentials (standalone/runs-elsewhere)from_execution_context(execution_context, model, **kwargs)- Create from execution context (runtime/runs-on)from_session(session, model, **kwargs)- Create from AgenticSession (runtime/runs-on)from_runnable_config(config, model, **kwargs)- Create from RunnableConfig (runtime/runs-on)
Embedding model IDs
Use the model ID formats returned by the watsonx Orchestrate/models endpoint:
PYTHON
openai/text-embedding-3-smallopenai/text-embedding-3-largeopenai/text-embedding-ada-002watsonx/ibm/slate-30m-english-rtrvr
- Embeddings provides a drop-in replacement for embeddings usage in LangChain-based agents.
- The model ID must follow the format returned by the platform.
- Authentication and request routing are handled through the SDK interface.

