class AzureOpenAiProvider extends Provider implements EmbeddingProvider, FileProvider, ImageProvider, StoreProvider, SupportsCodeExecution, SupportsFileSearch, SupportsToolSearch, SupportsWebSearch, TextProvider

Traits

Properties

protected EmbeddingGateway $embeddingGateway from  HasEmbeddingGateway
protected FileGateway $fileGateway from  HasFileGateway
protected ImageGateway $imageGateway from  HasImageGateway
protected StoreGateway $storeGateway from  HasStoreGateway
protected StepTextGateway $textGateway from  HasTextGateway
protected TextGenerationLoop|null $textGenerationLoop from  HasTextGateway
protected AzureOpenAiGateway|null $azureGateway

Methods

__construct(array $config, Dispatcher $events)

Create an Azure OpenAI 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.

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 the provider's supported media types.

image(string $prompt, array $attachments = [], string|null $size = null, string|null $quality = null, string|null $model = null, int|null $timeout = null, array $providerOptions = [])

Generate an image.

array|null
resumableApprovalFor(AgentPrompt $prompt, array $messages, array $tools)

Get the tool approval to resume with, unless a faked agent has no paused approval to resume.

array
withoutForeignReplayBlocks(array $messages)

Replace another provider's raw paused-turn replay state with its generic mapping, since raw blocks are only valid verbatim on the provider that produced them.

bool
resumesApproval(AgentPrompt $prompt, array $messages, array $tools)

Determine whether the prompt is a resume that runs the approved tools.

Closure|null
approvalResultRecorderFor(AgentPrompt $prompt, array|null $approval, Collection|null $resolvedApprovalResults)

Get a callback that captures a resume's resolved approval results for its completion event.

prompt(AgentPrompt $prompt)

Invoke the given agent.

array
gatherMiddlewareFor(Agent $agent)

Gather the internal run middleware for the given agent.

array
resolveTools(AgentPrompt $prompt)

Resolve the tools for the given prompt, wrapping any agent instances as tools.

array
declaredTools(Agent $agent)

Get the tools the agent declares, including the tool that loads its skills.

mixed
resolveTool(mixed $tool)

Resolve a tool returned by the agent into a native tool instance when needed.

prepareRunContext(string $invocationId, AgentPrompt $prompt, array|null $approval)

Build the run's context, letting a remembered conversation claim and record the approval decisions the run resumes.

runContextFor(string $invocationId, AgentPrompt $prompt)

Build the context that identifies this run and reports its step and tool events.

void
recordAgentFailure(string $invocationId, AgentPrompt $prompt, Throwable $exception, bool $retryable = true)

Dispatch the terminal failure event for a run, unless the caller may still retry it against another provider.

void
throwIfNotResumable(AgentPrompt $prompt)

Throw when a pause has surfaced on a prompt that cannot be resumed from persisted or replayed history.

embeddingGateway()

Get the provider's embedding gateway.

useEmbeddingGateway(EmbeddingGateway $gateway)

Set the provider's embedding gateway.

fileGateway()

Get the provider's file gateway.

useFileGateway(FileGateway $gateway)

Set the provider's file gateway.

imageGateway()

Get the provider's image gateway.

useImageGateway(ImageGateway $gateway)

Set the provider's image gateway.

storeGateway()

Get the provider's store gateway.

useStoreGateway(StoreGateway $gateway)

Set the provider's store gateway.

textGateway()

Get the provider's text gateway.

useTextGateway(StepTextGateway $gateway)

Set the provider's text gateway.

textGenerationLoop()

Get the multi-step text generation loop wrapping the provider's text gateway.

getFile(string $fileId)

Get a file by its ID.

putFile(StorableFile $file)

Store the given file.

void
deleteFile(string $fileId)

Delete a file by its ID.

getStore(string $storeId)

Get a vector store by its ID.

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

Create a new vector store.

string
addFileToStore(string $storeId, HasProviderId $file, array $metadata = [])

Add a file to a vector store.

bool
removeFileFromStore(string $storeId, HasProviderId|string $documentId)

Remove a file from a vector store.

bool
deleteStore(string $storeId)

Delete a vector store by its ID.

stream(AgentPrompt $prompt)

Stream the response from the given agent.

azureGateway()

Get the shared Azure OpenAI gateway instance.

string
defaultTextModel()

Get the name of the default (deployment name) text model.

string
cheapestTextModel()

Get the name of the cheapest text model.

string
smartestTextModel()

Get the name of the smartest text model.

string
defaultImageModel()

Get the name of the default image deployment.

