Skip to content

feat(voyageai): add output_dimension support for embeddings#904

Merged
sixlive merged 1 commit into
prism-php:mainfrom
markritterman:feature/voyageai-output-dimension
Feb 26, 2026
Merged

feat(voyageai): add output_dimension support for embeddings#904
sixlive merged 1 commit into
prism-php:mainfrom
markritterman:feature/voyageai-output-dimension

Conversation

@markritterman

Copy link
Copy Markdown
Contributor

Description

Adds outputDimension provider option support to the VoyageAI embeddings handler, allowing control over the number of dimensions in embedding responses.

Voyage AI models like voyage-4 and voyage-multimodal-3.5 support Matryoshka-style dimension truncation via the output_dimension API parameter. This was previously not forwarded by the Prism handler.

Usage

Prism::embeddings()
    ->using(Provider::VoyageAI, 'voyage-4')
    ->fromInput('some text')
    ->withProviderOptions(['outputDimension' => 2048])
    ->asEmbeddings();

When outputDimension is not set, the parameter is omitted from the request (no change in default behaviour).

Tests

  • Verifies output_dimension is included in the API request when outputDimension provider option is set
  • Verifies output_dimension is omitted from the API request when not set
  • All existing VoyageAI embeddings tests continue to pass

Allow controlling the number of dimensions in Voyage AI embedding
responses via the outputDimension provider option. This is useful
for models like voyage-4 and voyage-multimodal-3.5 that support
Matryoshka-style dimension truncation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sixlive
sixlive force-pushed the feature/voyageai-output-dimension branch from ce0c359 to f6e5bc5 Compare February 26, 2026 16:56
@sixlive
sixlive merged commit d16e98c into prism-php:main Feb 26, 2026
14 checks passed
markritterman added a commit to markritterman/ai that referenced this pull request Mar 5, 2026
The PrismGateway maps the dimensions parameter to provider-specific
options for Gemini and OpenAI but not for VoyageAI. This causes
VoyageAI to return its default 1024-dimension vectors instead of
the requested size, leading to dimension mismatches when storing
in pgvector columns configured for larger dimensions.

Prism already supports `outputDimension` as a provider option for
VoyageAI (prism-php/prism#904), so we just need to pass it through.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
taylorotwell added a commit to laravel/ai that referenced this pull request Mar 5, 2026
* fix: pass outputDimension for VoyageAI embeddings

The PrismGateway maps the dimensions parameter to provider-specific
options for Gemini and OpenAI but not for VoyageAI. This causes
VoyageAI to return its default 1024-dimension vectors instead of
the requested size, leading to dimension mismatches when storing
in pgvector columns configured for larger dimensions.

Prism already supports `outputDimension` as a provider option for
VoyageAI (prism-php/prism#904), so we just need to pass it through.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: verify provider-specific dimension options in PrismGateway

Adds unit tests verifying that PrismGateway::generateEmbeddings()
passes the correct provider option key for embedding dimensions:
- OpenAI: dimensions
- Gemini: outputDimensionality
- VoyageAI: outputDimension

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Delete tests/Unit/Gateway/Prism/PrismEmbeddingsTest.php

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Taylor Otwell <taylor@laravel.com>
sulimanbenhalim pushed a commit to sulimanbenhalim/ai that referenced this pull request Mar 6, 2026
* fix: pass outputDimension for VoyageAI embeddings

The PrismGateway maps the dimensions parameter to provider-specific
options for Gemini and OpenAI but not for VoyageAI. This causes
VoyageAI to return its default 1024-dimension vectors instead of
the requested size, leading to dimension mismatches when storing
in pgvector columns configured for larger dimensions.

Prism already supports `outputDimension` as a provider option for
VoyageAI (prism-php/prism#904), so we just need to pass it through.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: verify provider-specific dimension options in PrismGateway

Adds unit tests verifying that PrismGateway::generateEmbeddings()
passes the correct provider option key for embedding dimensions:
- OpenAI: dimensions
- Gemini: outputDimensionality
- VoyageAI: outputDimension

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Delete tests/Unit/Gateway/Prism/PrismEmbeddingsTest.php

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Taylor Otwell <taylor@laravel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants