> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lancedb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Voyage AI

Voyage AI provides cutting-edge embedding and rerankers.

Using voyageai API requires voyageai package, which can be installed using `pip install voyageai`. Voyage AI embeddings are used to generate embeddings for text data. The embeddings can be used for various tasks like semantic search, clustering, and classification.
You also need to set the `VOYAGE_API_KEY` environment variable to use the Voyage AI API.

```bash Bash icon="terminal" theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
export VOYAGE_API_KEY="your-api-key"
```

Supported models are:

* voyage-4-large (best retrieval quality, 1024 default dimensions, supports 256/512/1024/2048)
* voyage-4 (balanced general-purpose, 1024 default dimensions, supports 256/512/1024/2048)
* voyage-4-lite (optimized for latency/cost, 1024 default dimensions, supports 256/512/1024/2048)
* voyage-context-3
* voyage-3.5
* voyage-3.5-lite
* voyage-3
* voyage-3-lite
* voyage-finance-2
* voyage-multilingual-2
* voyage-law-2
* voyage-code-2
* voyage-multimodal-3.5 (multimodal - supports text, images, and video)

> [!NOTE]
>
> **Multimodal Model:** `voyage-multimodal-3.5` supports text, images, and video inputs. It outputs 1024-dimensional embeddings by default, configurable via the `output_dimension` parameter (256, 512, 1024, 2048). See the [Voyage AI multimodal embeddings documentation](https://docs.voyageai.com/docs/multimodal-embeddings) for more details.

Supported parameters (to be passed in `create` method) are:

| Parameter | Type | Default Value | Description |
| - | - | - | - |
| `name` | `str` | `None` | The model ID of the model to use. Supported models: voyage-4-large, voyage-4, voyage-4-lite, voyage-3, voyage-3-lite, voyage-3.5, voyage-3.5-lite, voyage-context-3, voyage-finance-2, voyage-multilingual-2, voyage-law-2, voyage-code-2, voyage-multimodal-3.5 |
| `input_type` | `str` | `None` | Type of the input text. Default to None. Other options: query, document. |
| `truncation` | `bool` | `True` | Whether to truncate the input texts to fit within the context length. |
| `output_dimension` | `int` | `None` | Output embedding dimension. Only supported by `voyage-multimodal-3.5`. Valid options: 256, 512, 1024 (default), 2048. |

For text models, `compute_source_embeddings()` accepts a single string, a list of strings, a one-dimensional NumPy array, or a PyArrow `Array` or `ChunkedArray`. Batch inputs retain their order.

Usage Example:

```python Python icon="python" theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
import tempfile
from pathlib import Path

import lancedb
from lancedb.embeddings import EmbeddingFunctionRegistry
from lancedb.pydantic import LanceModel, Vector

voyageai = (
    EmbeddingFunctionRegistry.get_instance().get("voyageai").create(name="voyage-3")
)

class TextModel(LanceModel):
    text: str = voyageai.SourceField()
    vector: Vector(voyageai.ndims()) = voyageai.VectorField()

data = [{"text": "hello world"}, {"text": "goodbye world"}]

db = lancedb.connect(str(Path(tempfile.mkdtemp()) / "voyageai-demo"))
tbl = db.create_table("test", schema=TextModel, mode="overwrite")

tbl.add(data)
```

### Multimodal Example

The `voyage-multimodal-3.5` model can embed text alongside images. You can use image URLs, local `pathlib.Path` objects, raw image bytes, or PIL Image objects.

For source embeddings, PIL images and images loaded from bytes or local paths are
converted to RGB and encoded as JPEG. This supports RGBA, grayscale with alpha,
and palette images; transparency is discarded. Composite transparent images onto
your chosen background before embedding if the background color matters.

```python Python icon="python" theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
import tempfile
from pathlib import Path

import lancedb
from lancedb.embeddings import EmbeddingFunctionRegistry
from lancedb.pydantic import LanceModel, Vector

# Create multimodal embedding function with custom dimension
voyageai = (
    EmbeddingFunctionRegistry.get_instance()
    .get("voyageai")
    .create(name="voyage-multimodal-3.5", output_dimension=512)
)

class ImageModel(LanceModel):
    image_uri: str = voyageai.SourceField()
    vector: Vector(voyageai.ndims()) = voyageai.VectorField()

db = lancedb.connect(str(Path(tempfile.mkdtemp()) / "voyageai-multimodal"))
tbl = db.create_table("images", schema=ImageModel, mode="overwrite")

# Add images using URLs
tbl.add(
    [
        {
            "image_uri": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/300px-PNG_transparency_demonstration_1.png"
        },
    ]
)

# Search with text query
results = tbl.search("dice").limit(1).to_list()
print(results)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.