OpenAiFileGateway
class OpenAiFileGateway implements FileGateway
Traits
Methods
Create an HTTP client with the provider's request options.
Select a boot-registered connection without retaining dynamic provider names.
Encode the given provider resource ID as a single URL path 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.
Resolve the upload body options and HTTP headers for the given file.
Get the default purpose to use when a file does not specify one.
Get the provider key used to resolve file upload options.
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
CreatesOpenAiClient at line 18
protected PendingRequest
client(Provider $provider, int|null $timeout = null)
Get an HTTP client for the OpenAI API.
in
CreatesOpenAiClient at line 31
protected string
baseUrl(Provider $provider)
Get the base URL for the OpenAI-compatible API.
in
EncodesResourceIds at line 16
protected string
resourceId(string $id)
Encode the given provider resource ID as a single URL path 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.
in
PreparesStorableFiles at line 19
protected array
prepareStorableFile(StorableFile $file)
Prepare file data for upload.
in
PreparesStorableFiles at line 33
protected array
resolveProviderOptionsAndHeaders(StorableFile $file, Lab|string $provider)
Resolve the upload body options and HTTP headers for the given file.
at line 29
FileResponse
getFile(FileProvider $provider, string $fileId)
Get a file by its ID.
at line 46
StoredFileResponse
putFile(FileProvider $provider, StorableFile $file)
Store the given file.
at line 73
void
deleteFile(FileProvider $provider, string $fileId)
Delete a file by its ID.
at line 86
protected string
defaultPurpose()
Get the default purpose to use when a file does not specify one.
at line 94
protected Lab
providerOptionsKey()
Get the provider key used to resolve file upload options.