Embeddings API Reference
The maticlib.embeddings module provides a consistent interface for generating text embeddings using various cloud providers.
Base Class
maticlib.embeddings.base.BaseEmbeddings
Bases: ABC
Abstract base class for all embedding models.
embed_documents
abstractmethod
Generates embeddings for a list of document strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
texts
|
List[str]
|
A list of texts to embed. |
required |
Returns:
| Type | Description |
|---|---|
EmbedDocumentsResponse
|
An EmbedDocumentsResponse containing the list of vectors and usage metadata. |
Source code in maticlib/embeddings/base.py
embed_query
abstractmethod
Generates an embedding for a single query string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The text to embed. |
required |
Returns:
| Type | Description |
|---|---|
EmbedQueryResponse
|
An EmbedQueryResponse containing the vector and usage metadata. |
Source code in maticlib/embeddings/base.py
OpenAI Embeddings
maticlib.embeddings.openai.OpenAIEmbeddings
Bases: BaseEmbeddings
Client for interacting with OpenAI Embedding models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
str
|
The OpenAI embedding model to use. Defaults to "text-embedding-3-small". |
'text-embedding-3-small'
|
api_key
|
Optional[str]
|
Your OpenAI API key. Falls back to OPENAI_API_KEY environment variable. |
None
|
dimensions
|
Optional[int]
|
The number of dimensions the resulting output embeddings should have. Only supported in text-embedding-3 and later models. |
None
|
verbose
|
bool
|
If True, prints status messages to console. |
True
|
Source code in maticlib/embeddings/openai.py
embed_documents
Embed a list of document strings.
Source code in maticlib/embeddings/openai.py
embed_query
Embed a single query string.
Source code in maticlib/embeddings/openai.py
Google GenAI Embeddings
maticlib.embeddings.google.GoogleGenAIEmbeddings
GoogleGenAIEmbeddings(
model="gemini-embedding-001",
api_key=None,
task_type="RETRIEVAL_DOCUMENT",
verbose=True,
)
Bases: BaseEmbeddings
Client for interacting with Google's Generative AI (Gemini) Embedding models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
str
|
The Gemini embedding model to use. Defaults to "gemini-embedding-001". |
'gemini-embedding-001'
|
api_key
|
Optional[str]
|
Your Google AI API key. Falls back to GOOGLE_API_KEY or GEMINI_API_KEY. |
None
|
task_type
|
str
|
The type of task the embedding will be used for. Common values: "RETRIEVAL_QUERY", "RETRIEVAL_DOCUMENT", "SEMANTIC_SIMILARITY". |
'RETRIEVAL_DOCUMENT'
|
verbose
|
bool
|
If True, prints status messages to console. |
True
|
Source code in maticlib/embeddings/google.py
embed_documents
Embed a list of document strings using batchEmbedContents.
Source code in maticlib/embeddings/google.py
embed_query
Embed a single query string.
Source code in maticlib/embeddings/google.py
Mistral Embeddings
maticlib.embeddings.mistral.MistralEmbeddings
Bases: BaseEmbeddings
Client for interacting with Mistral AI Embedding models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
str
|
The Mistral embedding model to use. Defaults to "mistral-embed". |
'mistral-embed'
|
api_key
|
Optional[str]
|
Your Mistral API key. Falls back to MISTRAL_API_KEY environment variable. |
None
|
verbose
|
bool
|
If True, prints status messages to console. |
True
|
Source code in maticlib/embeddings/mistral.py
embed_documents
Embed a list of document strings.
Source code in maticlib/embeddings/mistral.py
embed_query
Embed a single query string.