array
defaultImageOptions(string|null $size = null, string|null $quality = null)

Get the default / normalized image options for the provider.

string
defaultEmbeddingsModel()

Get the name of the default embeddings model.

int
defaultEmbeddingsDimensions()

Get the default dimensions of the default embeddings model.

array
fileSearchToolOptions(FileSearch $search)

Get the file search tool options for the provider.

array
codeExecutionToolOptions(CodeExecution $codeExecution)

Get the code execution tool options for the provider.

array
webSearchToolOptions(WebSearch $search)

Get the web search tool options for the provider.

Details

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

Create an Azure OpenAI 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

at line 216
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

protected void validateEmbeddingInputs(array $inputs, string $model)

Validate embeddings inputs against the provider's supported media types.

Parameters

array $inputs
string $model

Return Value

void

in GeneratesImages at line 26
ImageResponse image(string $prompt, array $attachments = [], string|null $size = null, string|null $quality = null, string|null $model = null, int|null $timeout = null, array $providerOptions = [])

Generate an image.

Parameters

string $prompt
array $attachments
string|null $size
string|null $quality
string|null $model
int|null $timeout
array $providerOptions

Return Value

ImageResponse

protected array|null resumableApprovalFor(AgentPrompt $prompt, array $messages, array $tools)

Get the tool approval to resume with, unless a faked agent has no paused approval to resume.

Parameters

AgentPrompt $prompt
array $messages
array $tools

Return Value

array|null

protected array withoutForeignReplayBlocks(array $messages)

Replace another provider's raw paused-turn replay state with its generic mapping, since raw blocks are only valid verbatim on the provider that produced them.

Parameters

array $messages

Return Value

array

protected bool resumesApproval(AgentPrompt $prompt, array $messages, array $tools)

Determine whether the prompt is a resume that runs the approved tools.

Parameters

AgentPrompt $prompt
array $messages
array $tools

Return Value

bool

protected Closure|null approvalResultRecorderFor(AgentPrompt $prompt, array|null $approval, Collection|null $resolvedApprovalResults)

Get a callback that captures a resume's resolved approval results for its completion event.

Parameters

AgentPrompt $prompt
array|null $approval
Collection|null $resolvedApprovalResults

Return Value

Closure|null

in GeneratesText at line 53
AgentResponse prompt(AgentPrompt $prompt)

Invoke the given agent.

Parameters

AgentPrompt $prompt

Return Value

AgentResponse

in GeneratesText at line 175
protected array gatherMiddlewareFor(Agent $agent)

Gather the internal run middleware for the given agent.

Parameters

Agent $agent

Return Value

array

in GeneratesText at line 193
protected array resolveTools(AgentPrompt $prompt)

Resolve the tools for the given prompt, wrapping any agent instances as tools.

Parameters

AgentPrompt $prompt

Return Value

array

in GeneratesText at line 204
protected array declaredTools(Agent $agent)

Get the tools the agent declares, including the tool that loads its skills.

Parameters

Agent $agent

Return Value

array

in GeneratesText at line 214
protected mixed resolveTool(mixed $tool)

Resolve a tool returned by the agent into a native tool instance when needed.

Parameters

mixed $tool

Return Value

mixed

in GeneratesText at line 233
protected RunContext prepareRunContext(string $invocationId, AgentPrompt $prompt, array|null $approval)

Build the run's context, letting a remembered conversation claim and record the approval decisions the run resumes.

Parameters

string $invocationId
AgentPrompt $prompt
array|null $approval

Return Value

RunContext

in GeneratesText at line 257
protected RunContext runContextFor(string $invocationId, AgentPrompt $prompt)

Build the context that identifies this run and reports its step and tool events.

Parameters

string $invocationId
AgentPrompt $prompt

Return Value

RunContext

in GeneratesText at line 268
protected void recordAgentFailure(string $invocationId, AgentPrompt $prompt, Throwable $exception, bool $retryable = true)

Dispatch the terminal failure event for a run, unless the caller may still retry it against another provider.

Parameters

string $invocationId
AgentPrompt $prompt
Throwable $exception
bool $retryable

Return Value

void

in GeneratesText at line 285
protected void throwIfNotResumable(AgentPrompt $prompt)

Throw when a pause has surfaced on a prompt that cannot be resumed from persisted or replayed history.

Parameters

AgentPrompt $prompt

Return Value

void

at line 85
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 229
FileGateway fileGateway()

Get the provider's file gateway.

Return Value

FileGateway

