feat(gemini): add multimodal embedding support#944
Merged
sixlive merged 2 commits intoMar 12, 2026
Conversation
sixlive
approved these changes
Mar 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds first-class multimodal embeddings support for Gemini, including the new
gemini-embedding-2-previewworkflow shape.What changed
Embeddings\Contentvalue object so embeddings requests can represent real content entries instead of only flat text/image listsfromAudio(),fromAudios(),fromVideo(),fromVideos(),fromDocument(),fromDocuments()to the embeddings pending request APIfromContent()andfromContents()so callers can explicitly choose between:embedContentbatchEmbedContentstitle,taskType, andoutputDimensionalityWhy
Prism already supports image inputs at the generic Embeddings API level, but Gemini's provider implementation still serialized only text parts. That meant models such as
gemini-embedding-2-previewcould not actually use Prism's multimodal embeddings surface even though the public API suggested they could.This change aligns the Gemini provider with the current Embeddings API and exposes the input structuring needed by Gemini's multimodal embedding model.
Example
Aggregated multimodal embedding
Multiple embeddings in one request
References
Test plan
Ran in DDEV:
php vendor/bin/pest tests/Embeddings tests/Providers/Geminiphp vendor/bin/pest tests/Embeddings/ImageEmbeddingsTest.php tests/Embeddings/MultimodalEmbeddingsTest.php tests/Providers/Gemini/EmbeddingsTest.php tests/Providers/Gemini/MultimodalEmbeddingsTest.phpphp vendor/bin/pint --testphp vendor/bin/rector process --dry-runphp vendor/bin/phpstan analyse --verbose --no-ansi