PHPackages                             0xmrmasry/voyage-ai - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. 0xmrmasry/voyage-ai

ActiveLibrary[API Development](/categories/api)

0xmrmasry/voyage-ai
===================

PHP client for the Voyage AI API — text embeddings, multimodal embeddings, and reranking.

04PHP

Since May 11Pushed 4w agoCompare

[ Source](https://github.com/0xMrMasry/voyage-ai)[ Packagist](https://packagist.org/packages/0xmrmasry/voyage-ai)[ RSS](/packages/0xmrmasry-voyage-ai/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Voyage AI PHP
=============

[](#voyage-ai-php)

PHP client for the [Voyage AI](https://www.voyageai.com) API — text embeddings, multimodal embeddings (text, images, video), and reranking.

Installation
------------

[](#installation)

```
composer require 0xmrmasry/voyage-ai
```

Configuration
-------------

[](#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
-----

[](#usage)

### Text Embeddings

[](#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

[](#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)

[](#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

[](#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

[](#with-options-1)

```
$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

[](#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

[](#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

[](#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

[](#custom-base-url)

```
$voyage = Voyage::client(
    apiKey: 'your-key',
    baseUrl: 'https://your-proxy.example.com/v1',
);
```

Available Models
----------------

[](#available-models)

### Text Embedding Models

[](#text-embedding-models)

ModelContext LengthEmbedding Dimensionvoyage-4-large32,0001024 (default), 256, 512, 2048voyage-432,0001024 (default), 256, 512, 2048voyage-4-lite32,0001024 (default), 256, 512, 2048voyage-3.532,0001024 (default), 256, 512, 2048voyage-3.5-lite32,0001024 (default), 256, 512, 2048voyage-3-large32,0001024 (default), 256, 512, 2048voyage-332,0001024voyage-3-lite32,000512voyage-code-3.532,0001024 (default), 256, 512, 2048voyage-code-332,0001024 (default), 256, 512, 2048voyage-finance-232,0001024voyage-multilingual-232,0001024voyage-law-216,0001024voyage-code-216,0001536### Multimodal Embedding Models

[](#multimodal-embedding-models)

ModelContext LengthEmbedding Dimensionvoyage-multimodal-3.532,0001024voyage-multimodal-332,0001024### Reranking Models

[](#reranking-models)

ModelQuery Token LimitQuery + Document Token Limitrerank-2.58,00032,000rerank-2.5-lite8,00032,000rerank-24,00016,000rerank-2-lite2,0008,000rerank-12,0008,000rerank-lite-11,0004,000Error Handling
--------------

[](#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
------------

[](#requirements)

- PHP 8.1+
- Guzzle 7 (installed automatically via Composer)

License
-------

[](#license)

MIT

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance61

Regular maintenance activity

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ad29a77247e95d735d757f5267feae16ea626c036af787636abf50caccd15654?d=identicon)[0xmrmasry](/maintainers/0xmrmasry)

---

Top Contributors

[![0xMrMasry](https://avatars.githubusercontent.com/u/90429720?v=4)](https://github.com/0xMrMasry "0xMrMasry (1 commits)")

### Embed Badge

![Health badge](/badges/0xmrmasry-voyage-ai/health.svg)

```
[![Health](https://phpackages.com/badges/0xmrmasry-voyage-ai/health.svg)](https://phpackages.com/packages/0xmrmasry-voyage-ai)
```

###  Alternatives

[facebook/php-business-sdk

PHP SDK for Facebook Business

90923.5M35](/packages/facebook-php-business-sdk)[exsyst/swagger

A php library to manipulate Swagger specifications

35916.3M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[botman/driver-telegram

Telegram driver for BotMan

93452.6k6](/packages/botman-driver-telegram)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