in HasFileGateway at line 27
HasFileGateway useFileGateway(FileGateway $gateway)

Set the provider's file gateway.

Changing a shared provider's gateway affects subsequent operations.

Parameters

FileGateway $gateway

Return Value

HasFileGateway

at line 117
ImageGateway imageGateway()

Get the provider's image gateway.

Return Value

ImageGateway

in HasImageGateway at line 27
HasImageGateway useImageGateway(ImageGateway $gateway)

Set the provider's image gateway.

Changing a shared provider's gateway affects subsequent operations.

Parameters

ImageGateway $gateway

Return Value

HasImageGateway

at line 237
StoreGateway storeGateway()

Get the provider's store gateway.

Return Value

StoreGateway

in HasStoreGateway at line 27
HasStoreGateway useStoreGateway(StoreGateway $gateway)

Set the provider's store gateway.

Changing a shared provider's gateway affects subsequent operations.

Parameters

StoreGateway $gateway

Return Value

HasStoreGateway

at line 77
StepTextGateway textGateway()

Get the provider's text gateway.

Return Value

StepTextGateway

in HasTextGateway at line 30
HasTextGateway useTextGateway(StepTextGateway $gateway)

Set the provider's text gateway.

Changing a shared provider's gateway affects subsequent operations.

Parameters

StepTextGateway $gateway

Return Value

HasTextGateway

in HasTextGateway at line 42
TextGenerationLoop textGenerationLoop()

Get the multi-step text generation loop wrapping the provider's text gateway.

Return Value

TextGenerationLoop

in ManagesFiles at line 23
FileResponse getFile(string $fileId)

Get a file by its ID.

Parameters

string $fileId

Return Value

FileResponse

in ManagesFiles at line 31
StoredFileResponse putFile(StorableFile $file)

Store the given file.

Parameters

StorableFile $file

Return Value

StoredFileResponse

in ManagesFiles at line 68
void deleteFile(string $fileId)

Delete a file by its ID.

Parameters

string $fileId

Return Value

void

in ManagesStores at line 30
Store getStore(string $storeId)

Get a vector store by its ID.

Parameters

string $storeId

Return Value

Store

in ManagesStores at line 38
Store createStore(string $name, string|null $description = null, Collection|null $fileIds = null, DateInterval|null $expiresWhenIdleFor = null)

Create a new vector store.

Parameters

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

Return Value

Store

in ManagesStores at line 87
string addFileToStore(string $storeId, HasProviderId $file, array $metadata = [])

Add a file to a vector store.

Parameters

string $storeId
HasProviderId $file
array $metadata

Return Value

string

in ManagesStores at line 122
bool removeFileFromStore(string $storeId, HasProviderId|string $documentId)

Remove a file from a vector store.

Parameters

string $storeId
HasProviderId|string $documentId

Return Value

bool

in ManagesStores at line 162
bool deleteStore(string $storeId)

Delete a vector store by its ID.

Parameters

string $storeId

Return Value

bool

in StreamsText at line 37
StreamableAgentResponse stream(AgentPrompt $prompt)

Stream the response from the given agent.

Parameters

AgentPrompt $prompt

Return Value

StreamableAgentResponse

at line 69
protected AzureOpenAiGateway azureGateway()

Get the shared Azure OpenAI gateway instance.

Return Value

AzureOpenAiGateway

at line 93
string defaultTextModel()

Get the name of the default (deployment name) text model.

Return Value

string

at line 101
string cheapestTextModel()

Get the name of the cheapest text model.

Return Value

string

at line 109
string smartestTextModel()

Get the name of the smartest text model.

Return Value

string

at line 125
string defaultImageModel()

Get the name of the default image deployment.

Return Value

string

at line 133
array defaultImageOptions(string|null $size = null, string|null $quality = null)

Get the default / normalized image options for the provider.

Parameters

string|null $size
string|null $quality

Return Value

array

at line 149
string defaultEmbeddingsModel()

Get the name of the default embeddings model.

Return Value

string

at line 157
int defaultEmbeddingsDimensions()

Get the default dimensions of the default embeddings model.

Return Value

int

at line 165
array fileSearchToolOptions(FileSearch $search)

Get the file search tool options for the provider.

Parameters

FileSearch $search

Return Value

array

at line 179
array codeExecutionToolOptions(CodeExecution $codeExecution)

Get the code execution tool options for the provider.

Parameters

CodeExecution $codeExecution

Return Value

array

at line 189
array webSearchToolOptions(WebSearch $search)

Get the web search tool options for the provider.

Parameters

WebSearch $search

Return Value

array