diff --git a/.release-please-manifest.json b/.release-please-manifest.json index eba8a04..1887bd5 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "3.21.0" + ".": "3.22.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 15099ca..90ce078 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 8 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase/stagehand-c7910965e66e73ad8b65b6cc391d431094b2a6c6577c3e9d82feaa8138e74cff.yml -openapi_spec_hash: 37748bb69c22a9ce721d9b5a5861f964 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase/stagehand-4d0d50b4f18fd74f58aca0b84d6968d1228499f2fa4e5714516f13ff6f820c9d.yml +openapi_spec_hash: f7b1a869f3e412aea4d4bd42467791bb config_hash: 1fb12ae9b478488bc1e56bfbdc210b01 diff --git a/CHANGELOG.md b/CHANGELOG.md index 513a727..aef2e5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 3.22.0 (2026-06-09) + +Full Changelog: [v3.21.0...v3.22.0](https://github.com/browserbase/stagehand-php/compare/v3.21.0...v3.22.0) + +### Features + +* [STG-2090] Add Azure Entra model auth support ([804b83d](https://github.com/browserbase/stagehand-php/commit/804b83d439fb62c8abf8d25853d41dc524a78d69)) + ## 3.21.0 (2026-05-27) Full Changelog: [v3.20.0...v3.21.0](https://github.com/browserbase/stagehand-php/compare/v3.20.0...v3.21.0) diff --git a/README.md b/README.md index dd7e623..84c1594 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ The REST API documentation can be found on [docs.stagehand.dev](https://docs.sta ``` -composer require "browserbase/stagehand 3.21.0" +composer require "browserbase/stagehand 3.22.0" ``` diff --git a/src/Sessions/ModelConfig.php b/src/Sessions/ModelConfig.php index dc6b3fd..142fa7b 100644 --- a/src/Sessions/ModelConfig.php +++ b/src/Sessions/ModelConfig.php @@ -7,15 +7,19 @@ use Stagehand\Core\Concerns\SdkUnion; use Stagehand\Core\Conversion\Contracts\Converter; use Stagehand\Core\Conversion\Contracts\ConverterSource; +use Stagehand\Sessions\ModelConfig\AzureAPIKeyModelConfigObject; +use Stagehand\Sessions\ModelConfig\AzureEntraModelConfigObject; use Stagehand\Sessions\ModelConfig\GenericModelConfigObject; use Stagehand\Sessions\ModelConfig\VertexModelConfigObject; /** * @phpstan-import-type VertexModelConfigObjectShape from \Stagehand\Sessions\ModelConfig\VertexModelConfigObject + * @phpstan-import-type AzureEntraModelConfigObjectShape from \Stagehand\Sessions\ModelConfig\AzureEntraModelConfigObject + * @phpstan-import-type AzureAPIKeyModelConfigObjectShape from \Stagehand\Sessions\ModelConfig\AzureAPIKeyModelConfigObject * @phpstan-import-type GenericModelConfigObjectShape from \Stagehand\Sessions\ModelConfig\GenericModelConfigObject * - * @phpstan-type ModelConfigVariants = VertexModelConfigObject|GenericModelConfigObject - * @phpstan-type ModelConfigShape = ModelConfigVariants|VertexModelConfigObjectShape|GenericModelConfigObjectShape + * @phpstan-type ModelConfigVariants = VertexModelConfigObject|AzureEntraModelConfigObject|AzureAPIKeyModelConfigObject|GenericModelConfigObject + * @phpstan-type ModelConfigShape = ModelConfigVariants|VertexModelConfigObjectShape|AzureEntraModelConfigObjectShape|AzureAPIKeyModelConfigObjectShape|GenericModelConfigObjectShape */ final class ModelConfig implements ConverterSource { @@ -26,6 +30,11 @@ final class ModelConfig implements ConverterSource */ public static function variants(): array { - return [VertexModelConfigObject::class, GenericModelConfigObject::class]; + return [ + VertexModelConfigObject::class, + AzureEntraModelConfigObject::class, + AzureAPIKeyModelConfigObject::class, + GenericModelConfigObject::class, + ]; } } diff --git a/src/Sessions/ModelConfig/AzureAPIKeyModelConfigObject.php b/src/Sessions/ModelConfig/AzureAPIKeyModelConfigObject.php new file mode 100644 index 0000000..eb0ddf9 --- /dev/null +++ b/src/Sessions/ModelConfig/AzureAPIKeyModelConfigObject.php @@ -0,0 +1,188 @@ +|null, + * } + */ +final class AzureAPIKeyModelConfigObject implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI model provider. + * + * @var 'azure' $provider + */ + #[Required] + public string $provider = 'azure'; + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + #[Required] + public string $modelName; + + /** + * Azure provider-specific model configuration. + */ + #[Required] + public ProviderOptions $providerOptions; + + /** + * API key for the model provider. + */ + #[Optional] + public ?string $apiKey; + + /** + * Base URL for the model provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the model provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * `new AzureAPIKeyModelConfigObject()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AzureAPIKeyModelConfigObject::with(modelName: ..., providerOptions: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AzureAPIKeyModelConfigObject)->withModelName(...)->withProviderOptions(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param ProviderOptions|ProviderOptionsShape $providerOptions + * @param array|null $headers + */ + public static function with( + string $modelName, + ProviderOptions|array $providerOptions, + ?string $apiKey = null, + ?string $baseURL = null, + ?array $headers = null, + ): self { + $self = new self; + + $self['modelName'] = $modelName; + $self['providerOptions'] = $providerOptions; + + null !== $apiKey && $self['apiKey'] = $apiKey; + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + + return $self; + } + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + public function withModelName(string $modelName): self + { + $self = clone $this; + $self['modelName'] = $modelName; + + return $self; + } + + /** + * Azure OpenAI model provider. + * + * @param 'azure' $provider + */ + public function withProvider(string $provider): self + { + $self = clone $this; + $self['provider'] = $provider; + + return $self; + } + + /** + * Azure provider-specific model configuration. + * + * @param ProviderOptions|ProviderOptionsShape $providerOptions + */ + public function withProviderOptions( + ProviderOptions|array $providerOptions + ): self { + $self = clone $this; + $self['providerOptions'] = $providerOptions; + + return $self; + } + + /** + * API key for the model provider. + */ + public function withAPIKey(string $apiKey): self + { + $self = clone $this; + $self['apiKey'] = $apiKey; + + return $self; + } + + /** + * Base URL for the model provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the model provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } +} diff --git a/src/Sessions/ModelConfig/AzureAPIKeyModelConfigObject/ProviderOptions.php b/src/Sessions/ModelConfig/AzureAPIKeyModelConfigObject/ProviderOptions.php new file mode 100644 index 0000000..6f592b3 --- /dev/null +++ b/src/Sessions/ModelConfig/AzureAPIKeyModelConfigObject/ProviderOptions.php @@ -0,0 +1,77 @@ + */ + use SdkModel; + + /** + * Azure OpenAI provider-specific settings. + */ + #[Required] + public Azure $azure; + + /** + * `new ProviderOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ProviderOptions::with(azure: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ProviderOptions)->withAzure(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Azure|AzureShape $azure + */ + public static function with(Azure|array $azure): self + { + $self = new self; + + $self['azure'] = $azure; + + return $self; + } + + /** + * Azure OpenAI provider-specific settings. + * + * @param Azure|AzureShape $azure + */ + public function withAzure(Azure|array $azure): self + { + $self = clone $this; + $self['azure'] = $azure; + + return $self; + } +} diff --git a/src/Sessions/ModelConfig/AzureAPIKeyModelConfigObject/ProviderOptions/Azure.php b/src/Sessions/ModelConfig/AzureAPIKeyModelConfigObject/ProviderOptions/Azure.php new file mode 100644 index 0000000..ac2bdc7 --- /dev/null +++ b/src/Sessions/ModelConfig/AzureAPIKeyModelConfigObject/ProviderOptions/Azure.php @@ -0,0 +1,146 @@ +|null, + * resourceName?: string|null, + * useDeploymentBasedURLs?: bool|null, + * } + */ +final class Azure implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI API version. + */ + #[Optional] + public ?string $apiVersion; + + /** + * Base URL for the Azure OpenAI provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * Azure OpenAI resource name. + */ + #[Optional] + public ?string $resourceName; + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + #[Optional('useDeploymentBasedUrls')] + public ?bool $useDeploymentBasedURLs; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param array|null $headers + */ + public static function with( + ?string $apiVersion = null, + ?string $baseURL = null, + ?array $headers = null, + ?string $resourceName = null, + ?bool $useDeploymentBasedURLs = null, + ): self { + $self = new self; + + null !== $apiVersion && $self['apiVersion'] = $apiVersion; + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + null !== $resourceName && $self['resourceName'] = $resourceName; + null !== $useDeploymentBasedURLs && $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } + + /** + * Azure OpenAI API version. + */ + public function withAPIVersion(string $apiVersion): self + { + $self = clone $this; + $self['apiVersion'] = $apiVersion; + + return $self; + } + + /** + * Base URL for the Azure OpenAI provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } + + /** + * Azure OpenAI resource name. + */ + public function withResourceName(string $resourceName): self + { + $self = clone $this; + $self['resourceName'] = $resourceName; + + return $self; + } + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + public function withUseDeploymentBasedURLs( + bool $useDeploymentBasedURLs + ): self { + $self = clone $this; + $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } +} diff --git a/src/Sessions/ModelConfig/AzureEntraModelConfigObject.php b/src/Sessions/ModelConfig/AzureEntraModelConfigObject.php new file mode 100644 index 0000000..0971a20 --- /dev/null +++ b/src/Sessions/ModelConfig/AzureEntraModelConfigObject.php @@ -0,0 +1,198 @@ +|null, + * } + */ +final class AzureEntraModelConfigObject implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI model provider. + * + * @var 'azure' $provider + */ + #[Required] + public string $provider = 'azure'; + + /** + * Azure provider authentication configuration. + */ + #[Required] + public Auth $auth; + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + #[Required] + public string $modelName; + + /** + * Azure provider-specific model configuration. + */ + #[Required] + public ProviderOptions $providerOptions; + + /** + * Base URL for the model provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the model provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * `new AzureEntraModelConfigObject()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AzureEntraModelConfigObject::with( + * auth: ..., modelName: ..., providerOptions: ... + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AzureEntraModelConfigObject) + * ->withAuth(...) + * ->withModelName(...) + * ->withProviderOptions(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Auth|AuthShape $auth + * @param ProviderOptions|ProviderOptionsShape $providerOptions + * @param array|null $headers + */ + public static function with( + Auth|array $auth, + string $modelName, + ProviderOptions|array $providerOptions, + ?string $baseURL = null, + ?array $headers = null, + ): self { + $self = new self; + + $self['auth'] = $auth; + $self['modelName'] = $modelName; + $self['providerOptions'] = $providerOptions; + + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + + return $self; + } + + /** + * Azure provider authentication configuration. + * + * @param Auth|AuthShape $auth + */ + public function withAuth(Auth|array $auth): self + { + $self = clone $this; + $self['auth'] = $auth; + + return $self; + } + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + public function withModelName(string $modelName): self + { + $self = clone $this; + $self['modelName'] = $modelName; + + return $self; + } + + /** + * Azure OpenAI model provider. + * + * @param 'azure' $provider + */ + public function withProvider(string $provider): self + { + $self = clone $this; + $self['provider'] = $provider; + + return $self; + } + + /** + * Azure provider-specific model configuration. + * + * @param ProviderOptions|ProviderOptionsShape $providerOptions + */ + public function withProviderOptions( + ProviderOptions|array $providerOptions + ): self { + $self = clone $this; + $self['providerOptions'] = $providerOptions; + + return $self; + } + + /** + * Base URL for the model provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the model provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } +} diff --git a/src/Sessions/ModelConfig/AzureEntraModelConfigObject/Auth.php b/src/Sessions/ModelConfig/AzureEntraModelConfigObject/Auth.php new file mode 100644 index 0000000..141e215 --- /dev/null +++ b/src/Sessions/ModelConfig/AzureEntraModelConfigObject/Auth.php @@ -0,0 +1,91 @@ + */ + use SdkModel; + + /** + * Use a Microsoft Entra ID bearer token for authentication. + * + * @var 'azureEntraId' $type + */ + #[Required] + public string $type = 'azureEntraId'; + + /** + * Microsoft Entra ID bearer token for Azure OpenAI. + */ + #[Required] + public string $token; + + /** + * `new Auth()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Auth::with(token: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Auth)->withToken(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(string $token): self + { + $self = new self; + + $self['token'] = $token; + + return $self; + } + + /** + * Microsoft Entra ID bearer token for Azure OpenAI. + */ + public function withToken(string $token): self + { + $self = clone $this; + $self['token'] = $token; + + return $self; + } + + /** + * Use a Microsoft Entra ID bearer token for authentication. + * + * @param 'azureEntraId' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } +} diff --git a/src/Sessions/ModelConfig/AzureEntraModelConfigObject/ProviderOptions.php b/src/Sessions/ModelConfig/AzureEntraModelConfigObject/ProviderOptions.php new file mode 100644 index 0000000..efc0178 --- /dev/null +++ b/src/Sessions/ModelConfig/AzureEntraModelConfigObject/ProviderOptions.php @@ -0,0 +1,77 @@ + */ + use SdkModel; + + /** + * Azure OpenAI provider-specific settings. + */ + #[Required] + public Azure $azure; + + /** + * `new ProviderOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ProviderOptions::with(azure: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ProviderOptions)->withAzure(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Azure|AzureShape $azure + */ + public static function with(Azure|array $azure): self + { + $self = new self; + + $self['azure'] = $azure; + + return $self; + } + + /** + * Azure OpenAI provider-specific settings. + * + * @param Azure|AzureShape $azure + */ + public function withAzure(Azure|array $azure): self + { + $self = clone $this; + $self['azure'] = $azure; + + return $self; + } +} diff --git a/src/Sessions/ModelConfig/AzureEntraModelConfigObject/ProviderOptions/Azure.php b/src/Sessions/ModelConfig/AzureEntraModelConfigObject/ProviderOptions/Azure.php new file mode 100644 index 0000000..0e3f5f8 --- /dev/null +++ b/src/Sessions/ModelConfig/AzureEntraModelConfigObject/ProviderOptions/Azure.php @@ -0,0 +1,146 @@ +|null, + * resourceName?: string|null, + * useDeploymentBasedURLs?: bool|null, + * } + */ +final class Azure implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI API version. + */ + #[Optional] + public ?string $apiVersion; + + /** + * Base URL for the Azure OpenAI provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * Azure OpenAI resource name. + */ + #[Optional] + public ?string $resourceName; + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + #[Optional('useDeploymentBasedUrls')] + public ?bool $useDeploymentBasedURLs; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param array|null $headers + */ + public static function with( + ?string $apiVersion = null, + ?string $baseURL = null, + ?array $headers = null, + ?string $resourceName = null, + ?bool $useDeploymentBasedURLs = null, + ): self { + $self = new self; + + null !== $apiVersion && $self['apiVersion'] = $apiVersion; + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + null !== $resourceName && $self['resourceName'] = $resourceName; + null !== $useDeploymentBasedURLs && $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } + + /** + * Azure OpenAI API version. + */ + public function withAPIVersion(string $apiVersion): self + { + $self = clone $this; + $self['apiVersion'] = $apiVersion; + + return $self; + } + + /** + * Base URL for the Azure OpenAI provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } + + /** + * Azure OpenAI resource name. + */ + public function withResourceName(string $resourceName): self + { + $self = clone $this; + $self['resourceName'] = $resourceName; + + return $self; + } + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + public function withUseDeploymentBasedURLs( + bool $useDeploymentBasedURLs + ): self { + $self = clone $this; + $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } +} diff --git a/src/Sessions/SessionActParams/Options.php b/src/Sessions/SessionActParams/Options.php index 0cd84c2..2007a77 100644 --- a/src/Sessions/SessionActParams/Options.php +++ b/src/Sessions/SessionActParams/Options.php @@ -7,6 +7,8 @@ use Stagehand\Core\Attributes\Optional; use Stagehand\Core\Concerns\SdkModel; use Stagehand\Core\Contracts\BaseModel; +use Stagehand\Sessions\SessionActParams\Options\Model\AzureAPIKeyModelConfigObject; +use Stagehand\Sessions\SessionActParams\Options\Model\AzureEntraModelConfigObject; use Stagehand\Sessions\SessionActParams\Options\Model\GenericModelConfigObject; use Stagehand\Sessions\SessionActParams\Options\Model\VertexModelConfigObject; use Stagehand\Sessions\SessionActParams\Options\Variable; @@ -34,7 +36,7 @@ final class Options implements BaseModel * @var ModelVariants|null $model */ #[Optional] - public string|VertexModelConfigObject|GenericModelConfigObject|null $model; + public string|VertexModelConfigObject|AzureEntraModelConfigObject|AzureAPIKeyModelConfigObject|GenericModelConfigObject|null $model; /** * Timeout in ms for the action. @@ -64,7 +66,7 @@ public function __construct() * @param array|null $variables */ public static function with( - string|VertexModelConfigObject|array|GenericModelConfigObject|null $model = null, + string|VertexModelConfigObject|array|AzureEntraModelConfigObject|AzureAPIKeyModelConfigObject|GenericModelConfigObject|null $model = null, ?float $timeout = null, ?array $variables = null, ): self { @@ -83,7 +85,7 @@ public static function with( * @param ModelShape $model */ public function withModel( - string|VertexModelConfigObject|array|GenericModelConfigObject $model + string|VertexModelConfigObject|array|AzureEntraModelConfigObject|AzureAPIKeyModelConfigObject|GenericModelConfigObject $model, ): self { $self = clone $this; $self['model'] = $model; diff --git a/src/Sessions/SessionActParams/Options/Model.php b/src/Sessions/SessionActParams/Options/Model.php index da1cc51..58acf42 100644 --- a/src/Sessions/SessionActParams/Options/Model.php +++ b/src/Sessions/SessionActParams/Options/Model.php @@ -7,6 +7,8 @@ use Stagehand\Core\Concerns\SdkUnion; use Stagehand\Core\Conversion\Contracts\Converter; use Stagehand\Core\Conversion\Contracts\ConverterSource; +use Stagehand\Sessions\SessionActParams\Options\Model\AzureAPIKeyModelConfigObject; +use Stagehand\Sessions\SessionActParams\Options\Model\AzureEntraModelConfigObject; use Stagehand\Sessions\SessionActParams\Options\Model\GenericModelConfigObject; use Stagehand\Sessions\SessionActParams\Options\Model\VertexModelConfigObject; @@ -14,10 +16,12 @@ * Model configuration object or model name string (e.g., 'openai/gpt-5-nano'). * * @phpstan-import-type VertexModelConfigObjectShape from \Stagehand\Sessions\SessionActParams\Options\Model\VertexModelConfigObject + * @phpstan-import-type AzureEntraModelConfigObjectShape from \Stagehand\Sessions\SessionActParams\Options\Model\AzureEntraModelConfigObject + * @phpstan-import-type AzureAPIKeyModelConfigObjectShape from \Stagehand\Sessions\SessionActParams\Options\Model\AzureAPIKeyModelConfigObject * @phpstan-import-type GenericModelConfigObjectShape from \Stagehand\Sessions\SessionActParams\Options\Model\GenericModelConfigObject * - * @phpstan-type ModelVariants = string|VertexModelConfigObject|GenericModelConfigObject - * @phpstan-type ModelShape = ModelVariants|VertexModelConfigObjectShape|GenericModelConfigObjectShape + * @phpstan-type ModelVariants = string|VertexModelConfigObject|AzureEntraModelConfigObject|AzureAPIKeyModelConfigObject|GenericModelConfigObject + * @phpstan-type ModelShape = ModelVariants|VertexModelConfigObjectShape|AzureEntraModelConfigObjectShape|AzureAPIKeyModelConfigObjectShape|GenericModelConfigObjectShape */ final class Model implements ConverterSource { @@ -29,7 +33,11 @@ final class Model implements ConverterSource public static function variants(): array { return [ - VertexModelConfigObject::class, GenericModelConfigObject::class, 'string', + VertexModelConfigObject::class, + AzureEntraModelConfigObject::class, + AzureAPIKeyModelConfigObject::class, + GenericModelConfigObject::class, + 'string', ]; } } diff --git a/src/Sessions/SessionActParams/Options/Model/AzureAPIKeyModelConfigObject.php b/src/Sessions/SessionActParams/Options/Model/AzureAPIKeyModelConfigObject.php new file mode 100644 index 0000000..51675fc --- /dev/null +++ b/src/Sessions/SessionActParams/Options/Model/AzureAPIKeyModelConfigObject.php @@ -0,0 +1,188 @@ +|null, + * } + */ +final class AzureAPIKeyModelConfigObject implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI model provider. + * + * @var 'azure' $provider + */ + #[Required] + public string $provider = 'azure'; + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + #[Required] + public string $modelName; + + /** + * Azure provider-specific model configuration. + */ + #[Required] + public ProviderOptions $providerOptions; + + /** + * API key for the model provider. + */ + #[Optional] + public ?string $apiKey; + + /** + * Base URL for the model provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the model provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * `new AzureAPIKeyModelConfigObject()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AzureAPIKeyModelConfigObject::with(modelName: ..., providerOptions: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AzureAPIKeyModelConfigObject)->withModelName(...)->withProviderOptions(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param ProviderOptions|ProviderOptionsShape $providerOptions + * @param array|null $headers + */ + public static function with( + string $modelName, + ProviderOptions|array $providerOptions, + ?string $apiKey = null, + ?string $baseURL = null, + ?array $headers = null, + ): self { + $self = new self; + + $self['modelName'] = $modelName; + $self['providerOptions'] = $providerOptions; + + null !== $apiKey && $self['apiKey'] = $apiKey; + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + + return $self; + } + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + public function withModelName(string $modelName): self + { + $self = clone $this; + $self['modelName'] = $modelName; + + return $self; + } + + /** + * Azure OpenAI model provider. + * + * @param 'azure' $provider + */ + public function withProvider(string $provider): self + { + $self = clone $this; + $self['provider'] = $provider; + + return $self; + } + + /** + * Azure provider-specific model configuration. + * + * @param ProviderOptions|ProviderOptionsShape $providerOptions + */ + public function withProviderOptions( + ProviderOptions|array $providerOptions + ): self { + $self = clone $this; + $self['providerOptions'] = $providerOptions; + + return $self; + } + + /** + * API key for the model provider. + */ + public function withAPIKey(string $apiKey): self + { + $self = clone $this; + $self['apiKey'] = $apiKey; + + return $self; + } + + /** + * Base URL for the model provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the model provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } +} diff --git a/src/Sessions/SessionActParams/Options/Model/AzureAPIKeyModelConfigObject/ProviderOptions.php b/src/Sessions/SessionActParams/Options/Model/AzureAPIKeyModelConfigObject/ProviderOptions.php new file mode 100644 index 0000000..d78369e --- /dev/null +++ b/src/Sessions/SessionActParams/Options/Model/AzureAPIKeyModelConfigObject/ProviderOptions.php @@ -0,0 +1,77 @@ + */ + use SdkModel; + + /** + * Azure OpenAI provider-specific settings. + */ + #[Required] + public Azure $azure; + + /** + * `new ProviderOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ProviderOptions::with(azure: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ProviderOptions)->withAzure(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Azure|AzureShape $azure + */ + public static function with(Azure|array $azure): self + { + $self = new self; + + $self['azure'] = $azure; + + return $self; + } + + /** + * Azure OpenAI provider-specific settings. + * + * @param Azure|AzureShape $azure + */ + public function withAzure(Azure|array $azure): self + { + $self = clone $this; + $self['azure'] = $azure; + + return $self; + } +} diff --git a/src/Sessions/SessionActParams/Options/Model/AzureAPIKeyModelConfigObject/ProviderOptions/Azure.php b/src/Sessions/SessionActParams/Options/Model/AzureAPIKeyModelConfigObject/ProviderOptions/Azure.php new file mode 100644 index 0000000..360aa69 --- /dev/null +++ b/src/Sessions/SessionActParams/Options/Model/AzureAPIKeyModelConfigObject/ProviderOptions/Azure.php @@ -0,0 +1,146 @@ +|null, + * resourceName?: string|null, + * useDeploymentBasedURLs?: bool|null, + * } + */ +final class Azure implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI API version. + */ + #[Optional] + public ?string $apiVersion; + + /** + * Base URL for the Azure OpenAI provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * Azure OpenAI resource name. + */ + #[Optional] + public ?string $resourceName; + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + #[Optional('useDeploymentBasedUrls')] + public ?bool $useDeploymentBasedURLs; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param array|null $headers + */ + public static function with( + ?string $apiVersion = null, + ?string $baseURL = null, + ?array $headers = null, + ?string $resourceName = null, + ?bool $useDeploymentBasedURLs = null, + ): self { + $self = new self; + + null !== $apiVersion && $self['apiVersion'] = $apiVersion; + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + null !== $resourceName && $self['resourceName'] = $resourceName; + null !== $useDeploymentBasedURLs && $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } + + /** + * Azure OpenAI API version. + */ + public function withAPIVersion(string $apiVersion): self + { + $self = clone $this; + $self['apiVersion'] = $apiVersion; + + return $self; + } + + /** + * Base URL for the Azure OpenAI provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } + + /** + * Azure OpenAI resource name. + */ + public function withResourceName(string $resourceName): self + { + $self = clone $this; + $self['resourceName'] = $resourceName; + + return $self; + } + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + public function withUseDeploymentBasedURLs( + bool $useDeploymentBasedURLs + ): self { + $self = clone $this; + $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } +} diff --git a/src/Sessions/SessionActParams/Options/Model/AzureEntraModelConfigObject.php b/src/Sessions/SessionActParams/Options/Model/AzureEntraModelConfigObject.php new file mode 100644 index 0000000..83a40f4 --- /dev/null +++ b/src/Sessions/SessionActParams/Options/Model/AzureEntraModelConfigObject.php @@ -0,0 +1,198 @@ +|null, + * } + */ +final class AzureEntraModelConfigObject implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI model provider. + * + * @var 'azure' $provider + */ + #[Required] + public string $provider = 'azure'; + + /** + * Azure provider authentication configuration. + */ + #[Required] + public Auth $auth; + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + #[Required] + public string $modelName; + + /** + * Azure provider-specific model configuration. + */ + #[Required] + public ProviderOptions $providerOptions; + + /** + * Base URL for the model provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the model provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * `new AzureEntraModelConfigObject()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AzureEntraModelConfigObject::with( + * auth: ..., modelName: ..., providerOptions: ... + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AzureEntraModelConfigObject) + * ->withAuth(...) + * ->withModelName(...) + * ->withProviderOptions(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Auth|AuthShape $auth + * @param ProviderOptions|ProviderOptionsShape $providerOptions + * @param array|null $headers + */ + public static function with( + Auth|array $auth, + string $modelName, + ProviderOptions|array $providerOptions, + ?string $baseURL = null, + ?array $headers = null, + ): self { + $self = new self; + + $self['auth'] = $auth; + $self['modelName'] = $modelName; + $self['providerOptions'] = $providerOptions; + + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + + return $self; + } + + /** + * Azure provider authentication configuration. + * + * @param Auth|AuthShape $auth + */ + public function withAuth(Auth|array $auth): self + { + $self = clone $this; + $self['auth'] = $auth; + + return $self; + } + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + public function withModelName(string $modelName): self + { + $self = clone $this; + $self['modelName'] = $modelName; + + return $self; + } + + /** + * Azure OpenAI model provider. + * + * @param 'azure' $provider + */ + public function withProvider(string $provider): self + { + $self = clone $this; + $self['provider'] = $provider; + + return $self; + } + + /** + * Azure provider-specific model configuration. + * + * @param ProviderOptions|ProviderOptionsShape $providerOptions + */ + public function withProviderOptions( + ProviderOptions|array $providerOptions + ): self { + $self = clone $this; + $self['providerOptions'] = $providerOptions; + + return $self; + } + + /** + * Base URL for the model provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the model provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } +} diff --git a/src/Sessions/SessionActParams/Options/Model/AzureEntraModelConfigObject/Auth.php b/src/Sessions/SessionActParams/Options/Model/AzureEntraModelConfigObject/Auth.php new file mode 100644 index 0000000..385be35 --- /dev/null +++ b/src/Sessions/SessionActParams/Options/Model/AzureEntraModelConfigObject/Auth.php @@ -0,0 +1,91 @@ + */ + use SdkModel; + + /** + * Use a Microsoft Entra ID bearer token for authentication. + * + * @var 'azureEntraId' $type + */ + #[Required] + public string $type = 'azureEntraId'; + + /** + * Microsoft Entra ID bearer token for Azure OpenAI. + */ + #[Required] + public string $token; + + /** + * `new Auth()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Auth::with(token: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Auth)->withToken(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(string $token): self + { + $self = new self; + + $self['token'] = $token; + + return $self; + } + + /** + * Microsoft Entra ID bearer token for Azure OpenAI. + */ + public function withToken(string $token): self + { + $self = clone $this; + $self['token'] = $token; + + return $self; + } + + /** + * Use a Microsoft Entra ID bearer token for authentication. + * + * @param 'azureEntraId' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } +} diff --git a/src/Sessions/SessionActParams/Options/Model/AzureEntraModelConfigObject/ProviderOptions.php b/src/Sessions/SessionActParams/Options/Model/AzureEntraModelConfigObject/ProviderOptions.php new file mode 100644 index 0000000..15614e2 --- /dev/null +++ b/src/Sessions/SessionActParams/Options/Model/AzureEntraModelConfigObject/ProviderOptions.php @@ -0,0 +1,77 @@ + */ + use SdkModel; + + /** + * Azure OpenAI provider-specific settings. + */ + #[Required] + public Azure $azure; + + /** + * `new ProviderOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ProviderOptions::with(azure: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ProviderOptions)->withAzure(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Azure|AzureShape $azure + */ + public static function with(Azure|array $azure): self + { + $self = new self; + + $self['azure'] = $azure; + + return $self; + } + + /** + * Azure OpenAI provider-specific settings. + * + * @param Azure|AzureShape $azure + */ + public function withAzure(Azure|array $azure): self + { + $self = clone $this; + $self['azure'] = $azure; + + return $self; + } +} diff --git a/src/Sessions/SessionActParams/Options/Model/AzureEntraModelConfigObject/ProviderOptions/Azure.php b/src/Sessions/SessionActParams/Options/Model/AzureEntraModelConfigObject/ProviderOptions/Azure.php new file mode 100644 index 0000000..517bd18 --- /dev/null +++ b/src/Sessions/SessionActParams/Options/Model/AzureEntraModelConfigObject/ProviderOptions/Azure.php @@ -0,0 +1,146 @@ +|null, + * resourceName?: string|null, + * useDeploymentBasedURLs?: bool|null, + * } + */ +final class Azure implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI API version. + */ + #[Optional] + public ?string $apiVersion; + + /** + * Base URL for the Azure OpenAI provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * Azure OpenAI resource name. + */ + #[Optional] + public ?string $resourceName; + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + #[Optional('useDeploymentBasedUrls')] + public ?bool $useDeploymentBasedURLs; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param array|null $headers + */ + public static function with( + ?string $apiVersion = null, + ?string $baseURL = null, + ?array $headers = null, + ?string $resourceName = null, + ?bool $useDeploymentBasedURLs = null, + ): self { + $self = new self; + + null !== $apiVersion && $self['apiVersion'] = $apiVersion; + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + null !== $resourceName && $self['resourceName'] = $resourceName; + null !== $useDeploymentBasedURLs && $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } + + /** + * Azure OpenAI API version. + */ + public function withAPIVersion(string $apiVersion): self + { + $self = clone $this; + $self['apiVersion'] = $apiVersion; + + return $self; + } + + /** + * Base URL for the Azure OpenAI provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } + + /** + * Azure OpenAI resource name. + */ + public function withResourceName(string $resourceName): self + { + $self = clone $this; + $self['resourceName'] = $resourceName; + + return $self; + } + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + public function withUseDeploymentBasedURLs( + bool $useDeploymentBasedURLs + ): self { + $self = clone $this; + $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } +} diff --git a/src/Sessions/SessionExecuteParams/AgentConfig.php b/src/Sessions/SessionExecuteParams/AgentConfig.php index 04de895..656480e 100644 --- a/src/Sessions/SessionExecuteParams/AgentConfig.php +++ b/src/Sessions/SessionExecuteParams/AgentConfig.php @@ -7,6 +7,8 @@ use Stagehand\Core\Attributes\Optional; use Stagehand\Core\Concerns\SdkModel; use Stagehand\Core\Contracts\BaseModel; +use Stagehand\Sessions\SessionExecuteParams\AgentConfig\ExecutionModel\AzureAPIKeyModelConfigObject; +use Stagehand\Sessions\SessionExecuteParams\AgentConfig\ExecutionModel\AzureEntraModelConfigObject; use Stagehand\Sessions\SessionExecuteParams\AgentConfig\ExecutionModel\GenericModelConfigObject; use Stagehand\Sessions\SessionExecuteParams\AgentConfig\ExecutionModel\VertexModelConfigObject; use Stagehand\Sessions\SessionExecuteParams\AgentConfig\Mode; @@ -44,7 +46,7 @@ final class AgentConfig implements BaseModel * @var ExecutionModelVariants|null $executionModel */ #[Optional] - public string|VertexModelConfigObject|GenericModelConfigObject|null $executionModel; + public string|VertexModelConfigObject|AzureEntraModelConfigObject|AzureAPIKeyModelConfigObject|GenericModelConfigObject|null $executionModel; /** * Tool mode for the agent (dom, hybrid, cua). If set, overrides cua. @@ -60,7 +62,7 @@ final class AgentConfig implements BaseModel * @var ModelVariants|null $model */ #[Optional] - public string|\Stagehand\Sessions\SessionExecuteParams\AgentConfig\Model\VertexModelConfigObject|AgentConfig\Model\GenericModelConfigObject|null $model; + public string|\Stagehand\Sessions\SessionExecuteParams\AgentConfig\Model\VertexModelConfigObject|\Stagehand\Sessions\SessionExecuteParams\AgentConfig\Model\AzureEntraModelConfigObject|\Stagehand\Sessions\SessionExecuteParams\AgentConfig\Model\AzureAPIKeyModelConfigObject|AgentConfig\Model\GenericModelConfigObject|null $model; /** * AI provider for the agent (legacy, use model: openai/gpt-5-nano instead). @@ -93,9 +95,9 @@ public function __construct() */ public static function with( ?bool $cua = null, - string|VertexModelConfigObject|array|GenericModelConfigObject|null $executionModel = null, + string|VertexModelConfigObject|array|AzureEntraModelConfigObject|AzureAPIKeyModelConfigObject|GenericModelConfigObject|null $executionModel = null, Mode|string|null $mode = null, - string|AgentConfig\Model\VertexModelConfigObject|array|AgentConfig\Model\GenericModelConfigObject|null $model = null, + string|AgentConfig\Model\VertexModelConfigObject|array|AgentConfig\Model\AzureEntraModelConfigObject|AgentConfig\Model\AzureAPIKeyModelConfigObject|AgentConfig\Model\GenericModelConfigObject|null $model = null, Provider|string|null $provider = null, ?string $systemPrompt = null, ): self { @@ -128,7 +130,7 @@ public function withCua(bool $cua): self * @param ExecutionModelShape $executionModel */ public function withExecutionModel( - string|VertexModelConfigObject|array|GenericModelConfigObject $executionModel, + string|VertexModelConfigObject|array|AzureEntraModelConfigObject|AzureAPIKeyModelConfigObject|GenericModelConfigObject $executionModel, ): self { $self = clone $this; $self['executionModel'] = $executionModel; @@ -155,7 +157,7 @@ public function withMode(Mode|string $mode): self * @param ModelShape $model */ public function withModel( - string|AgentConfig\Model\VertexModelConfigObject|array|AgentConfig\Model\GenericModelConfigObject $model, + string|AgentConfig\Model\VertexModelConfigObject|array|AgentConfig\Model\AzureEntraModelConfigObject|AgentConfig\Model\AzureAPIKeyModelConfigObject|AgentConfig\Model\GenericModelConfigObject $model, ): self { $self = clone $this; $self['model'] = $model; diff --git a/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel.php b/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel.php index 47e2aaa..a0662e9 100644 --- a/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel.php +++ b/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel.php @@ -7,6 +7,8 @@ use Stagehand\Core\Concerns\SdkUnion; use Stagehand\Core\Conversion\Contracts\Converter; use Stagehand\Core\Conversion\Contracts\ConverterSource; +use Stagehand\Sessions\SessionExecuteParams\AgentConfig\ExecutionModel\AzureAPIKeyModelConfigObject; +use Stagehand\Sessions\SessionExecuteParams\AgentConfig\ExecutionModel\AzureEntraModelConfigObject; use Stagehand\Sessions\SessionExecuteParams\AgentConfig\ExecutionModel\GenericModelConfigObject; use Stagehand\Sessions\SessionExecuteParams\AgentConfig\ExecutionModel\VertexModelConfigObject; @@ -14,10 +16,12 @@ * Model configuration object or model name string (e.g., 'openai/gpt-5-nano') for tool execution (observe/act calls within agent tools). If not specified, inherits from the main model configuration. * * @phpstan-import-type VertexModelConfigObjectShape from \Stagehand\Sessions\SessionExecuteParams\AgentConfig\ExecutionModel\VertexModelConfigObject + * @phpstan-import-type AzureEntraModelConfigObjectShape from \Stagehand\Sessions\SessionExecuteParams\AgentConfig\ExecutionModel\AzureEntraModelConfigObject + * @phpstan-import-type AzureAPIKeyModelConfigObjectShape from \Stagehand\Sessions\SessionExecuteParams\AgentConfig\ExecutionModel\AzureAPIKeyModelConfigObject * @phpstan-import-type GenericModelConfigObjectShape from \Stagehand\Sessions\SessionExecuteParams\AgentConfig\ExecutionModel\GenericModelConfigObject * - * @phpstan-type ExecutionModelVariants = string|VertexModelConfigObject|GenericModelConfigObject - * @phpstan-type ExecutionModelShape = ExecutionModelVariants|VertexModelConfigObjectShape|GenericModelConfigObjectShape + * @phpstan-type ExecutionModelVariants = string|VertexModelConfigObject|AzureEntraModelConfigObject|AzureAPIKeyModelConfigObject|GenericModelConfigObject + * @phpstan-type ExecutionModelShape = ExecutionModelVariants|VertexModelConfigObjectShape|AzureEntraModelConfigObjectShape|AzureAPIKeyModelConfigObjectShape|GenericModelConfigObjectShape */ final class ExecutionModel implements ConverterSource { @@ -29,7 +33,11 @@ final class ExecutionModel implements ConverterSource public static function variants(): array { return [ - VertexModelConfigObject::class, GenericModelConfigObject::class, 'string', + VertexModelConfigObject::class, + AzureEntraModelConfigObject::class, + AzureAPIKeyModelConfigObject::class, + GenericModelConfigObject::class, + 'string', ]; } } diff --git a/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel/AzureAPIKeyModelConfigObject.php b/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel/AzureAPIKeyModelConfigObject.php new file mode 100644 index 0000000..b7be46d --- /dev/null +++ b/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel/AzureAPIKeyModelConfigObject.php @@ -0,0 +1,188 @@ +|null, + * } + */ +final class AzureAPIKeyModelConfigObject implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI model provider. + * + * @var 'azure' $provider + */ + #[Required] + public string $provider = 'azure'; + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + #[Required] + public string $modelName; + + /** + * Azure provider-specific model configuration. + */ + #[Required] + public ProviderOptions $providerOptions; + + /** + * API key for the model provider. + */ + #[Optional] + public ?string $apiKey; + + /** + * Base URL for the model provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the model provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * `new AzureAPIKeyModelConfigObject()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AzureAPIKeyModelConfigObject::with(modelName: ..., providerOptions: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AzureAPIKeyModelConfigObject)->withModelName(...)->withProviderOptions(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param ProviderOptions|ProviderOptionsShape $providerOptions + * @param array|null $headers + */ + public static function with( + string $modelName, + ProviderOptions|array $providerOptions, + ?string $apiKey = null, + ?string $baseURL = null, + ?array $headers = null, + ): self { + $self = new self; + + $self['modelName'] = $modelName; + $self['providerOptions'] = $providerOptions; + + null !== $apiKey && $self['apiKey'] = $apiKey; + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + + return $self; + } + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + public function withModelName(string $modelName): self + { + $self = clone $this; + $self['modelName'] = $modelName; + + return $self; + } + + /** + * Azure OpenAI model provider. + * + * @param 'azure' $provider + */ + public function withProvider(string $provider): self + { + $self = clone $this; + $self['provider'] = $provider; + + return $self; + } + + /** + * Azure provider-specific model configuration. + * + * @param ProviderOptions|ProviderOptionsShape $providerOptions + */ + public function withProviderOptions( + ProviderOptions|array $providerOptions + ): self { + $self = clone $this; + $self['providerOptions'] = $providerOptions; + + return $self; + } + + /** + * API key for the model provider. + */ + public function withAPIKey(string $apiKey): self + { + $self = clone $this; + $self['apiKey'] = $apiKey; + + return $self; + } + + /** + * Base URL for the model provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the model provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } +} diff --git a/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel/AzureAPIKeyModelConfigObject/ProviderOptions.php b/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel/AzureAPIKeyModelConfigObject/ProviderOptions.php new file mode 100644 index 0000000..bb56a52 --- /dev/null +++ b/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel/AzureAPIKeyModelConfigObject/ProviderOptions.php @@ -0,0 +1,77 @@ + */ + use SdkModel; + + /** + * Azure OpenAI provider-specific settings. + */ + #[Required] + public Azure $azure; + + /** + * `new ProviderOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ProviderOptions::with(azure: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ProviderOptions)->withAzure(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Azure|AzureShape $azure + */ + public static function with(Azure|array $azure): self + { + $self = new self; + + $self['azure'] = $azure; + + return $self; + } + + /** + * Azure OpenAI provider-specific settings. + * + * @param Azure|AzureShape $azure + */ + public function withAzure(Azure|array $azure): self + { + $self = clone $this; + $self['azure'] = $azure; + + return $self; + } +} diff --git a/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel/AzureAPIKeyModelConfigObject/ProviderOptions/Azure.php b/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel/AzureAPIKeyModelConfigObject/ProviderOptions/Azure.php new file mode 100644 index 0000000..dbe5935 --- /dev/null +++ b/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel/AzureAPIKeyModelConfigObject/ProviderOptions/Azure.php @@ -0,0 +1,146 @@ +|null, + * resourceName?: string|null, + * useDeploymentBasedURLs?: bool|null, + * } + */ +final class Azure implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI API version. + */ + #[Optional] + public ?string $apiVersion; + + /** + * Base URL for the Azure OpenAI provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * Azure OpenAI resource name. + */ + #[Optional] + public ?string $resourceName; + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + #[Optional('useDeploymentBasedUrls')] + public ?bool $useDeploymentBasedURLs; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param array|null $headers + */ + public static function with( + ?string $apiVersion = null, + ?string $baseURL = null, + ?array $headers = null, + ?string $resourceName = null, + ?bool $useDeploymentBasedURLs = null, + ): self { + $self = new self; + + null !== $apiVersion && $self['apiVersion'] = $apiVersion; + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + null !== $resourceName && $self['resourceName'] = $resourceName; + null !== $useDeploymentBasedURLs && $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } + + /** + * Azure OpenAI API version. + */ + public function withAPIVersion(string $apiVersion): self + { + $self = clone $this; + $self['apiVersion'] = $apiVersion; + + return $self; + } + + /** + * Base URL for the Azure OpenAI provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } + + /** + * Azure OpenAI resource name. + */ + public function withResourceName(string $resourceName): self + { + $self = clone $this; + $self['resourceName'] = $resourceName; + + return $self; + } + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + public function withUseDeploymentBasedURLs( + bool $useDeploymentBasedURLs + ): self { + $self = clone $this; + $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } +} diff --git a/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel/AzureEntraModelConfigObject.php b/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel/AzureEntraModelConfigObject.php new file mode 100644 index 0000000..3a1bd19 --- /dev/null +++ b/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel/AzureEntraModelConfigObject.php @@ -0,0 +1,198 @@ +|null, + * } + */ +final class AzureEntraModelConfigObject implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI model provider. + * + * @var 'azure' $provider + */ + #[Required] + public string $provider = 'azure'; + + /** + * Azure provider authentication configuration. + */ + #[Required] + public Auth $auth; + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + #[Required] + public string $modelName; + + /** + * Azure provider-specific model configuration. + */ + #[Required] + public ProviderOptions $providerOptions; + + /** + * Base URL for the model provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the model provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * `new AzureEntraModelConfigObject()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AzureEntraModelConfigObject::with( + * auth: ..., modelName: ..., providerOptions: ... + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AzureEntraModelConfigObject) + * ->withAuth(...) + * ->withModelName(...) + * ->withProviderOptions(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Auth|AuthShape $auth + * @param ProviderOptions|ProviderOptionsShape $providerOptions + * @param array|null $headers + */ + public static function with( + Auth|array $auth, + string $modelName, + ProviderOptions|array $providerOptions, + ?string $baseURL = null, + ?array $headers = null, + ): self { + $self = new self; + + $self['auth'] = $auth; + $self['modelName'] = $modelName; + $self['providerOptions'] = $providerOptions; + + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + + return $self; + } + + /** + * Azure provider authentication configuration. + * + * @param Auth|AuthShape $auth + */ + public function withAuth(Auth|array $auth): self + { + $self = clone $this; + $self['auth'] = $auth; + + return $self; + } + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + public function withModelName(string $modelName): self + { + $self = clone $this; + $self['modelName'] = $modelName; + + return $self; + } + + /** + * Azure OpenAI model provider. + * + * @param 'azure' $provider + */ + public function withProvider(string $provider): self + { + $self = clone $this; + $self['provider'] = $provider; + + return $self; + } + + /** + * Azure provider-specific model configuration. + * + * @param ProviderOptions|ProviderOptionsShape $providerOptions + */ + public function withProviderOptions( + ProviderOptions|array $providerOptions + ): self { + $self = clone $this; + $self['providerOptions'] = $providerOptions; + + return $self; + } + + /** + * Base URL for the model provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the model provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } +} diff --git a/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel/AzureEntraModelConfigObject/Auth.php b/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel/AzureEntraModelConfigObject/Auth.php new file mode 100644 index 0000000..843a789 --- /dev/null +++ b/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel/AzureEntraModelConfigObject/Auth.php @@ -0,0 +1,91 @@ + */ + use SdkModel; + + /** + * Use a Microsoft Entra ID bearer token for authentication. + * + * @var 'azureEntraId' $type + */ + #[Required] + public string $type = 'azureEntraId'; + + /** + * Microsoft Entra ID bearer token for Azure OpenAI. + */ + #[Required] + public string $token; + + /** + * `new Auth()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Auth::with(token: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Auth)->withToken(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(string $token): self + { + $self = new self; + + $self['token'] = $token; + + return $self; + } + + /** + * Microsoft Entra ID bearer token for Azure OpenAI. + */ + public function withToken(string $token): self + { + $self = clone $this; + $self['token'] = $token; + + return $self; + } + + /** + * Use a Microsoft Entra ID bearer token for authentication. + * + * @param 'azureEntraId' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } +} diff --git a/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel/AzureEntraModelConfigObject/ProviderOptions.php b/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel/AzureEntraModelConfigObject/ProviderOptions.php new file mode 100644 index 0000000..08f5519 --- /dev/null +++ b/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel/AzureEntraModelConfigObject/ProviderOptions.php @@ -0,0 +1,77 @@ + */ + use SdkModel; + + /** + * Azure OpenAI provider-specific settings. + */ + #[Required] + public Azure $azure; + + /** + * `new ProviderOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ProviderOptions::with(azure: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ProviderOptions)->withAzure(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Azure|AzureShape $azure + */ + public static function with(Azure|array $azure): self + { + $self = new self; + + $self['azure'] = $azure; + + return $self; + } + + /** + * Azure OpenAI provider-specific settings. + * + * @param Azure|AzureShape $azure + */ + public function withAzure(Azure|array $azure): self + { + $self = clone $this; + $self['azure'] = $azure; + + return $self; + } +} diff --git a/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel/AzureEntraModelConfigObject/ProviderOptions/Azure.php b/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel/AzureEntraModelConfigObject/ProviderOptions/Azure.php new file mode 100644 index 0000000..5ab568f --- /dev/null +++ b/src/Sessions/SessionExecuteParams/AgentConfig/ExecutionModel/AzureEntraModelConfigObject/ProviderOptions/Azure.php @@ -0,0 +1,146 @@ +|null, + * resourceName?: string|null, + * useDeploymentBasedURLs?: bool|null, + * } + */ +final class Azure implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI API version. + */ + #[Optional] + public ?string $apiVersion; + + /** + * Base URL for the Azure OpenAI provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * Azure OpenAI resource name. + */ + #[Optional] + public ?string $resourceName; + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + #[Optional('useDeploymentBasedUrls')] + public ?bool $useDeploymentBasedURLs; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param array|null $headers + */ + public static function with( + ?string $apiVersion = null, + ?string $baseURL = null, + ?array $headers = null, + ?string $resourceName = null, + ?bool $useDeploymentBasedURLs = null, + ): self { + $self = new self; + + null !== $apiVersion && $self['apiVersion'] = $apiVersion; + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + null !== $resourceName && $self['resourceName'] = $resourceName; + null !== $useDeploymentBasedURLs && $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } + + /** + * Azure OpenAI API version. + */ + public function withAPIVersion(string $apiVersion): self + { + $self = clone $this; + $self['apiVersion'] = $apiVersion; + + return $self; + } + + /** + * Base URL for the Azure OpenAI provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } + + /** + * Azure OpenAI resource name. + */ + public function withResourceName(string $resourceName): self + { + $self = clone $this; + $self['resourceName'] = $resourceName; + + return $self; + } + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + public function withUseDeploymentBasedURLs( + bool $useDeploymentBasedURLs + ): self { + $self = clone $this; + $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } +} diff --git a/src/Sessions/SessionExecuteParams/AgentConfig/Model.php b/src/Sessions/SessionExecuteParams/AgentConfig/Model.php index 7d3d45c..994bca2 100644 --- a/src/Sessions/SessionExecuteParams/AgentConfig/Model.php +++ b/src/Sessions/SessionExecuteParams/AgentConfig/Model.php @@ -7,6 +7,8 @@ use Stagehand\Core\Concerns\SdkUnion; use Stagehand\Core\Conversion\Contracts\Converter; use Stagehand\Core\Conversion\Contracts\ConverterSource; +use Stagehand\Sessions\SessionExecuteParams\AgentConfig\Model\AzureAPIKeyModelConfigObject; +use Stagehand\Sessions\SessionExecuteParams\AgentConfig\Model\AzureEntraModelConfigObject; use Stagehand\Sessions\SessionExecuteParams\AgentConfig\Model\GenericModelConfigObject; use Stagehand\Sessions\SessionExecuteParams\AgentConfig\Model\VertexModelConfigObject; @@ -14,10 +16,12 @@ * Model configuration object or model name string (e.g., 'openai/gpt-5-nano'). * * @phpstan-import-type VertexModelConfigObjectShape from \Stagehand\Sessions\SessionExecuteParams\AgentConfig\Model\VertexModelConfigObject + * @phpstan-import-type AzureEntraModelConfigObjectShape from \Stagehand\Sessions\SessionExecuteParams\AgentConfig\Model\AzureEntraModelConfigObject + * @phpstan-import-type AzureAPIKeyModelConfigObjectShape from \Stagehand\Sessions\SessionExecuteParams\AgentConfig\Model\AzureAPIKeyModelConfigObject * @phpstan-import-type GenericModelConfigObjectShape from \Stagehand\Sessions\SessionExecuteParams\AgentConfig\Model\GenericModelConfigObject * - * @phpstan-type ModelVariants = string|VertexModelConfigObject|GenericModelConfigObject - * @phpstan-type ModelShape = ModelVariants|VertexModelConfigObjectShape|GenericModelConfigObjectShape + * @phpstan-type ModelVariants = string|VertexModelConfigObject|AzureEntraModelConfigObject|AzureAPIKeyModelConfigObject|GenericModelConfigObject + * @phpstan-type ModelShape = ModelVariants|VertexModelConfigObjectShape|AzureEntraModelConfigObjectShape|AzureAPIKeyModelConfigObjectShape|GenericModelConfigObjectShape */ final class Model implements ConverterSource { @@ -29,7 +33,11 @@ final class Model implements ConverterSource public static function variants(): array { return [ - VertexModelConfigObject::class, GenericModelConfigObject::class, 'string', + VertexModelConfigObject::class, + AzureEntraModelConfigObject::class, + AzureAPIKeyModelConfigObject::class, + GenericModelConfigObject::class, + 'string', ]; } } diff --git a/src/Sessions/SessionExecuteParams/AgentConfig/Model/AzureAPIKeyModelConfigObject.php b/src/Sessions/SessionExecuteParams/AgentConfig/Model/AzureAPIKeyModelConfigObject.php new file mode 100644 index 0000000..d0009c8 --- /dev/null +++ b/src/Sessions/SessionExecuteParams/AgentConfig/Model/AzureAPIKeyModelConfigObject.php @@ -0,0 +1,188 @@ +|null, + * } + */ +final class AzureAPIKeyModelConfigObject implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI model provider. + * + * @var 'azure' $provider + */ + #[Required] + public string $provider = 'azure'; + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + #[Required] + public string $modelName; + + /** + * Azure provider-specific model configuration. + */ + #[Required] + public ProviderOptions $providerOptions; + + /** + * API key for the model provider. + */ + #[Optional] + public ?string $apiKey; + + /** + * Base URL for the model provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the model provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * `new AzureAPIKeyModelConfigObject()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AzureAPIKeyModelConfigObject::with(modelName: ..., providerOptions: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AzureAPIKeyModelConfigObject)->withModelName(...)->withProviderOptions(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param ProviderOptions|ProviderOptionsShape $providerOptions + * @param array|null $headers + */ + public static function with( + string $modelName, + ProviderOptions|array $providerOptions, + ?string $apiKey = null, + ?string $baseURL = null, + ?array $headers = null, + ): self { + $self = new self; + + $self['modelName'] = $modelName; + $self['providerOptions'] = $providerOptions; + + null !== $apiKey && $self['apiKey'] = $apiKey; + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + + return $self; + } + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + public function withModelName(string $modelName): self + { + $self = clone $this; + $self['modelName'] = $modelName; + + return $self; + } + + /** + * Azure OpenAI model provider. + * + * @param 'azure' $provider + */ + public function withProvider(string $provider): self + { + $self = clone $this; + $self['provider'] = $provider; + + return $self; + } + + /** + * Azure provider-specific model configuration. + * + * @param ProviderOptions|ProviderOptionsShape $providerOptions + */ + public function withProviderOptions( + ProviderOptions|array $providerOptions + ): self { + $self = clone $this; + $self['providerOptions'] = $providerOptions; + + return $self; + } + + /** + * API key for the model provider. + */ + public function withAPIKey(string $apiKey): self + { + $self = clone $this; + $self['apiKey'] = $apiKey; + + return $self; + } + + /** + * Base URL for the model provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the model provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } +} diff --git a/src/Sessions/SessionExecuteParams/AgentConfig/Model/AzureAPIKeyModelConfigObject/ProviderOptions.php b/src/Sessions/SessionExecuteParams/AgentConfig/Model/AzureAPIKeyModelConfigObject/ProviderOptions.php new file mode 100644 index 0000000..d4bf3dc --- /dev/null +++ b/src/Sessions/SessionExecuteParams/AgentConfig/Model/AzureAPIKeyModelConfigObject/ProviderOptions.php @@ -0,0 +1,77 @@ + */ + use SdkModel; + + /** + * Azure OpenAI provider-specific settings. + */ + #[Required] + public Azure $azure; + + /** + * `new ProviderOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ProviderOptions::with(azure: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ProviderOptions)->withAzure(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Azure|AzureShape $azure + */ + public static function with(Azure|array $azure): self + { + $self = new self; + + $self['azure'] = $azure; + + return $self; + } + + /** + * Azure OpenAI provider-specific settings. + * + * @param Azure|AzureShape $azure + */ + public function withAzure(Azure|array $azure): self + { + $self = clone $this; + $self['azure'] = $azure; + + return $self; + } +} diff --git a/src/Sessions/SessionExecuteParams/AgentConfig/Model/AzureAPIKeyModelConfigObject/ProviderOptions/Azure.php b/src/Sessions/SessionExecuteParams/AgentConfig/Model/AzureAPIKeyModelConfigObject/ProviderOptions/Azure.php new file mode 100644 index 0000000..f52cfa2 --- /dev/null +++ b/src/Sessions/SessionExecuteParams/AgentConfig/Model/AzureAPIKeyModelConfigObject/ProviderOptions/Azure.php @@ -0,0 +1,146 @@ +|null, + * resourceName?: string|null, + * useDeploymentBasedURLs?: bool|null, + * } + */ +final class Azure implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI API version. + */ + #[Optional] + public ?string $apiVersion; + + /** + * Base URL for the Azure OpenAI provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * Azure OpenAI resource name. + */ + #[Optional] + public ?string $resourceName; + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + #[Optional('useDeploymentBasedUrls')] + public ?bool $useDeploymentBasedURLs; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param array|null $headers + */ + public static function with( + ?string $apiVersion = null, + ?string $baseURL = null, + ?array $headers = null, + ?string $resourceName = null, + ?bool $useDeploymentBasedURLs = null, + ): self { + $self = new self; + + null !== $apiVersion && $self['apiVersion'] = $apiVersion; + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + null !== $resourceName && $self['resourceName'] = $resourceName; + null !== $useDeploymentBasedURLs && $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } + + /** + * Azure OpenAI API version. + */ + public function withAPIVersion(string $apiVersion): self + { + $self = clone $this; + $self['apiVersion'] = $apiVersion; + + return $self; + } + + /** + * Base URL for the Azure OpenAI provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } + + /** + * Azure OpenAI resource name. + */ + public function withResourceName(string $resourceName): self + { + $self = clone $this; + $self['resourceName'] = $resourceName; + + return $self; + } + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + public function withUseDeploymentBasedURLs( + bool $useDeploymentBasedURLs + ): self { + $self = clone $this; + $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } +} diff --git a/src/Sessions/SessionExecuteParams/AgentConfig/Model/AzureEntraModelConfigObject.php b/src/Sessions/SessionExecuteParams/AgentConfig/Model/AzureEntraModelConfigObject.php new file mode 100644 index 0000000..07fb78f --- /dev/null +++ b/src/Sessions/SessionExecuteParams/AgentConfig/Model/AzureEntraModelConfigObject.php @@ -0,0 +1,198 @@ +|null, + * } + */ +final class AzureEntraModelConfigObject implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI model provider. + * + * @var 'azure' $provider + */ + #[Required] + public string $provider = 'azure'; + + /** + * Azure provider authentication configuration. + */ + #[Required] + public Auth $auth; + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + #[Required] + public string $modelName; + + /** + * Azure provider-specific model configuration. + */ + #[Required] + public ProviderOptions $providerOptions; + + /** + * Base URL for the model provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the model provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * `new AzureEntraModelConfigObject()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AzureEntraModelConfigObject::with( + * auth: ..., modelName: ..., providerOptions: ... + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AzureEntraModelConfigObject) + * ->withAuth(...) + * ->withModelName(...) + * ->withProviderOptions(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Auth|AuthShape $auth + * @param ProviderOptions|ProviderOptionsShape $providerOptions + * @param array|null $headers + */ + public static function with( + Auth|array $auth, + string $modelName, + ProviderOptions|array $providerOptions, + ?string $baseURL = null, + ?array $headers = null, + ): self { + $self = new self; + + $self['auth'] = $auth; + $self['modelName'] = $modelName; + $self['providerOptions'] = $providerOptions; + + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + + return $self; + } + + /** + * Azure provider authentication configuration. + * + * @param Auth|AuthShape $auth + */ + public function withAuth(Auth|array $auth): self + { + $self = clone $this; + $self['auth'] = $auth; + + return $self; + } + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + public function withModelName(string $modelName): self + { + $self = clone $this; + $self['modelName'] = $modelName; + + return $self; + } + + /** + * Azure OpenAI model provider. + * + * @param 'azure' $provider + */ + public function withProvider(string $provider): self + { + $self = clone $this; + $self['provider'] = $provider; + + return $self; + } + + /** + * Azure provider-specific model configuration. + * + * @param ProviderOptions|ProviderOptionsShape $providerOptions + */ + public function withProviderOptions( + ProviderOptions|array $providerOptions + ): self { + $self = clone $this; + $self['providerOptions'] = $providerOptions; + + return $self; + } + + /** + * Base URL for the model provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the model provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } +} diff --git a/src/Sessions/SessionExecuteParams/AgentConfig/Model/AzureEntraModelConfigObject/Auth.php b/src/Sessions/SessionExecuteParams/AgentConfig/Model/AzureEntraModelConfigObject/Auth.php new file mode 100644 index 0000000..267e681 --- /dev/null +++ b/src/Sessions/SessionExecuteParams/AgentConfig/Model/AzureEntraModelConfigObject/Auth.php @@ -0,0 +1,91 @@ + */ + use SdkModel; + + /** + * Use a Microsoft Entra ID bearer token for authentication. + * + * @var 'azureEntraId' $type + */ + #[Required] + public string $type = 'azureEntraId'; + + /** + * Microsoft Entra ID bearer token for Azure OpenAI. + */ + #[Required] + public string $token; + + /** + * `new Auth()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Auth::with(token: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Auth)->withToken(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(string $token): self + { + $self = new self; + + $self['token'] = $token; + + return $self; + } + + /** + * Microsoft Entra ID bearer token for Azure OpenAI. + */ + public function withToken(string $token): self + { + $self = clone $this; + $self['token'] = $token; + + return $self; + } + + /** + * Use a Microsoft Entra ID bearer token for authentication. + * + * @param 'azureEntraId' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } +} diff --git a/src/Sessions/SessionExecuteParams/AgentConfig/Model/AzureEntraModelConfigObject/ProviderOptions.php b/src/Sessions/SessionExecuteParams/AgentConfig/Model/AzureEntraModelConfigObject/ProviderOptions.php new file mode 100644 index 0000000..5a0aa4a --- /dev/null +++ b/src/Sessions/SessionExecuteParams/AgentConfig/Model/AzureEntraModelConfigObject/ProviderOptions.php @@ -0,0 +1,77 @@ + */ + use SdkModel; + + /** + * Azure OpenAI provider-specific settings. + */ + #[Required] + public Azure $azure; + + /** + * `new ProviderOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ProviderOptions::with(azure: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ProviderOptions)->withAzure(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Azure|AzureShape $azure + */ + public static function with(Azure|array $azure): self + { + $self = new self; + + $self['azure'] = $azure; + + return $self; + } + + /** + * Azure OpenAI provider-specific settings. + * + * @param Azure|AzureShape $azure + */ + public function withAzure(Azure|array $azure): self + { + $self = clone $this; + $self['azure'] = $azure; + + return $self; + } +} diff --git a/src/Sessions/SessionExecuteParams/AgentConfig/Model/AzureEntraModelConfigObject/ProviderOptions/Azure.php b/src/Sessions/SessionExecuteParams/AgentConfig/Model/AzureEntraModelConfigObject/ProviderOptions/Azure.php new file mode 100644 index 0000000..92e07ab --- /dev/null +++ b/src/Sessions/SessionExecuteParams/AgentConfig/Model/AzureEntraModelConfigObject/ProviderOptions/Azure.php @@ -0,0 +1,146 @@ +|null, + * resourceName?: string|null, + * useDeploymentBasedURLs?: bool|null, + * } + */ +final class Azure implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI API version. + */ + #[Optional] + public ?string $apiVersion; + + /** + * Base URL for the Azure OpenAI provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * Azure OpenAI resource name. + */ + #[Optional] + public ?string $resourceName; + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + #[Optional('useDeploymentBasedUrls')] + public ?bool $useDeploymentBasedURLs; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param array|null $headers + */ + public static function with( + ?string $apiVersion = null, + ?string $baseURL = null, + ?array $headers = null, + ?string $resourceName = null, + ?bool $useDeploymentBasedURLs = null, + ): self { + $self = new self; + + null !== $apiVersion && $self['apiVersion'] = $apiVersion; + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + null !== $resourceName && $self['resourceName'] = $resourceName; + null !== $useDeploymentBasedURLs && $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } + + /** + * Azure OpenAI API version. + */ + public function withAPIVersion(string $apiVersion): self + { + $self = clone $this; + $self['apiVersion'] = $apiVersion; + + return $self; + } + + /** + * Base URL for the Azure OpenAI provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } + + /** + * Azure OpenAI resource name. + */ + public function withResourceName(string $resourceName): self + { + $self = clone $this; + $self['resourceName'] = $resourceName; + + return $self; + } + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + public function withUseDeploymentBasedURLs( + bool $useDeploymentBasedURLs + ): self { + $self = clone $this; + $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } +} diff --git a/src/Sessions/SessionExtractParams/Options.php b/src/Sessions/SessionExtractParams/Options.php index d364a3f..2434c1a 100644 --- a/src/Sessions/SessionExtractParams/Options.php +++ b/src/Sessions/SessionExtractParams/Options.php @@ -7,6 +7,8 @@ use Stagehand\Core\Attributes\Optional; use Stagehand\Core\Concerns\SdkModel; use Stagehand\Core\Contracts\BaseModel; +use Stagehand\Sessions\SessionExtractParams\Options\Model\AzureAPIKeyModelConfigObject; +use Stagehand\Sessions\SessionExtractParams\Options\Model\AzureEntraModelConfigObject; use Stagehand\Sessions\SessionExtractParams\Options\Model\GenericModelConfigObject; use Stagehand\Sessions\SessionExtractParams\Options\Model\VertexModelConfigObject; @@ -41,7 +43,7 @@ final class Options implements BaseModel * @var ModelVariants|null $model */ #[Optional] - public string|VertexModelConfigObject|GenericModelConfigObject|null $model; + public string|VertexModelConfigObject|AzureEntraModelConfigObject|AzureAPIKeyModelConfigObject|GenericModelConfigObject|null $model; /** * When true, include a screenshot of the current viewport in the extraction LLM call. Defaults to false. @@ -76,7 +78,7 @@ public function __construct() */ public static function with( ?array $ignoreSelectors = null, - string|VertexModelConfigObject|array|GenericModelConfigObject|null $model = null, + string|VertexModelConfigObject|array|AzureEntraModelConfigObject|AzureAPIKeyModelConfigObject|GenericModelConfigObject|null $model = null, ?bool $screenshot = null, ?string $selector = null, ?float $timeout = null, @@ -111,7 +113,7 @@ public function withIgnoreSelectors(array $ignoreSelectors): self * @param ModelShape $model */ public function withModel( - string|VertexModelConfigObject|array|GenericModelConfigObject $model + string|VertexModelConfigObject|array|AzureEntraModelConfigObject|AzureAPIKeyModelConfigObject|GenericModelConfigObject $model, ): self { $self = clone $this; $self['model'] = $model; diff --git a/src/Sessions/SessionExtractParams/Options/Model.php b/src/Sessions/SessionExtractParams/Options/Model.php index 444bcd6..a20184a 100644 --- a/src/Sessions/SessionExtractParams/Options/Model.php +++ b/src/Sessions/SessionExtractParams/Options/Model.php @@ -7,6 +7,8 @@ use Stagehand\Core\Concerns\SdkUnion; use Stagehand\Core\Conversion\Contracts\Converter; use Stagehand\Core\Conversion\Contracts\ConverterSource; +use Stagehand\Sessions\SessionExtractParams\Options\Model\AzureAPIKeyModelConfigObject; +use Stagehand\Sessions\SessionExtractParams\Options\Model\AzureEntraModelConfigObject; use Stagehand\Sessions\SessionExtractParams\Options\Model\GenericModelConfigObject; use Stagehand\Sessions\SessionExtractParams\Options\Model\VertexModelConfigObject; @@ -14,10 +16,12 @@ * Model configuration object or model name string (e.g., 'openai/gpt-5-nano'). * * @phpstan-import-type VertexModelConfigObjectShape from \Stagehand\Sessions\SessionExtractParams\Options\Model\VertexModelConfigObject + * @phpstan-import-type AzureEntraModelConfigObjectShape from \Stagehand\Sessions\SessionExtractParams\Options\Model\AzureEntraModelConfigObject + * @phpstan-import-type AzureAPIKeyModelConfigObjectShape from \Stagehand\Sessions\SessionExtractParams\Options\Model\AzureAPIKeyModelConfigObject * @phpstan-import-type GenericModelConfigObjectShape from \Stagehand\Sessions\SessionExtractParams\Options\Model\GenericModelConfigObject * - * @phpstan-type ModelVariants = string|VertexModelConfigObject|GenericModelConfigObject - * @phpstan-type ModelShape = ModelVariants|VertexModelConfigObjectShape|GenericModelConfigObjectShape + * @phpstan-type ModelVariants = string|VertexModelConfigObject|AzureEntraModelConfigObject|AzureAPIKeyModelConfigObject|GenericModelConfigObject + * @phpstan-type ModelShape = ModelVariants|VertexModelConfigObjectShape|AzureEntraModelConfigObjectShape|AzureAPIKeyModelConfigObjectShape|GenericModelConfigObjectShape */ final class Model implements ConverterSource { @@ -29,7 +33,11 @@ final class Model implements ConverterSource public static function variants(): array { return [ - VertexModelConfigObject::class, GenericModelConfigObject::class, 'string', + VertexModelConfigObject::class, + AzureEntraModelConfigObject::class, + AzureAPIKeyModelConfigObject::class, + GenericModelConfigObject::class, + 'string', ]; } } diff --git a/src/Sessions/SessionExtractParams/Options/Model/AzureAPIKeyModelConfigObject.php b/src/Sessions/SessionExtractParams/Options/Model/AzureAPIKeyModelConfigObject.php new file mode 100644 index 0000000..63183d7 --- /dev/null +++ b/src/Sessions/SessionExtractParams/Options/Model/AzureAPIKeyModelConfigObject.php @@ -0,0 +1,188 @@ +|null, + * } + */ +final class AzureAPIKeyModelConfigObject implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI model provider. + * + * @var 'azure' $provider + */ + #[Required] + public string $provider = 'azure'; + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + #[Required] + public string $modelName; + + /** + * Azure provider-specific model configuration. + */ + #[Required] + public ProviderOptions $providerOptions; + + /** + * API key for the model provider. + */ + #[Optional] + public ?string $apiKey; + + /** + * Base URL for the model provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the model provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * `new AzureAPIKeyModelConfigObject()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AzureAPIKeyModelConfigObject::with(modelName: ..., providerOptions: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AzureAPIKeyModelConfigObject)->withModelName(...)->withProviderOptions(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param ProviderOptions|ProviderOptionsShape $providerOptions + * @param array|null $headers + */ + public static function with( + string $modelName, + ProviderOptions|array $providerOptions, + ?string $apiKey = null, + ?string $baseURL = null, + ?array $headers = null, + ): self { + $self = new self; + + $self['modelName'] = $modelName; + $self['providerOptions'] = $providerOptions; + + null !== $apiKey && $self['apiKey'] = $apiKey; + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + + return $self; + } + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + public function withModelName(string $modelName): self + { + $self = clone $this; + $self['modelName'] = $modelName; + + return $self; + } + + /** + * Azure OpenAI model provider. + * + * @param 'azure' $provider + */ + public function withProvider(string $provider): self + { + $self = clone $this; + $self['provider'] = $provider; + + return $self; + } + + /** + * Azure provider-specific model configuration. + * + * @param ProviderOptions|ProviderOptionsShape $providerOptions + */ + public function withProviderOptions( + ProviderOptions|array $providerOptions + ): self { + $self = clone $this; + $self['providerOptions'] = $providerOptions; + + return $self; + } + + /** + * API key for the model provider. + */ + public function withAPIKey(string $apiKey): self + { + $self = clone $this; + $self['apiKey'] = $apiKey; + + return $self; + } + + /** + * Base URL for the model provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the model provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } +} diff --git a/src/Sessions/SessionExtractParams/Options/Model/AzureAPIKeyModelConfigObject/ProviderOptions.php b/src/Sessions/SessionExtractParams/Options/Model/AzureAPIKeyModelConfigObject/ProviderOptions.php new file mode 100644 index 0000000..f182781 --- /dev/null +++ b/src/Sessions/SessionExtractParams/Options/Model/AzureAPIKeyModelConfigObject/ProviderOptions.php @@ -0,0 +1,77 @@ + */ + use SdkModel; + + /** + * Azure OpenAI provider-specific settings. + */ + #[Required] + public Azure $azure; + + /** + * `new ProviderOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ProviderOptions::with(azure: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ProviderOptions)->withAzure(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Azure|AzureShape $azure + */ + public static function with(Azure|array $azure): self + { + $self = new self; + + $self['azure'] = $azure; + + return $self; + } + + /** + * Azure OpenAI provider-specific settings. + * + * @param Azure|AzureShape $azure + */ + public function withAzure(Azure|array $azure): self + { + $self = clone $this; + $self['azure'] = $azure; + + return $self; + } +} diff --git a/src/Sessions/SessionExtractParams/Options/Model/AzureAPIKeyModelConfigObject/ProviderOptions/Azure.php b/src/Sessions/SessionExtractParams/Options/Model/AzureAPIKeyModelConfigObject/ProviderOptions/Azure.php new file mode 100644 index 0000000..49c5469 --- /dev/null +++ b/src/Sessions/SessionExtractParams/Options/Model/AzureAPIKeyModelConfigObject/ProviderOptions/Azure.php @@ -0,0 +1,146 @@ +|null, + * resourceName?: string|null, + * useDeploymentBasedURLs?: bool|null, + * } + */ +final class Azure implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI API version. + */ + #[Optional] + public ?string $apiVersion; + + /** + * Base URL for the Azure OpenAI provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * Azure OpenAI resource name. + */ + #[Optional] + public ?string $resourceName; + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + #[Optional('useDeploymentBasedUrls')] + public ?bool $useDeploymentBasedURLs; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param array|null $headers + */ + public static function with( + ?string $apiVersion = null, + ?string $baseURL = null, + ?array $headers = null, + ?string $resourceName = null, + ?bool $useDeploymentBasedURLs = null, + ): self { + $self = new self; + + null !== $apiVersion && $self['apiVersion'] = $apiVersion; + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + null !== $resourceName && $self['resourceName'] = $resourceName; + null !== $useDeploymentBasedURLs && $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } + + /** + * Azure OpenAI API version. + */ + public function withAPIVersion(string $apiVersion): self + { + $self = clone $this; + $self['apiVersion'] = $apiVersion; + + return $self; + } + + /** + * Base URL for the Azure OpenAI provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } + + /** + * Azure OpenAI resource name. + */ + public function withResourceName(string $resourceName): self + { + $self = clone $this; + $self['resourceName'] = $resourceName; + + return $self; + } + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + public function withUseDeploymentBasedURLs( + bool $useDeploymentBasedURLs + ): self { + $self = clone $this; + $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } +} diff --git a/src/Sessions/SessionExtractParams/Options/Model/AzureEntraModelConfigObject.php b/src/Sessions/SessionExtractParams/Options/Model/AzureEntraModelConfigObject.php new file mode 100644 index 0000000..128c2b8 --- /dev/null +++ b/src/Sessions/SessionExtractParams/Options/Model/AzureEntraModelConfigObject.php @@ -0,0 +1,198 @@ +|null, + * } + */ +final class AzureEntraModelConfigObject implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI model provider. + * + * @var 'azure' $provider + */ + #[Required] + public string $provider = 'azure'; + + /** + * Azure provider authentication configuration. + */ + #[Required] + public Auth $auth; + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + #[Required] + public string $modelName; + + /** + * Azure provider-specific model configuration. + */ + #[Required] + public ProviderOptions $providerOptions; + + /** + * Base URL for the model provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the model provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * `new AzureEntraModelConfigObject()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AzureEntraModelConfigObject::with( + * auth: ..., modelName: ..., providerOptions: ... + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AzureEntraModelConfigObject) + * ->withAuth(...) + * ->withModelName(...) + * ->withProviderOptions(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Auth|AuthShape $auth + * @param ProviderOptions|ProviderOptionsShape $providerOptions + * @param array|null $headers + */ + public static function with( + Auth|array $auth, + string $modelName, + ProviderOptions|array $providerOptions, + ?string $baseURL = null, + ?array $headers = null, + ): self { + $self = new self; + + $self['auth'] = $auth; + $self['modelName'] = $modelName; + $self['providerOptions'] = $providerOptions; + + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + + return $self; + } + + /** + * Azure provider authentication configuration. + * + * @param Auth|AuthShape $auth + */ + public function withAuth(Auth|array $auth): self + { + $self = clone $this; + $self['auth'] = $auth; + + return $self; + } + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + public function withModelName(string $modelName): self + { + $self = clone $this; + $self['modelName'] = $modelName; + + return $self; + } + + /** + * Azure OpenAI model provider. + * + * @param 'azure' $provider + */ + public function withProvider(string $provider): self + { + $self = clone $this; + $self['provider'] = $provider; + + return $self; + } + + /** + * Azure provider-specific model configuration. + * + * @param ProviderOptions|ProviderOptionsShape $providerOptions + */ + public function withProviderOptions( + ProviderOptions|array $providerOptions + ): self { + $self = clone $this; + $self['providerOptions'] = $providerOptions; + + return $self; + } + + /** + * Base URL for the model provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the model provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } +} diff --git a/src/Sessions/SessionExtractParams/Options/Model/AzureEntraModelConfigObject/Auth.php b/src/Sessions/SessionExtractParams/Options/Model/AzureEntraModelConfigObject/Auth.php new file mode 100644 index 0000000..977f8e1 --- /dev/null +++ b/src/Sessions/SessionExtractParams/Options/Model/AzureEntraModelConfigObject/Auth.php @@ -0,0 +1,91 @@ + */ + use SdkModel; + + /** + * Use a Microsoft Entra ID bearer token for authentication. + * + * @var 'azureEntraId' $type + */ + #[Required] + public string $type = 'azureEntraId'; + + /** + * Microsoft Entra ID bearer token for Azure OpenAI. + */ + #[Required] + public string $token; + + /** + * `new Auth()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Auth::with(token: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Auth)->withToken(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(string $token): self + { + $self = new self; + + $self['token'] = $token; + + return $self; + } + + /** + * Microsoft Entra ID bearer token for Azure OpenAI. + */ + public function withToken(string $token): self + { + $self = clone $this; + $self['token'] = $token; + + return $self; + } + + /** + * Use a Microsoft Entra ID bearer token for authentication. + * + * @param 'azureEntraId' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } +} diff --git a/src/Sessions/SessionExtractParams/Options/Model/AzureEntraModelConfigObject/ProviderOptions.php b/src/Sessions/SessionExtractParams/Options/Model/AzureEntraModelConfigObject/ProviderOptions.php new file mode 100644 index 0000000..c244c01 --- /dev/null +++ b/src/Sessions/SessionExtractParams/Options/Model/AzureEntraModelConfigObject/ProviderOptions.php @@ -0,0 +1,77 @@ + */ + use SdkModel; + + /** + * Azure OpenAI provider-specific settings. + */ + #[Required] + public Azure $azure; + + /** + * `new ProviderOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ProviderOptions::with(azure: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ProviderOptions)->withAzure(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Azure|AzureShape $azure + */ + public static function with(Azure|array $azure): self + { + $self = new self; + + $self['azure'] = $azure; + + return $self; + } + + /** + * Azure OpenAI provider-specific settings. + * + * @param Azure|AzureShape $azure + */ + public function withAzure(Azure|array $azure): self + { + $self = clone $this; + $self['azure'] = $azure; + + return $self; + } +} diff --git a/src/Sessions/SessionExtractParams/Options/Model/AzureEntraModelConfigObject/ProviderOptions/Azure.php b/src/Sessions/SessionExtractParams/Options/Model/AzureEntraModelConfigObject/ProviderOptions/Azure.php new file mode 100644 index 0000000..ec659ce --- /dev/null +++ b/src/Sessions/SessionExtractParams/Options/Model/AzureEntraModelConfigObject/ProviderOptions/Azure.php @@ -0,0 +1,146 @@ +|null, + * resourceName?: string|null, + * useDeploymentBasedURLs?: bool|null, + * } + */ +final class Azure implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI API version. + */ + #[Optional] + public ?string $apiVersion; + + /** + * Base URL for the Azure OpenAI provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * Azure OpenAI resource name. + */ + #[Optional] + public ?string $resourceName; + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + #[Optional('useDeploymentBasedUrls')] + public ?bool $useDeploymentBasedURLs; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param array|null $headers + */ + public static function with( + ?string $apiVersion = null, + ?string $baseURL = null, + ?array $headers = null, + ?string $resourceName = null, + ?bool $useDeploymentBasedURLs = null, + ): self { + $self = new self; + + null !== $apiVersion && $self['apiVersion'] = $apiVersion; + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + null !== $resourceName && $self['resourceName'] = $resourceName; + null !== $useDeploymentBasedURLs && $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } + + /** + * Azure OpenAI API version. + */ + public function withAPIVersion(string $apiVersion): self + { + $self = clone $this; + $self['apiVersion'] = $apiVersion; + + return $self; + } + + /** + * Base URL for the Azure OpenAI provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } + + /** + * Azure OpenAI resource name. + */ + public function withResourceName(string $resourceName): self + { + $self = clone $this; + $self['resourceName'] = $resourceName; + + return $self; + } + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + public function withUseDeploymentBasedURLs( + bool $useDeploymentBasedURLs + ): self { + $self = clone $this; + $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } +} diff --git a/src/Sessions/SessionObserveParams/Options.php b/src/Sessions/SessionObserveParams/Options.php index 3b08d68..c9f27f4 100644 --- a/src/Sessions/SessionObserveParams/Options.php +++ b/src/Sessions/SessionObserveParams/Options.php @@ -7,6 +7,8 @@ use Stagehand\Core\Attributes\Optional; use Stagehand\Core\Concerns\SdkModel; use Stagehand\Core\Contracts\BaseModel; +use Stagehand\Sessions\SessionObserveParams\Options\Model\AzureAPIKeyModelConfigObject; +use Stagehand\Sessions\SessionObserveParams\Options\Model\AzureEntraModelConfigObject; use Stagehand\Sessions\SessionObserveParams\Options\Model\GenericModelConfigObject; use Stagehand\Sessions\SessionObserveParams\Options\Model\VertexModelConfigObject; use Stagehand\Sessions\SessionObserveParams\Options\Variable; @@ -44,7 +46,7 @@ final class Options implements BaseModel * @var ModelVariants|null $model */ #[Optional] - public string|VertexModelConfigObject|GenericModelConfigObject|null $model; + public string|VertexModelConfigObject|AzureEntraModelConfigObject|AzureAPIKeyModelConfigObject|GenericModelConfigObject|null $model; /** * CSS selector to scope observation to a specific element. @@ -82,7 +84,7 @@ public function __construct() */ public static function with( ?array $ignoreSelectors = null, - string|VertexModelConfigObject|array|GenericModelConfigObject|null $model = null, + string|VertexModelConfigObject|array|AzureEntraModelConfigObject|AzureAPIKeyModelConfigObject|GenericModelConfigObject|null $model = null, ?string $selector = null, ?float $timeout = null, ?array $variables = null, @@ -117,7 +119,7 @@ public function withIgnoreSelectors(array $ignoreSelectors): self * @param ModelShape $model */ public function withModel( - string|VertexModelConfigObject|array|GenericModelConfigObject $model + string|VertexModelConfigObject|array|AzureEntraModelConfigObject|AzureAPIKeyModelConfigObject|GenericModelConfigObject $model, ): self { $self = clone $this; $self['model'] = $model; diff --git a/src/Sessions/SessionObserveParams/Options/Model.php b/src/Sessions/SessionObserveParams/Options/Model.php index 2841eeb..3b26d49 100644 --- a/src/Sessions/SessionObserveParams/Options/Model.php +++ b/src/Sessions/SessionObserveParams/Options/Model.php @@ -7,6 +7,8 @@ use Stagehand\Core\Concerns\SdkUnion; use Stagehand\Core\Conversion\Contracts\Converter; use Stagehand\Core\Conversion\Contracts\ConverterSource; +use Stagehand\Sessions\SessionObserveParams\Options\Model\AzureAPIKeyModelConfigObject; +use Stagehand\Sessions\SessionObserveParams\Options\Model\AzureEntraModelConfigObject; use Stagehand\Sessions\SessionObserveParams\Options\Model\GenericModelConfigObject; use Stagehand\Sessions\SessionObserveParams\Options\Model\VertexModelConfigObject; @@ -14,10 +16,12 @@ * Model configuration object or model name string (e.g., 'openai/gpt-5-nano'). * * @phpstan-import-type VertexModelConfigObjectShape from \Stagehand\Sessions\SessionObserveParams\Options\Model\VertexModelConfigObject + * @phpstan-import-type AzureEntraModelConfigObjectShape from \Stagehand\Sessions\SessionObserveParams\Options\Model\AzureEntraModelConfigObject + * @phpstan-import-type AzureAPIKeyModelConfigObjectShape from \Stagehand\Sessions\SessionObserveParams\Options\Model\AzureAPIKeyModelConfigObject * @phpstan-import-type GenericModelConfigObjectShape from \Stagehand\Sessions\SessionObserveParams\Options\Model\GenericModelConfigObject * - * @phpstan-type ModelVariants = string|VertexModelConfigObject|GenericModelConfigObject - * @phpstan-type ModelShape = ModelVariants|VertexModelConfigObjectShape|GenericModelConfigObjectShape + * @phpstan-type ModelVariants = string|VertexModelConfigObject|AzureEntraModelConfigObject|AzureAPIKeyModelConfigObject|GenericModelConfigObject + * @phpstan-type ModelShape = ModelVariants|VertexModelConfigObjectShape|AzureEntraModelConfigObjectShape|AzureAPIKeyModelConfigObjectShape|GenericModelConfigObjectShape */ final class Model implements ConverterSource { @@ -29,7 +33,11 @@ final class Model implements ConverterSource public static function variants(): array { return [ - VertexModelConfigObject::class, GenericModelConfigObject::class, 'string', + VertexModelConfigObject::class, + AzureEntraModelConfigObject::class, + AzureAPIKeyModelConfigObject::class, + GenericModelConfigObject::class, + 'string', ]; } } diff --git a/src/Sessions/SessionObserveParams/Options/Model/AzureAPIKeyModelConfigObject.php b/src/Sessions/SessionObserveParams/Options/Model/AzureAPIKeyModelConfigObject.php new file mode 100644 index 0000000..f8622d5 --- /dev/null +++ b/src/Sessions/SessionObserveParams/Options/Model/AzureAPIKeyModelConfigObject.php @@ -0,0 +1,188 @@ +|null, + * } + */ +final class AzureAPIKeyModelConfigObject implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI model provider. + * + * @var 'azure' $provider + */ + #[Required] + public string $provider = 'azure'; + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + #[Required] + public string $modelName; + + /** + * Azure provider-specific model configuration. + */ + #[Required] + public ProviderOptions $providerOptions; + + /** + * API key for the model provider. + */ + #[Optional] + public ?string $apiKey; + + /** + * Base URL for the model provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the model provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * `new AzureAPIKeyModelConfigObject()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AzureAPIKeyModelConfigObject::with(modelName: ..., providerOptions: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AzureAPIKeyModelConfigObject)->withModelName(...)->withProviderOptions(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param ProviderOptions|ProviderOptionsShape $providerOptions + * @param array|null $headers + */ + public static function with( + string $modelName, + ProviderOptions|array $providerOptions, + ?string $apiKey = null, + ?string $baseURL = null, + ?array $headers = null, + ): self { + $self = new self; + + $self['modelName'] = $modelName; + $self['providerOptions'] = $providerOptions; + + null !== $apiKey && $self['apiKey'] = $apiKey; + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + + return $self; + } + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + public function withModelName(string $modelName): self + { + $self = clone $this; + $self['modelName'] = $modelName; + + return $self; + } + + /** + * Azure OpenAI model provider. + * + * @param 'azure' $provider + */ + public function withProvider(string $provider): self + { + $self = clone $this; + $self['provider'] = $provider; + + return $self; + } + + /** + * Azure provider-specific model configuration. + * + * @param ProviderOptions|ProviderOptionsShape $providerOptions + */ + public function withProviderOptions( + ProviderOptions|array $providerOptions + ): self { + $self = clone $this; + $self['providerOptions'] = $providerOptions; + + return $self; + } + + /** + * API key for the model provider. + */ + public function withAPIKey(string $apiKey): self + { + $self = clone $this; + $self['apiKey'] = $apiKey; + + return $self; + } + + /** + * Base URL for the model provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the model provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } +} diff --git a/src/Sessions/SessionObserveParams/Options/Model/AzureAPIKeyModelConfigObject/ProviderOptions.php b/src/Sessions/SessionObserveParams/Options/Model/AzureAPIKeyModelConfigObject/ProviderOptions.php new file mode 100644 index 0000000..4c746c5 --- /dev/null +++ b/src/Sessions/SessionObserveParams/Options/Model/AzureAPIKeyModelConfigObject/ProviderOptions.php @@ -0,0 +1,77 @@ + */ + use SdkModel; + + /** + * Azure OpenAI provider-specific settings. + */ + #[Required] + public Azure $azure; + + /** + * `new ProviderOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ProviderOptions::with(azure: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ProviderOptions)->withAzure(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Azure|AzureShape $azure + */ + public static function with(Azure|array $azure): self + { + $self = new self; + + $self['azure'] = $azure; + + return $self; + } + + /** + * Azure OpenAI provider-specific settings. + * + * @param Azure|AzureShape $azure + */ + public function withAzure(Azure|array $azure): self + { + $self = clone $this; + $self['azure'] = $azure; + + return $self; + } +} diff --git a/src/Sessions/SessionObserveParams/Options/Model/AzureAPIKeyModelConfigObject/ProviderOptions/Azure.php b/src/Sessions/SessionObserveParams/Options/Model/AzureAPIKeyModelConfigObject/ProviderOptions/Azure.php new file mode 100644 index 0000000..fe88cb0 --- /dev/null +++ b/src/Sessions/SessionObserveParams/Options/Model/AzureAPIKeyModelConfigObject/ProviderOptions/Azure.php @@ -0,0 +1,146 @@ +|null, + * resourceName?: string|null, + * useDeploymentBasedURLs?: bool|null, + * } + */ +final class Azure implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI API version. + */ + #[Optional] + public ?string $apiVersion; + + /** + * Base URL for the Azure OpenAI provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * Azure OpenAI resource name. + */ + #[Optional] + public ?string $resourceName; + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + #[Optional('useDeploymentBasedUrls')] + public ?bool $useDeploymentBasedURLs; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param array|null $headers + */ + public static function with( + ?string $apiVersion = null, + ?string $baseURL = null, + ?array $headers = null, + ?string $resourceName = null, + ?bool $useDeploymentBasedURLs = null, + ): self { + $self = new self; + + null !== $apiVersion && $self['apiVersion'] = $apiVersion; + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + null !== $resourceName && $self['resourceName'] = $resourceName; + null !== $useDeploymentBasedURLs && $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } + + /** + * Azure OpenAI API version. + */ + public function withAPIVersion(string $apiVersion): self + { + $self = clone $this; + $self['apiVersion'] = $apiVersion; + + return $self; + } + + /** + * Base URL for the Azure OpenAI provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } + + /** + * Azure OpenAI resource name. + */ + public function withResourceName(string $resourceName): self + { + $self = clone $this; + $self['resourceName'] = $resourceName; + + return $self; + } + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + public function withUseDeploymentBasedURLs( + bool $useDeploymentBasedURLs + ): self { + $self = clone $this; + $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } +} diff --git a/src/Sessions/SessionObserveParams/Options/Model/AzureEntraModelConfigObject.php b/src/Sessions/SessionObserveParams/Options/Model/AzureEntraModelConfigObject.php new file mode 100644 index 0000000..f716a1d --- /dev/null +++ b/src/Sessions/SessionObserveParams/Options/Model/AzureEntraModelConfigObject.php @@ -0,0 +1,198 @@ +|null, + * } + */ +final class AzureEntraModelConfigObject implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI model provider. + * + * @var 'azure' $provider + */ + #[Required] + public string $provider = 'azure'; + + /** + * Azure provider authentication configuration. + */ + #[Required] + public Auth $auth; + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + #[Required] + public string $modelName; + + /** + * Azure provider-specific model configuration. + */ + #[Required] + public ProviderOptions $providerOptions; + + /** + * Base URL for the model provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the model provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * `new AzureEntraModelConfigObject()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AzureEntraModelConfigObject::with( + * auth: ..., modelName: ..., providerOptions: ... + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AzureEntraModelConfigObject) + * ->withAuth(...) + * ->withModelName(...) + * ->withProviderOptions(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Auth|AuthShape $auth + * @param ProviderOptions|ProviderOptionsShape $providerOptions + * @param array|null $headers + */ + public static function with( + Auth|array $auth, + string $modelName, + ProviderOptions|array $providerOptions, + ?string $baseURL = null, + ?array $headers = null, + ): self { + $self = new self; + + $self['auth'] = $auth; + $self['modelName'] = $modelName; + $self['providerOptions'] = $providerOptions; + + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + + return $self; + } + + /** + * Azure provider authentication configuration. + * + * @param Auth|AuthShape $auth + */ + public function withAuth(Auth|array $auth): self + { + $self = clone $this; + $self['auth'] = $auth; + + return $self; + } + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + public function withModelName(string $modelName): self + { + $self = clone $this; + $self['modelName'] = $modelName; + + return $self; + } + + /** + * Azure OpenAI model provider. + * + * @param 'azure' $provider + */ + public function withProvider(string $provider): self + { + $self = clone $this; + $self['provider'] = $provider; + + return $self; + } + + /** + * Azure provider-specific model configuration. + * + * @param ProviderOptions|ProviderOptionsShape $providerOptions + */ + public function withProviderOptions( + ProviderOptions|array $providerOptions + ): self { + $self = clone $this; + $self['providerOptions'] = $providerOptions; + + return $self; + } + + /** + * Base URL for the model provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the model provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } +} diff --git a/src/Sessions/SessionObserveParams/Options/Model/AzureEntraModelConfigObject/Auth.php b/src/Sessions/SessionObserveParams/Options/Model/AzureEntraModelConfigObject/Auth.php new file mode 100644 index 0000000..797484b --- /dev/null +++ b/src/Sessions/SessionObserveParams/Options/Model/AzureEntraModelConfigObject/Auth.php @@ -0,0 +1,91 @@ + */ + use SdkModel; + + /** + * Use a Microsoft Entra ID bearer token for authentication. + * + * @var 'azureEntraId' $type + */ + #[Required] + public string $type = 'azureEntraId'; + + /** + * Microsoft Entra ID bearer token for Azure OpenAI. + */ + #[Required] + public string $token; + + /** + * `new Auth()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Auth::with(token: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Auth)->withToken(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(string $token): self + { + $self = new self; + + $self['token'] = $token; + + return $self; + } + + /** + * Microsoft Entra ID bearer token for Azure OpenAI. + */ + public function withToken(string $token): self + { + $self = clone $this; + $self['token'] = $token; + + return $self; + } + + /** + * Use a Microsoft Entra ID bearer token for authentication. + * + * @param 'azureEntraId' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } +} diff --git a/src/Sessions/SessionObserveParams/Options/Model/AzureEntraModelConfigObject/ProviderOptions.php b/src/Sessions/SessionObserveParams/Options/Model/AzureEntraModelConfigObject/ProviderOptions.php new file mode 100644 index 0000000..9e25ab7 --- /dev/null +++ b/src/Sessions/SessionObserveParams/Options/Model/AzureEntraModelConfigObject/ProviderOptions.php @@ -0,0 +1,77 @@ + */ + use SdkModel; + + /** + * Azure OpenAI provider-specific settings. + */ + #[Required] + public Azure $azure; + + /** + * `new ProviderOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ProviderOptions::with(azure: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ProviderOptions)->withAzure(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Azure|AzureShape $azure + */ + public static function with(Azure|array $azure): self + { + $self = new self; + + $self['azure'] = $azure; + + return $self; + } + + /** + * Azure OpenAI provider-specific settings. + * + * @param Azure|AzureShape $azure + */ + public function withAzure(Azure|array $azure): self + { + $self = clone $this; + $self['azure'] = $azure; + + return $self; + } +} diff --git a/src/Sessions/SessionObserveParams/Options/Model/AzureEntraModelConfigObject/ProviderOptions/Azure.php b/src/Sessions/SessionObserveParams/Options/Model/AzureEntraModelConfigObject/ProviderOptions/Azure.php new file mode 100644 index 0000000..9491502 --- /dev/null +++ b/src/Sessions/SessionObserveParams/Options/Model/AzureEntraModelConfigObject/ProviderOptions/Azure.php @@ -0,0 +1,146 @@ +|null, + * resourceName?: string|null, + * useDeploymentBasedURLs?: bool|null, + * } + */ +final class Azure implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Azure OpenAI API version. + */ + #[Optional] + public ?string $apiVersion; + + /** + * Base URL for the Azure OpenAI provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * Azure OpenAI resource name. + */ + #[Optional] + public ?string $resourceName; + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + #[Optional('useDeploymentBasedUrls')] + public ?bool $useDeploymentBasedURLs; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param array|null $headers + */ + public static function with( + ?string $apiVersion = null, + ?string $baseURL = null, + ?array $headers = null, + ?string $resourceName = null, + ?bool $useDeploymentBasedURLs = null, + ): self { + $self = new self; + + null !== $apiVersion && $self['apiVersion'] = $apiVersion; + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + null !== $resourceName && $self['resourceName'] = $resourceName; + null !== $useDeploymentBasedURLs && $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } + + /** + * Azure OpenAI API version. + */ + public function withAPIVersion(string $apiVersion): self + { + $self = clone $this; + $self['apiVersion'] = $apiVersion; + + return $self; + } + + /** + * Base URL for the Azure OpenAI provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers sent with every request to the Azure OpenAI provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } + + /** + * Azure OpenAI resource name. + */ + public function withResourceName(string $resourceName): self + { + $self = clone $this; + $self['resourceName'] = $resourceName; + + return $self; + } + + /** + * Whether to use deployment-based Azure OpenAI URLs. + */ + public function withUseDeploymentBasedURLs( + bool $useDeploymentBasedURLs + ): self { + $self = clone $this; + $self['useDeploymentBasedURLs'] = $useDeploymentBasedURLs; + + return $self; + } +} diff --git a/src/Version.php b/src/Version.php index b10e37c..e7c552b 100644 --- a/src/Version.php +++ b/src/Version.php @@ -5,5 +5,5 @@ namespace Stagehand; // x-release-please-start-version -const VERSION = '3.21.0'; +const VERSION = '3.22.0'; // x-release-please-end