Skip to content

Conversation

@markritterman
Copy link
Contributor

Summary

The Embeddings API already supports image inputs via fromImage() / fromImages() (added in #789), but the VoyageAI provider was ignoring them and only sending text to the /embeddings endpoint.

This PR updates the VoyageAI embeddings handler to route image-containing requests to Voyage's /multimodalembeddings endpoint with the correct content structure:

  • Base64 images — sent as data:{mime};base64,... format
  • Image URLs — sent as image_url type
  • Mixed text + image — each input becomes a separate multimodal content object
  • Text-only requests — unchanged, still use /embeddings
  • Provider options (inputType, truncation) forwarded to both endpoints

Example usage

use Prism\Prism\Enums\Provider;
use Prism\Prism\Facades\Prism;
use Prism\Prism\ValueObjects\Media\Image;

// Image embedding
$response = Prism::embeddings()
    ->using(Provider::VoyageAI, 'voyage-multimodal-3')
    ->fromImage(Image::fromStoragePath('photos/sunset.jpg', 's3'))
    ->withProviderOptions(['inputType' => 'document'])
    ->asEmbeddings();

// Text query embedding (for searching against image embeddings)
$response = Prism::embeddings()
    ->using(Provider::VoyageAI, 'voyage-multimodal-3')
    ->fromInput('sunset over the ocean')
    ->withProviderOptions(['inputType' => 'query'])
    ->asEmbeddings();

Test plan

  • Image via base64 routes to /multimodalembeddings
  • Image via URL routes to /multimodalembeddings with image_url type
  • Mixed text + image returns multiple embeddings
  • Text-only still uses /embeddings (regression)
  • Provider options forwarded to multimodal endpoint
  • All 1355 existing tests pass

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@markritterman markritterman force-pushed the feat/voyageai-multimodal-embeddings branch from de9c022 to 60c9dc6 Compare February 9, 2026 04:46
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.

1 participant