class VoyageAiProvider extends Provider implements EmbeddingProvider, RerankingProvider

Traits

Properties

protected EmbeddingGateway $embeddingGateway from  HasEmbeddingGateway
protected RerankingGateway $rerankingGateway from  HasRerankingGateway

Methods

__construct(array $config, Dispatcher $events)

Create a Voyage AI provider instance.

string
name()

Get the name of the underlying AI provider.

from  Provider
string
driver()

Get the name of the underlying AI driver.

from  Provider
array
providerCredentials()

Get the credentials for the underlying AI provider.

from  Provider
array
additionalConfiguration()

Get the provider connection configuration other than the driver, key, and name.

from  Provider
withHeaders(array $headers)

Get a provider instance that sends the given HTTP headers with each request.

from  Provider
mixed
dispatchingFailure(Closure $call, Closure $failed)

Run the given gateway call, dispatching the event built from its exception before rethrowing.

from  Provider
static array
formatProviderAndModelList(Provider|Lab|array|string $providers, string|null $model = null)

Format the given provider / model list.

from  Provider
static array
providerAndModelPairs(Provider|Lab|array|string $providers, string|null $model = null)

Get provider and model pairs without discarding on-demand instances.

from  Provider
array
__serialize()

Get the serializable representation of the provider.

from  Provider
void
__unserialize(array $data)

Restore the provider from its serialized representation.

from  Provider
string
__toString()

Convert the provider to its string representation.

from  Provider
embeddings(array $inputs, int|null $dimensions = null, string|null $model = null, int $timeout = 30, array $providerOptions = [])

Get embedding vectors representing the given inputs.

bool
supportsNativeEmbeddingDimensions()

Determine if the provider may omit dimensions and use a model's native embedding dimensions.

void
validateEmbeddingInputs(array $inputs, string $model)

Validate embeddings inputs against Voyage AI's supported media types.

embeddingGateway()

Get the provider's embedding gateway.

useEmbeddingGateway(EmbeddingGateway $gateway)

Set the provider's embedding gateway.

rerankingGateway()

Get the provider's reranking gateway.

useRerankingGateway(RerankingGateway $gateway)

Set the provider's reranking gateway.

rerank(array $documents, string $query, int|null $limit = null, string|null $model = null, int $timeout = 30, array $providerOptions = [])

Rerank the given documents based on their relevance to the query.

from  Reranks
string
defaultEmbeddingsModel()

Get the name of the default embeddings model.

int
defaultEmbeddingsDimensions()

Get the default dimensions of the default embeddings model.

bool
isVoyageMultimodalModel(string $model)

Determine if the given model supports Voyage AI multimodal embeddings.

string
defaultRerankingModel()

Get the name of the default reranking model.

Details

at line 32
__construct(array $config, Dispatcher $events)

Create a Voyage AI provider instance.

Parameters

array $config
Dispatcher $events

in Provider at line 34
string name()

Get the name of the underlying AI provider.

Return Value

string

in Provider at line 42
string driver()

Get the name of the underlying AI driver.

Return Value

string

in Provider at line 50
array providerCredentials()

Get the credentials for the underlying AI provider.

Return Value

array

in Provider at line 60
array additionalConfiguration()

Get the provider connection configuration other than the driver, key, and name.

Return Value

array

in Provider at line 72
Provider withHeaders(array $headers)

internal  
 

Get a provider instance that sends the given HTTP headers with each request.

Parameters

array $headers

Return Value

Provider

in Provider at line 92
protected mixed dispatchingFailure(Closure $call, Closure $failed)

Run the given gateway call, dispatching the event built from its exception before rethrowing.

Parameters

Closure $call
Closure $failed

Return Value

mixed

in Provider at line 114
static array formatProviderAndModelList(Provider|Lab|array|string $providers, string|null $model = null)

Format the given provider / model list.

Parameters

Provider|Lab|array|string $providers
string|null $model

Return Value

array

in Provider at line 132
static array providerAndModelPairs(Provider|Lab|array|string $providers, string|null $model = null)

internal  
 

Get provider and model pairs without discarding on-demand instances.

Parameters

Provider|Lab|array|string $providers
string|null $model

Return Value

array

in Provider at line 164
array __serialize()

Get the serializable representation of the provider.

Return Value

array

in Provider at line 174
void __unserialize(array $data)

Restore the provider from its serialized representation.

Parameters

array $data

Return Value

void

in Provider at line 190
string __toString()

Convert the provider to its string representation.

Return Value

string

EmbeddingsResponse embeddings(array $inputs, int|null $dimensions = null, string|null $model = null, int $timeout = 30, array $providerOptions = [])

Get embedding vectors representing the given inputs.

Parameters

array $inputs
int|null $dimensions
string|null $model
int $timeout
array $providerOptions

Return Value

EmbeddingsResponse

protected bool supportsNativeEmbeddingDimensions()

Determine if the provider may omit dimensions and use a model's native embedding dimensions.

Return Value

bool

at line 57
protected void validateEmbeddingInputs(array $inputs, string $model)

Validate embeddings inputs against Voyage AI's supported media types.

Parameters

array $inputs
string $model

Return Value

void

at line 101
EmbeddingGateway embeddingGateway()

Get the provider's embedding gateway.

Return Value

EmbeddingGateway

HasEmbeddingGateway useEmbeddingGateway(EmbeddingGateway $gateway)

Set the provider's embedding gateway.

Changing a shared provider's gateway affects subsequent operations.

Parameters

EmbeddingGateway $gateway

Return Value

HasEmbeddingGateway

at line 117
RerankingGateway rerankingGateway()

Get the provider's reranking gateway.

Return Value

RerankingGateway

HasRerankingGateway useRerankingGateway(RerankingGateway $gateway)

Set the provider's reranking gateway.

Changing a shared provider's gateway affects subsequent operations.

Parameters

RerankingGateway $gateway

Return Value

HasRerankingGateway

in Reranks at line 24
RerankingResponse rerank(array $documents, string $query, int|null $limit = null, string|null $model = null, int $timeout = 30, array $providerOptions = [])

Rerank the given documents based on their relevance to the query.

Parameters

array $documents
string $query
int|null $limit
string|null $model
int $timeout
array $providerOptions

Return Value

RerankingResponse

at line 41
string defaultEmbeddingsModel()

Get the name of the default embeddings model.

Return Value

string

at line 49
int defaultEmbeddingsDimensions()

Get the default dimensions of the default embeddings model.

Return Value

int

at line 93
protected bool isVoyageMultimodalModel(string $model)

Determine if the given model supports Voyage AI multimodal embeddings.

Parameters

string $model

Return Value

bool

at line 109
string defaultRerankingModel()

Get the name of the default reranking model.

Return Value

string