class GeminiStoreGateway implements StoreGateway

Traits

Methods

createClient(string $baseUrl, array $headers = [], array $configuredHeaders = [], int|null $timeout = 60, bool $throw = true)

Create an HTTP client with the provider's request options.

string
httpConnection(Provider $provider)

Select a boot-registered connection without retaining dynamic provider names.

string
resourceId(string $id)

Encode the given provider resource ID as a single URL path segment.

mixed
withErrorHandling(string $providerName, Closure $callback)

Execute a callback with failoverable error handling.

int|null
retryAfterSeconds(Throwable $exception)

Get the short Retry-After delay of a rate limited or overloaded response, if it has one.

bool
isInsufficientCredits(RequestException $exception)

Determine if the response is a 402, or a 429 insufficient credits or quota error rather than a rate limit.

array
overloadedStatusCodes()

Get the status codes that indicate a provider is transiently unavailable and the request should fail over.

array
insufficientCreditPatterns()

Get the patterns used to detect insufficient credits or quota errors.

array
insufficientCreditCodes()

Get the error codes or types that indicate insufficient credits or quota on a 429 response.

getStore(StoreProvider $provider, string $storeId)

Get a vector store by its ID.

createStore(StoreProvider $provider, string $name, string|null $description = null, Collection|null $fileIds = null, DateInterval|null $expiresWhenIdleFor = null)

Create a new vector store.

string
addFile(StoreProvider $provider, string $storeId, string $fileId, array $metadata = [])

Add a file to a vector store.

waitForImportOperation(StoreProvider $provider, Response $operation)

Wait for a Gemini file import operation to complete.

array
formatMetadata(array $metadata)

Format metadata for Gemini's custom_metadata format.

bool
removeFile(StoreProvider $provider, string $storeId, string $documentId)

Remove a file from a vector store.

bool
deleteStore(StoreProvider $provider, string $storeId)

Delete a vector store by its ID.

client(Provider $provider)

Get an HTTP client for the Gemini File Search API.

string
baseUrl(Provider $provider)

Get the base URL for the Gemini API.

string
normalizeStoreId(string $storeId)

Normalize the store ID to include the resource prefix.

string
normalizeFileId(string $fileId)

Normalize the file ID to include the resource prefix.

string
normalizeDocumentId(string $storeId, string $documentId)

Normalize the document ID to include the full resource path.

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.

Parameters

string $baseUrl
array $headers
array $configuredHeaders
int|null $timeout
bool $throw

Return Value

PendingRequest

in CreatesClient at line 43
protected string httpConnection(Provider $provider)

Select a boot-registered connection without retaining dynamic provider names.

Parameters

Provider $provider

Return Value

string

in EncodesResourceIds at line 16
protected string resourceId(string $id)

Encode the given provider resource ID as a single URL path segment.

Parameters

string $id

Return Value

string

Exceptions

InvalidArgumentException

protected mixed withErrorHandling(string $providerName, Closure $callback)

Execute a callback with failoverable error handling.

Parameters

string $providerName
Closure $callback

Return Value

mixed

protected int|null retryAfterSeconds(Throwable $exception)

Get the short Retry-After delay of a rate limited or overloaded response, if it has one.

Parameters

Throwable $exception

Return Value

int|null

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.

Parameters

RequestException $exception

Return Value

bool

protected array overloadedStatusCodes()

Get the status codes that indicate a provider is transiently unavailable and the request should fail over.

Return Value

array

protected array insufficientCreditPatterns()

Get the patterns used to detect insufficient credits or quota errors.

Return Value

array

protected array insufficientCreditCodes()

Get the error codes or types that indicate insufficient credits or quota on a 429 response.

Return Value

array

at line 34
Store getStore(StoreProvider $provider, string $storeId)

Get a vector store by its ID.

Parameters

StoreProvider $provider
string $storeId

Return Value

Store

at line 60
Store createStore(StoreProvider $provider, string $name, string|null $description = null, Collection|null $fileIds = null, DateInterval|null $expiresWhenIdleFor = null)

Create a new vector store.

Parameters

StoreProvider $provider
string $name
string|null $description
Collection|null $fileIds
DateInterval|null $expiresWhenIdleFor

Return Value

Store

at line 88
string addFile(StoreProvider $provider, string $storeId, string $fileId, array $metadata = [])

Add a file to a vector store.

Parameters

StoreProvider $provider
string $storeId
string $fileId
array $metadata

Return Value

string

at line 121
protected Response waitForImportOperation(StoreProvider $provider, Response $operation)

Wait for a Gemini file import operation to complete.

Parameters

StoreProvider $provider
Response $operation

Return Value

Response

at line 147
protected array formatMetadata(array $metadata)

Format metadata for Gemini's custom_metadata format.

Parameters

array $metadata

Return Value

array

at line 159
bool removeFile(StoreProvider $provider, string $storeId, string $documentId)

Remove a file from a vector store.

Parameters

StoreProvider $provider
string $storeId
string $documentId

Return Value

bool

at line 175
bool deleteStore(StoreProvider $provider, string $storeId)

Delete a vector store by its ID.

Parameters

StoreProvider $provider
string $storeId

Return Value

bool

at line 191
protected PendingRequest client(Provider $provider)

Get an HTTP client for the Gemini File Search API.

Parameters

Provider $provider

Return Value

PendingRequest

at line 205
protected string baseUrl(Provider $provider)

Get the base URL for the Gemini API.

Parameters

Provider $provider

Return Value

string

at line 213
protected string normalizeStoreId(string $storeId)

Normalize the store ID to include the resource prefix.

Parameters

string $storeId

Return Value

string

at line 221
protected string normalizeFileId(string $fileId)

Normalize the file ID to include the resource prefix.

Parameters

string $fileId

Return Value

string

at line 229
protected string normalizeDocumentId(string $storeId, string $documentId)

Normalize the document ID to include the full resource path.

Parameters

string $storeId
string $documentId

Return Value

string