0xmrmasry/voyage-ai
Composer 安装命令:
composer require 0xmrmasry/voyage-ai
包简介
PHP client for the Voyage AI API — text embeddings, multimodal embeddings, and reranking.
README 文档
README
PHP client for the Voyage AI API — text embeddings, multimodal embeddings (text, images, video), and reranking.
Installation
composer require 0xmrmasry/voyage-ai
Configuration
Set your API key via environment variable:
VOYAGE_API_KEY=your-api-key
Or pass it directly:
$voyage = \VoyageAI\Voyage::client('your-api-key');
Usage
Text Embeddings
use VoyageAI\Voyage; use VoyageAI\Enums\{InputType, OutputDtype}; $voyage = Voyage::client(getenv('VOYAGE_API_KEY')); $response = $voyage->embeddings()->create( input: ['I like cats', 'I also like dogs'], model: 'voyage-4-large', ); foreach ($response->data as $result) { echo "Index: {$result->index}, Dims: " . count($result->embedding) . "\n"; } echo "Tokens used: {$response->usage->totalTokens}\n";
With Options
$response = $voyage->embeddings()->create( input: 'Represent this sentence for searching relevant passages', model: 'voyage-4-large', options: [ 'input_type' => InputType::Query, 'truncation' => true, 'output_dimension' => 256, 'output_dtype' => OutputDtype::Float, ], );
Quantized Embeddings (int8, uint8, binary, ubinary)
$response = $voyage->embeddings()->create( input: 'Test for quantization', model: 'voyage-4-large', options: [ 'output_dtype' => OutputDtype::Int8, ], ); // $response->data[0]->embedding is now array of ints (-128..127)
Reranking
$response = $voyage->reranking()->create( query: 'talk about rain', documents: [ 'sunny day at the beach', 'rainy day in the city', 'snowy mountain peak', ], model: 'rerank-2.5', ); // Results sorted by descending relevance foreach ($response->data as $result) { echo "Document {$result->index}: score {$result->relevanceScore}\n"; }
With Options
$response = $voyage->reranking()->create( query: 'best fruit', documents: ['apple', 'banana', 'car'], model: 'rerank-2.5-lite', options: [ 'top_k' => 2, 'return_documents' => true, 'truncation' => true, ], ); foreach ($response->data as $result) { echo "{$result->document}: {$result->relevanceScore}\n"; }
Multimodal Embeddings
use VoyageAI\Resources\{MultimodalInput, TextContent, ImageUrlContent, VideoUrlContent}; $response = $voyage->multimodal()->create( inputs: [ new MultimodalInput([ new TextContent('This is a banana.'), new ImageUrlContent('https://example.com/banana.jpg'), ]), ], model: 'voyage-multimodal-3.5', );
With Video
use VoyageAI\Resources\{MultimodalInput, TextContent, ImageUrlContent, VideoUrlContent}; $response = $voyage->multimodal()->create( inputs: [ new MultimodalInput([ new TextContent('A bunny running in a field.'), new ImageUrlContent('https://example.com/bunny.jpg'), new VideoUrlContent('https://example.com/bunny.mp4'), ]), ], model: 'voyage-multimodal-3.5', );
Base64 Images and Video
use VoyageAI\Resources\{MultimodalInput, TextContent, ImageBase64Content, VideoBase64Content}; $response = $voyage->multimodal()->create( inputs: [ new MultimodalInput([ new TextContent('A photo of a cat.'), new ImageBase64Content('data:image/jpeg;base64,/9j/4AAQSkZJRg...'), new VideoBase64Content('data:video/mp4;base64,AAAAIGZ0eXBpc29t...'), ]), ], model: 'voyage-multimodal-3.5', options: [ 'input_type' => InputType::Document, 'truncation' => true, ], );
Custom Base URL
$voyage = Voyage::client( apiKey: 'your-key', baseUrl: 'https://your-proxy.example.com/v1', );
Available Models
Text Embedding Models
| Model | Context Length | Embedding Dimension |
|---|---|---|
| voyage-4-large | 32,000 | 1024 (default), 256, 512, 2048 |
| voyage-4 | 32,000 | 1024 (default), 256, 512, 2048 |
| voyage-4-lite | 32,000 | 1024 (default), 256, 512, 2048 |
| voyage-3.5 | 32,000 | 1024 (default), 256, 512, 2048 |
| voyage-3.5-lite | 32,000 | 1024 (default), 256, 512, 2048 |
| voyage-3-large | 32,000 | 1024 (default), 256, 512, 2048 |
| voyage-3 | 32,000 | 1024 |
| voyage-3-lite | 32,000 | 512 |
| voyage-code-3.5 | 32,000 | 1024 (default), 256, 512, 2048 |
| voyage-code-3 | 32,000 | 1024 (default), 256, 512, 2048 |
| voyage-finance-2 | 32,000 | 1024 |
| voyage-multilingual-2 | 32,000 | 1024 |
| voyage-law-2 | 16,000 | 1024 |
| voyage-code-2 | 16,000 | 1536 |
Multimodal Embedding Models
| Model | Context Length | Embedding Dimension |
|---|---|---|
| voyage-multimodal-3.5 | 32,000 | 1024 |
| voyage-multimodal-3 | 32,000 | 1024 |
Reranking Models
| Model | Query Token Limit | Query + Document Token Limit |
|---|---|---|
| rerank-2.5 | 8,000 | 32,000 |
| rerank-2.5-lite | 8,000 | 32,000 |
| rerank-2 | 4,000 | 16,000 |
| rerank-2-lite | 2,000 | 8,000 |
| rerank-1 | 2,000 | 8,000 |
| rerank-lite-1 | 1,000 | 4,000 |
Error Handling
All API errors throw VoyageAI\Exceptions\VoyageException with an $httpStatusCode property:
try { $response = $voyage->embeddings()->create('Hello', 'invalid-model'); } catch (\VoyageAI\Exceptions\VoyageException $e) { echo "Error ({$e->httpStatusCode}): {$e->getMessage()}\n"; }
Requirements
- PHP 8.1+
- Guzzle 7 (installed automatically via Composer)
License
MIT
0xmrmasry/voyage-ai 适用场景与选型建议
0xmrmasry/voyage-ai 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「vector」 「multimodal」 「ai」 「embeddings」 「semantic-search」 「reranking」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 0xmrmasry/voyage-ai 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 0xmrmasry/voyage-ai 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 0xmrmasry/voyage-ai 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Generic, object-oriented Vector, Map, and Set collections with immutable and mutable variants
PHP Interface for Babel Street Text Analytics
Laravel AI SDK provider extension that adds Seeweb Regolo — chat, embeddings, reranking, plus a 30+ open-model catalog hosted in Italy — as a first-class provider for the official laravel/ai SDK.
Immutable data structures based on php/ds.
Add embeddings functionalities to modelflow-ai.
Simple PHP client for Qdrant vector database. Easy-to-use library for storing, searching, and managing vector embeddings in AI and machine learning applications.
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 39
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-11