# EmbeddingsLambda

> **Class** in `langgraph.store`

📖 [View in docs](https://reference.langchain.com/python/langgraph.store/base/embed/EmbeddingsLambda)

Wrapper to convert embedding functions into LangChain's Embeddings interface.

This class allows arbitrary embedding functions to be used with LangChain-compatible
tools. It supports both synchronous and asynchronous operations, and can handle:
1. A synchronous function for sync operations (async operations will use sync function)
2. An async function for both sync/async operations (sync operations will raise an error)

The embedding functions should convert text into fixed-dimensional vectors that
capture the semantic meaning of the text.

## Signature

```python
EmbeddingsLambda(
    self,
    func: EmbeddingsFunc | AEmbeddingsFunc,
)
```

## Description

??? example "Examples"

With a sync function:

```python
def my_embed_fn(texts):
    # Return 2D embeddings for each text
    return [[0.1, 0.2] for _ in texts]

embeddings = EmbeddingsLambda(my_embed_fn)
result = embeddings.embed_query("hello")  # Returns [0.1, 0.2]
await embeddings.aembed_query("hello")  # Also returns [0.1, 0.2]
```

With an async function:

```python
async def my_async_fn(texts):
    return [[0.1, 0.2] for _ in texts]

embeddings = EmbeddingsLambda(my_async_fn)
await embeddings.aembed_query("hello")  # Returns [0.1, 0.2]
# Note: embed_query() would raise an error
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `func` | `EmbeddingsFunc \| AEmbeddingsFunc` | Yes | Function that converts text to embeddings. Can be sync or async. If async, it will be used for async operations, but sync operations will raise an error. If sync, it will be used for both sync and async operations. |

## Extends

- `Embeddings`

## Constructors

```python
__init__(
    self,
    func: EmbeddingsFunc | AEmbeddingsFunc,
) -> None
```

| Name | Type |
|------|------|
| `func` | `EmbeddingsFunc \| AEmbeddingsFunc` |


## Properties

- `afunc`
- `func`

## Methods

- [`embed_documents()`](https://reference.langchain.com/python/langgraph.store/base/embed/EmbeddingsLambda/embed_documents)
- [`embed_query()`](https://reference.langchain.com/python/langgraph.store/base/embed/EmbeddingsLambda/embed_query)
- [`aembed_documents()`](https://reference.langchain.com/python/langgraph.store/base/embed/EmbeddingsLambda/aembed_documents)
- [`aembed_query()`](https://reference.langchain.com/python/langgraph.store/base/embed/EmbeddingsLambda/aembed_query)

---

[View source on GitHub](https://github.com/langchain-ai/langgraph/blob/1a9baae9592e0c21336f6e09c891ba75481fd657/libs/checkpoint/langgraph/store/base/embed.py#L109)