Skip to content

feat: Add output_dimension support for Voyage AI embeddings#2593

Closed
lagiosv wants to merge 1 commit intoHKUDS:mainfrom
lagiosv:feat/voyage-ai-dimensions
Closed

feat: Add output_dimension support for Voyage AI embeddings#2593
lagiosv wants to merge 1 commit intoHKUDS:mainfrom
lagiosv:feat/voyage-ai-dimensions

Conversation

@lagiosv
Copy link
Copy Markdown

@lagiosv lagiosv commented Jan 16, 2026

Summary

This PR adds support for custom embedding dimensions when using Voyage AI's embedding models through the OpenAI-compatible API.

Problem

LightRAG's OpenAI embedding binding passes the dimensions parameter directly to the API. However, Voyage AI's OpenAI-compatible endpoint requires the dimension parameter to be passed as output_dimension via the extra_body parameter.

Without this fix:

  • embedding_dim is configured (e.g., 2048)
  • Voyage AI ignores the dimensions parameter
  • Voyage AI returns 1024-dimensional vectors (default)
  • Dimension mismatch errors occur with vector stores

Related issues: #2233, #2230, #2119

Solution

Detect Voyage AI by checking if base_url contains "voyageai.com" and route the dimension parameter appropriately:

  • For Voyage AI: pass output_dimension via extra_body parameter
  • For OpenAI and others: pass dimensions directly (existing behavior)

Changes

lightrag/llm/openai.py

# Add dimensions parameter only if embedding_dim is provided
if embedding_dim is not None:
    # Voyage AI requires 'output_dimension' via extra_body, not 'dimensions'
    is_voyage_ai = base_url and "voyageai.com" in base_url
    if is_voyage_ai:
        api_params["extra_body"] = {"output_dimension": embedding_dim}
    else:
        api_params["dimensions"] = embedding_dim

Testing

Tested with:

  • Voyage AI voyage-3-large model
  • embedding_dim=2048
  • Qdrant vector store

Verified embeddings are correctly 2048-dimensional.

Backwards Compatibility

  • No breaking changes
  • Existing OpenAI configurations work unchanged
  • Only affects Voyage AI when embedding_dim is explicitly set

Voyage AI's OpenAI-compatible API requires `output_dimension` to be
passed via `extra_body` parameter instead of the standard `dimensions`
parameter used by OpenAI.

This change detects Voyage AI by checking if the base_url contains
"voyageai.com" and routes the embedding_dim parameter appropriately:
- For Voyage AI: passes `output_dimension` via `extra_body`
- For OpenAI and others: passes `dimensions` directly (existing behavior)

This fixes dimension mismatch issues when using Voyage AI models like
voyage-3-large with custom dimensions (e.g., 2048 instead of default 1024).

Related issues: #2233, #2230, #2119
@lagiosv lagiosv closed this by deleting the head repository Feb 13, 2026
@danielaskdd danielaskdd added the enhancement New feature or request label Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants