VoyageAiGateway
class VoyageAiGateway implements EmbeddingGateway, RerankingGateway
Traits
Methods
Create an HTTP client with the provider's request options.
Select a boot-registered connection without retaining dynamic provider names.
Determine if the model or inputs require Voyage AI's multimodal endpoint.
Generate embeddings for text and image inputs using Voyage AI's multimodal endpoint.
Validate Voyage AI's per-request media source constraint.
Get the media source type used by a multimodal embeddings input.
Map a Hypervel embeddings input to Voyage AI's multimodal input segment.
Execute a callback with failoverable error handling.
Get the short Retry-After delay of a rate limited or overloaded response, if it has one.
Determine if the response is a 402, or a 429 insufficient credits or quota error rather than a rate limit.
Get the status codes that indicate a provider is transiently unavailable and the request should fail over.
Get the patterns used to detect insufficient credits or quota errors.
Get the error codes or types that indicate insufficient credits or quota on a 429 response.
Generate embeddings for the given inputs.
Rerank the given documents based on their relevance to the query.
Details
in
CreatesClient at line 21
protected PendingRequest
createClient(string $baseUrl, array $headers = [], array $configuredHeaders = [], int|null $timeout = 60, bool $throw = true)
Create an HTTP client with the provider's request options.
in
CreatesClient at line 43
protected string
httpConnection(Provider $provider)
Select a boot-registered connection without retaining dynamic provider names.
in
CreatesVoyageAiClient at line 18
protected PendingRequest
client(Provider $provider, int|null $timeout = null)
Get an HTTP client for the Voyage AI API.
in
CreatesVoyageAiClient at line 31
protected string
baseUrl(Provider $provider)
Get the base URL for the Voyage AI API.
in
MapsEmbeddingInputs at line 28
protected bool
usesMultimodalEmbeddingEndpoint(string $model, array $inputs)
Determine if the model or inputs require Voyage AI's multimodal endpoint.
in
MapsEmbeddingInputs at line 37
protected EmbeddingsResponse
generateMultimodalEmbeddings(EmbeddingProvider $provider, string $model, array $inputs, int $dimensions, int $timeout = 30, array $providerOptions = [])
Generate embeddings for text and image inputs using Voyage AI's multimodal endpoint.
in
MapsEmbeddingInputs at line 76
protected void
validateMultimodalEmbeddingInputSources(array $inputs)
Validate Voyage AI's per-request media source constraint.
in
MapsEmbeddingInputs at line 100
protected string|null
multimodalEmbeddingInputSource(mixed $input)
Get the media source type used by a multimodal embeddings input.
in
MapsEmbeddingInputs at line 114
protected array
mapMultimodalEmbeddingInput(mixed $input)
Map a Hypervel embeddings input to Voyage AI's multimodal input segment.
in
HandlesFailoverErrors at line 26
protected mixed
withErrorHandling(string $providerName, Closure $callback)
Execute a callback with failoverable error handling.
in
HandlesFailoverErrors at line 91
protected int|null
retryAfterSeconds(Throwable $exception)
Get the short Retry-After delay of a rate limited or overloaded response, if it has one.
in
HandlesFailoverErrors at line 115
protected bool
isInsufficientCredits(RequestException $exception)
Determine if the response is a 402, or a 429 insufficient credits or quota error rather than a rate limit.
in
HandlesFailoverErrors at line 138
protected array
overloadedStatusCodes()
Get the status codes that indicate a provider is transiently unavailable and the request should fail over.
in
HandlesFailoverErrors at line 148
protected array
insufficientCreditPatterns()
Get the patterns used to detect insufficient credits or quota errors.
in
HandlesFailoverErrors at line 158
protected array
insufficientCreditCodes()
Get the error codes or types that indicate insufficient credits or quota on a 429 response.
at line 33
EmbeddingsResponse
generateEmbeddings(EmbeddingProvider $provider, string $model, array $inputs, int $dimensions, int $timeout = 30, array $providerOptions = [])
Generate embeddings for the given inputs.
at line 70
RerankingResponse
rerank(RerankingProvider $provider, string $model, array $documents, string $query, int|null $limit = null, int $timeout = 30, array $providerOptions = [])
Rerank the given documents based on their relevance to the query.