aisdk/voyageai
Composer 安装命令:
composer require aisdk/voyageai
包简介
Official Voyage AI provider for the PHP AI SDK.
README 文档
README
Official Voyage AI provider for the PHP AI SDK.
Installation
composer require aisdk/voyageai
Text Embeddings
use AiSdk\Generate; use AiSdk\VoyageAI; $result = Generate::embedding([ 'First document', 'Second document', ]) ->model(VoyageAI::embedding('voyage-4-large')) ->dimensions(512) ->providerOptions('voyageai', [ 'input_type' => 'document', ]) ->run(); $vector = $result->output->vector; $vectors = $result->embeddings;
The v0.5 API covers Voyage's text embeddings endpoint. Multimodal, contextualized chunk embeddings, and reranking use different API contracts and are not part of this package surface yet.
Configuration
| Variable | Description | Default |
|---|---|---|
VOYAGE_API_KEY |
API key for authentication | Required |
VOYAGE_BASE_URL |
Base URL for API requests | https://api.voyageai.com/v1 |
VoyageAI::create([ 'apiKey' => 'pa-...', 'baseUrl' => 'https://api.voyageai.com/v1', 'headers' => ['X-Custom-Header' => 'value'], ]);
Provider-Specific Options
Voyage's documented text embedding fields pass through unchanged:
$result = Generate::embedding('A search query') ->model(VoyageAI::embedding('voyage-4-large')) ->providerOptions('voyageai', [ 'input_type' => 'query', 'truncation' => true, 'output_dtype' => 'float', ]) ->run();
dimensions() maps to Voyage's output_dimension field. Model IDs pass through unchanged so Voyage's API remains the source of truth for model availability and supported dimensions.
The portable SDK result is a float vector, so v0.5 accepts Voyage's output_dtype: float only and rejects base64 encoding. Quantized and bit-packed output need a separate result contract rather than being mislabeled as ordinary float dimensions.
Testing
composer test
Links
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-11