diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index b11acac..b5e2925 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -18,7 +18,7 @@ jobs:
lint:
timeout-minutes: 15
name: lint
- runs-on: ${{ github.repository == 'stainless-sdks/stagehand-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
+ runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
steps:
@@ -45,7 +45,7 @@ jobs:
permissions:
contents: read
id-token: write
- runs-on: ${{ github.repository == 'stainless-sdks/stagehand-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
+ runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
steps:
@@ -88,7 +88,7 @@ jobs:
test:
timeout-minutes: 15
name: test
- runs-on: ${{ github.repository == 'stainless-sdks/stagehand-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
+ runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
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..7b1f04d 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-64b47a6dd07208d708130e739a272f7d37d4e42494a7c8e566ef66007f8ff25f.yml
+openapi_spec_hash: 4cdfcfed592c8631fbab9117bf45bb67
config_hash: 1fb12ae9b478488bc1e56bfbdc210b01
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1677dfa..bbf76e8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,15 @@
# Changelog
+## 3.22.0 (2026-07-21)
+
+Full Changelog: [v3.21.0...v3.22.0](https://github.com/browserbase/stagehand-java/compare/v3.21.0...v3.22.0)
+
+### Features
+
+* [STG-2090] Add Azure Entra model auth support ([3f3c1fa](https://github.com/browserbase/stagehand-java/commit/3f3c1fa68b001bf721eceefe6f34ad4384662294))
+* **server-v3:** expose OpenAI endpoint format ([b8aaaba](https://github.com/browserbase/stagehand-java/commit/b8aaabae25124a1e0d3fcd482b92ed887c8f0cea))
+* **stlc:** configurable CI runner and private-production-repo support in workflow templates ([2bf4f25](https://github.com/browserbase/stagehand-java/commit/2bf4f25bac7de5052a759afc0236fdea8774302c))
+
## 3.21.0 (2026-05-29)
Full Changelog: [v3.20.0...v3.21.0](https://github.com/browserbase/stagehand-java/compare/v3.20.0...v3.21.0)
diff --git a/README.md b/README.md
index b18062f..915df1f 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,8 @@
-[](https://central.sonatype.com/artifact/com.browserbase.api/stagehand-java/3.21.0)
-[](https://javadoc.io/doc/com.browserbase.api/stagehand-java/3.21.0)
+[](https://central.sonatype.com/artifact/com.browserbase.api/stagehand-java/3.22.0)
+[](https://javadoc.io/doc/com.browserbase.api/stagehand-java/3.22.0)
@@ -85,7 +85,7 @@ Most existing browser automation tools either require you to write low-level cod
### Gradle
```kotlin
-implementation("com.browserbase.api:stagehand-java:3.21.0")
+implementation("com.browserbase.api:stagehand-java:3.22.0")
```
### Maven
@@ -94,7 +94,7 @@ implementation("com.browserbase.api:stagehand-java:3.21.0")
com.browserbase.api
stagehand-java
- 3.21.0
+ 3.22.0
```
diff --git a/build.gradle.kts b/build.gradle.kts
index 2f55137..f75a874 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -8,7 +8,7 @@ repositories {
allprojects {
group = "com.browserbase.api"
- version = "3.21.0" // x-release-please-version
+ version = "3.22.0" // x-release-please-version
}
subprojects {
diff --git a/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/ModelConfig.kt b/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/ModelConfig.kt
index b6cc034..c120fc8 100644
--- a/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/ModelConfig.kt
+++ b/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/ModelConfig.kt
@@ -35,6 +35,8 @@ import kotlin.jvm.optionals.getOrNull
class ModelConfig
private constructor(
private val vertexModelConfigObject: VertexModelConfigObject? = null,
+ private val azureEntraModelConfigObject: AzureEntraModelConfigObject? = null,
+ private val azureApiKeyModelConfigObject: AzureApiKeyModelConfigObject? = null,
private val genericModelConfigObject: GenericModelConfigObject? = null,
private val _json: JsonValue? = null,
) {
@@ -42,16 +44,32 @@ private constructor(
fun vertexModelConfigObject(): Optional =
Optional.ofNullable(vertexModelConfigObject)
+ fun azureEntraModelConfigObject(): Optional =
+ Optional.ofNullable(azureEntraModelConfigObject)
+
+ fun azureApiKeyModelConfigObject(): Optional =
+ Optional.ofNullable(azureApiKeyModelConfigObject)
+
fun genericModelConfigObject(): Optional =
Optional.ofNullable(genericModelConfigObject)
fun isVertexModelConfigObject(): Boolean = vertexModelConfigObject != null
+ fun isAzureEntraModelConfigObject(): Boolean = azureEntraModelConfigObject != null
+
+ fun isAzureApiKeyModelConfigObject(): Boolean = azureApiKeyModelConfigObject != null
+
fun isGenericModelConfigObject(): Boolean = genericModelConfigObject != null
fun asVertexModelConfigObject(): VertexModelConfigObject =
vertexModelConfigObject.getOrThrow("vertexModelConfigObject")
+ fun asAzureEntraModelConfigObject(): AzureEntraModelConfigObject =
+ azureEntraModelConfigObject.getOrThrow("azureEntraModelConfigObject")
+
+ fun asAzureApiKeyModelConfigObject(): AzureApiKeyModelConfigObject =
+ azureApiKeyModelConfigObject.getOrThrow("azureApiKeyModelConfigObject")
+
fun asGenericModelConfigObject(): GenericModelConfigObject =
genericModelConfigObject.getOrThrow("genericModelConfigObject")
@@ -90,6 +108,10 @@ private constructor(
when {
vertexModelConfigObject != null ->
visitor.visitVertexModelConfigObject(vertexModelConfigObject)
+ azureEntraModelConfigObject != null ->
+ visitor.visitAzureEntraModelConfigObject(azureEntraModelConfigObject)
+ azureApiKeyModelConfigObject != null ->
+ visitor.visitAzureApiKeyModelConfigObject(azureApiKeyModelConfigObject)
genericModelConfigObject != null ->
visitor.visitGenericModelConfigObject(genericModelConfigObject)
else -> visitor.unknown(_json)
@@ -118,6 +140,18 @@ private constructor(
vertexModelConfigObject.validate()
}
+ override fun visitAzureEntraModelConfigObject(
+ azureEntraModelConfigObject: AzureEntraModelConfigObject
+ ) {
+ azureEntraModelConfigObject.validate()
+ }
+
+ override fun visitAzureApiKeyModelConfigObject(
+ azureApiKeyModelConfigObject: AzureApiKeyModelConfigObject
+ ) {
+ azureApiKeyModelConfigObject.validate()
+ }
+
override fun visitGenericModelConfigObject(
genericModelConfigObject: GenericModelConfigObject
) {
@@ -149,6 +183,14 @@ private constructor(
vertexModelConfigObject: VertexModelConfigObject
) = vertexModelConfigObject.validity()
+ override fun visitAzureEntraModelConfigObject(
+ azureEntraModelConfigObject: AzureEntraModelConfigObject
+ ) = azureEntraModelConfigObject.validity()
+
+ override fun visitAzureApiKeyModelConfigObject(
+ azureApiKeyModelConfigObject: AzureApiKeyModelConfigObject
+ ) = azureApiKeyModelConfigObject.validity()
+
override fun visitGenericModelConfigObject(
genericModelConfigObject: GenericModelConfigObject
) = genericModelConfigObject.validity()
@@ -164,15 +206,27 @@ private constructor(
return other is ModelConfig &&
vertexModelConfigObject == other.vertexModelConfigObject &&
+ azureEntraModelConfigObject == other.azureEntraModelConfigObject &&
+ azureApiKeyModelConfigObject == other.azureApiKeyModelConfigObject &&
genericModelConfigObject == other.genericModelConfigObject
}
- override fun hashCode(): Int = Objects.hash(vertexModelConfigObject, genericModelConfigObject)
+ override fun hashCode(): Int =
+ Objects.hash(
+ vertexModelConfigObject,
+ azureEntraModelConfigObject,
+ azureApiKeyModelConfigObject,
+ genericModelConfigObject,
+ )
override fun toString(): String =
when {
vertexModelConfigObject != null ->
"ModelConfig{vertexModelConfigObject=$vertexModelConfigObject}"
+ azureEntraModelConfigObject != null ->
+ "ModelConfig{azureEntraModelConfigObject=$azureEntraModelConfigObject}"
+ azureApiKeyModelConfigObject != null ->
+ "ModelConfig{azureApiKeyModelConfigObject=$azureApiKeyModelConfigObject}"
genericModelConfigObject != null ->
"ModelConfig{genericModelConfigObject=$genericModelConfigObject}"
_json != null -> "ModelConfig{_unknown=$_json}"
@@ -185,6 +239,16 @@ private constructor(
fun ofVertexModelConfigObject(vertexModelConfigObject: VertexModelConfigObject) =
ModelConfig(vertexModelConfigObject = vertexModelConfigObject)
+ @JvmStatic
+ fun ofAzureEntraModelConfigObject(
+ azureEntraModelConfigObject: AzureEntraModelConfigObject
+ ) = ModelConfig(azureEntraModelConfigObject = azureEntraModelConfigObject)
+
+ @JvmStatic
+ fun ofAzureApiKeyModelConfigObject(
+ azureApiKeyModelConfigObject: AzureApiKeyModelConfigObject
+ ) = ModelConfig(azureApiKeyModelConfigObject = azureApiKeyModelConfigObject)
+
@JvmStatic
fun ofGenericModelConfigObject(genericModelConfigObject: GenericModelConfigObject) =
ModelConfig(genericModelConfigObject = genericModelConfigObject)
@@ -197,6 +261,14 @@ private constructor(
fun visitVertexModelConfigObject(vertexModelConfigObject: VertexModelConfigObject): T
+ fun visitAzureEntraModelConfigObject(
+ azureEntraModelConfigObject: AzureEntraModelConfigObject
+ ): T
+
+ fun visitAzureApiKeyModelConfigObject(
+ azureApiKeyModelConfigObject: AzureApiKeyModelConfigObject
+ ): T
+
fun visitGenericModelConfigObject(genericModelConfigObject: GenericModelConfigObject): T
/**
@@ -223,6 +295,12 @@ private constructor(
tryDeserialize(node, jacksonTypeRef())?.let {
ModelConfig(vertexModelConfigObject = it, _json = json)
},
+ tryDeserialize(node, jacksonTypeRef())?.let {
+ ModelConfig(azureEntraModelConfigObject = it, _json = json)
+ },
+ tryDeserialize(node, jacksonTypeRef())?.let {
+ ModelConfig(azureApiKeyModelConfigObject = it, _json = json)
+ },
tryDeserialize(node, jacksonTypeRef())?.let {
ModelConfig(genericModelConfigObject = it, _json = json)
},
@@ -252,6 +330,10 @@ private constructor(
when {
value.vertexModelConfigObject != null ->
generator.writeObject(value.vertexModelConfigObject)
+ value.azureEntraModelConfigObject != null ->
+ generator.writeObject(value.azureEntraModelConfigObject)
+ value.azureApiKeyModelConfigObject != null ->
+ generator.writeObject(value.azureApiKeyModelConfigObject)
value.genericModelConfigObject != null ->
generator.writeObject(value.genericModelConfigObject)
value._json != null -> generator.writeObject(value._json)
@@ -2689,29 +2771,39 @@ private constructor(
"VertexModelConfigObject{auth=$auth, modelName=$modelName, provider=$provider, providerOptions=$providerOptions, apiKey=$apiKey, baseUrl=$baseUrl, headers=$headers, additionalProperties=$additionalProperties}"
}
- class GenericModelConfigObject
+ class AzureEntraModelConfigObject
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
private constructor(
+ private val auth: JsonField,
private val modelName: JsonField,
- private val apiKey: JsonField,
+ private val provider: JsonValue,
+ private val providerOptions: JsonField,
private val baseUrl: JsonField,
private val headers: JsonField,
- private val provider: JsonField,
private val additionalProperties: MutableMap,
) {
@JsonCreator
private constructor(
+ @JsonProperty("auth") @ExcludeMissing auth: JsonField = JsonMissing.of(),
@JsonProperty("modelName")
@ExcludeMissing
modelName: JsonField = JsonMissing.of(),
- @JsonProperty("apiKey") @ExcludeMissing apiKey: JsonField = JsonMissing.of(),
+ @JsonProperty("provider") @ExcludeMissing provider: JsonValue = JsonMissing.of(),
+ @JsonProperty("providerOptions")
+ @ExcludeMissing
+ providerOptions: JsonField = JsonMissing.of(),
@JsonProperty("baseURL") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(),
@JsonProperty("headers") @ExcludeMissing headers: JsonField = JsonMissing.of(),
- @JsonProperty("provider")
- @ExcludeMissing
- provider: JsonField = JsonMissing.of(),
- ) : this(modelName, apiKey, baseUrl, headers, provider, mutableMapOf())
+ ) : this(auth, modelName, provider, providerOptions, baseUrl, headers, mutableMapOf())
+
+ /**
+ * Azure provider authentication configuration
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun auth(): Auth = auth.getRequired("auth")
/**
* Model name string with provider prefix (e.g., 'openai/gpt-5-nano')
@@ -2722,12 +2814,25 @@ private constructor(
fun modelName(): String = modelName.getRequired("modelName")
/**
- * API key for the model provider
+ * Azure OpenAI model provider
*
- * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if
- * the server responded with an unexpected value).
+ * Expected to always return the following:
+ * ```java
+ * JsonValue.from("azure")
+ * ```
+ *
+ * However, this method can be useful for debugging and logging (e.g. if the server
+ * responded with an unexpected value).
*/
- fun apiKey(): Optional = apiKey.getOptional("apiKey")
+ @JsonProperty("provider") @ExcludeMissing fun _provider(): JsonValue = provider
+
+ /**
+ * Azure provider-specific model configuration
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun providerOptions(): ProviderOptions = providerOptions.getRequired("providerOptions")
/**
* Base URL for the model provider
@@ -2746,12 +2851,11 @@ private constructor(
fun headers(): Optional = headers.getOptional("headers")
/**
- * AI provider for the model (or provide a baseURL endpoint instead)
+ * Returns the raw JSON value of [auth].
*
- * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if
- * the server responded with an unexpected value).
+ * Unlike [auth], this method doesn't throw if the JSON field has an unexpected type.
*/
- fun provider(): Optional = provider.getOptional("provider")
+ @JsonProperty("auth") @ExcludeMissing fun _auth(): JsonField = auth
/**
* Returns the raw JSON value of [modelName].
@@ -2761,11 +2865,14 @@ private constructor(
@JsonProperty("modelName") @ExcludeMissing fun _modelName(): JsonField = modelName
/**
- * Returns the raw JSON value of [apiKey].
+ * Returns the raw JSON value of [providerOptions].
*
- * Unlike [apiKey], this method doesn't throw if the JSON field has an unexpected type.
+ * Unlike [providerOptions], this method doesn't throw if the JSON field has an unexpected
+ * type.
*/
- @JsonProperty("apiKey") @ExcludeMissing fun _apiKey(): JsonField = apiKey
+ @JsonProperty("providerOptions")
+ @ExcludeMissing
+ fun _providerOptions(): JsonField = providerOptions
/**
* Returns the raw JSON value of [baseUrl].
@@ -2781,13 +2888,6 @@ private constructor(
*/
@JsonProperty("headers") @ExcludeMissing fun _headers(): JsonField = headers
- /**
- * Returns the raw JSON value of [provider].
- *
- * Unlike [provider], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("provider") @ExcludeMissing fun _provider(): JsonField = provider
-
@JsonAnySetter
private fun putAdditionalProperty(key: String, value: JsonValue) {
additionalProperties.put(key, value)
@@ -2803,36 +2903,54 @@ private constructor(
companion object {
/**
- * Returns a mutable builder for constructing an instance of [GenericModelConfigObject].
+ * Returns a mutable builder for constructing an instance of
+ * [AzureEntraModelConfigObject].
*
* The following fields are required:
* ```java
+ * .auth()
* .modelName()
+ * .providerOptions()
* ```
*/
@JvmStatic fun builder() = Builder()
}
- /** A builder for [GenericModelConfigObject]. */
+ /** A builder for [AzureEntraModelConfigObject]. */
class Builder internal constructor() {
+ private var auth: JsonField? = null
private var modelName: JsonField? = null
- private var apiKey: JsonField = JsonMissing.of()
+ private var provider: JsonValue = JsonValue.from("azure")
+ private var providerOptions: JsonField? = null
private var baseUrl: JsonField = JsonMissing.of()
private var headers: JsonField = JsonMissing.of()
- private var provider: JsonField = JsonMissing.of()
private var additionalProperties: MutableMap = mutableMapOf()
@JvmSynthetic
- internal fun from(genericModelConfigObject: GenericModelConfigObject) = apply {
- modelName = genericModelConfigObject.modelName
- apiKey = genericModelConfigObject.apiKey
- baseUrl = genericModelConfigObject.baseUrl
- headers = genericModelConfigObject.headers
- provider = genericModelConfigObject.provider
- additionalProperties = genericModelConfigObject.additionalProperties.toMutableMap()
+ internal fun from(azureEntraModelConfigObject: AzureEntraModelConfigObject) = apply {
+ auth = azureEntraModelConfigObject.auth
+ modelName = azureEntraModelConfigObject.modelName
+ provider = azureEntraModelConfigObject.provider
+ providerOptions = azureEntraModelConfigObject.providerOptions
+ baseUrl = azureEntraModelConfigObject.baseUrl
+ headers = azureEntraModelConfigObject.headers
+ additionalProperties =
+ azureEntraModelConfigObject.additionalProperties.toMutableMap()
}
+ /** Azure provider authentication configuration */
+ fun auth(auth: Auth) = auth(JsonField.of(auth))
+
+ /**
+ * Sets [Builder.auth] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.auth] with a well-typed [Auth] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported
+ * value.
+ */
+ fun auth(auth: JsonField) = apply { this.auth = auth }
+
/** Model name string with provider prefix (e.g., 'openai/gpt-5-nano') */
fun modelName(modelName: String) = modelName(JsonField.of(modelName))
@@ -2845,17 +2963,34 @@ private constructor(
*/
fun modelName(modelName: JsonField) = apply { this.modelName = modelName }
- /** API key for the model provider */
- fun apiKey(apiKey: String) = apiKey(JsonField.of(apiKey))
-
/**
- * Sets [Builder.apiKey] to an arbitrary JSON value.
+ * Sets the field to an arbitrary JSON value.
+ *
+ * It is usually unnecessary to call this method because the field defaults to the
+ * following:
+ * ```java
+ * JsonValue.from("azure")
+ * ```
*
- * You should usually call [Builder.apiKey] with a well-typed [String] value instead.
* This method is primarily for setting the field to an undocumented or not yet
* supported value.
*/
- fun apiKey(apiKey: JsonField) = apply { this.apiKey = apiKey }
+ fun provider(provider: JsonValue) = apply { this.provider = provider }
+
+ /** Azure provider-specific model configuration */
+ fun providerOptions(providerOptions: ProviderOptions) =
+ providerOptions(JsonField.of(providerOptions))
+
+ /**
+ * Sets [Builder.providerOptions] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.providerOptions] with a well-typed [ProviderOptions]
+ * value instead. This method is primarily for setting the field to an undocumented or
+ * not yet supported value.
+ */
+ fun providerOptions(providerOptions: JsonField) = apply {
+ this.providerOptions = providerOptions
+ }
/** Base URL for the model provider */
fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl))
@@ -2881,18 +3016,6 @@ private constructor(
*/
fun headers(headers: JsonField) = apply { this.headers = headers }
- /** AI provider for the model (or provide a baseURL endpoint instead) */
- fun provider(provider: Provider) = provider(JsonField.of(provider))
-
- /**
- * Sets [Builder.provider] to an arbitrary JSON value.
- *
- * You should usually call [Builder.provider] with a well-typed [Provider] value
- * instead. This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun provider(provider: JsonField) = apply { this.provider = provider }
-
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
@@ -2913,24 +3036,27 @@ private constructor(
}
/**
- * Returns an immutable instance of [GenericModelConfigObject].
+ * Returns an immutable instance of [AzureEntraModelConfigObject].
*
* Further updates to this [Builder] will not mutate the returned instance.
*
* The following fields are required:
* ```java
+ * .auth()
* .modelName()
+ * .providerOptions()
* ```
*
* @throws IllegalStateException if any required field is unset.
*/
- fun build(): GenericModelConfigObject =
- GenericModelConfigObject(
+ fun build(): AzureEntraModelConfigObject =
+ AzureEntraModelConfigObject(
+ checkRequired("auth", auth),
checkRequired("modelName", modelName),
- apiKey,
+ provider,
+ checkRequired("providerOptions", providerOptions),
baseUrl,
headers,
- provider,
additionalProperties.toMutableMap(),
)
}
@@ -2946,16 +3072,21 @@ private constructor(
* @throws StagehandInvalidDataException if any value type in this object doesn't match its
* expected type.
*/
- fun validate(): GenericModelConfigObject = apply {
+ fun validate(): AzureEntraModelConfigObject = apply {
if (validated) {
return@apply
}
+ auth().validate()
modelName()
- apiKey()
+ _provider().let {
+ if (it != JsonValue.from("azure")) {
+ throw StagehandInvalidDataException("'provider' is invalid, received $it")
+ }
+ }
+ providerOptions().validate()
baseUrl()
headers().ifPresent { it.validate() }
- provider().ifPresent { it.validate() }
validated = true
}
@@ -2975,40 +3106,2514 @@ private constructor(
*/
@JvmSynthetic
internal fun validity(): Int =
- (if (modelName.asKnown().isPresent) 1 else 0) +
- (if (apiKey.asKnown().isPresent) 1 else 0) +
+ (auth.asKnown().getOrNull()?.validity() ?: 0) +
+ (if (modelName.asKnown().isPresent) 1 else 0) +
+ provider.let { if (it == JsonValue.from("azure")) 1 else 0 } +
+ (providerOptions.asKnown().getOrNull()?.validity() ?: 0) +
(if (baseUrl.asKnown().isPresent) 1 else 0) +
- (headers.asKnown().getOrNull()?.validity() ?: 0) +
- (provider.asKnown().getOrNull()?.validity() ?: 0)
+ (headers.asKnown().getOrNull()?.validity() ?: 0)
- /** Custom headers sent with every request to the model provider */
- class Headers
- @JsonCreator
+ /** Azure provider authentication configuration */
+ class Auth
+ @JsonCreator(mode = JsonCreator.Mode.DISABLED)
private constructor(
- @com.fasterxml.jackson.annotation.JsonValue
- private val additionalProperties: Map
+ private val token: JsonField,
+ private val type: JsonValue,
+ private val additionalProperties: MutableMap,
) {
+ @JsonCreator
+ private constructor(
+ @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(),
+ @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(),
+ ) : this(token, type, mutableMapOf())
+
+ /**
+ * Microsoft Entra ID bearer token for Azure OpenAI
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected
+ * value).
+ */
+ fun token(): String = token.getRequired("token")
+
+ /**
+ * Use a Microsoft Entra ID bearer token for authentication
+ *
+ * Expected to always return the following:
+ * ```java
+ * JsonValue.from("azureEntraId")
+ * ```
+ *
+ * However, this method can be useful for debugging and logging (e.g. if the server
+ * responded with an unexpected value).
+ */
+ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type
+
+ /**
+ * Returns the raw JSON value of [token].
+ *
+ * Unlike [token], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
@JsonAnyGetter
@ExcludeMissing
- fun _additionalProperties(): Map = additionalProperties
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
fun toBuilder() = Builder().from(this)
companion object {
- /** Returns a mutable builder for constructing an instance of [Headers]. */
+ /**
+ * Returns a mutable builder for constructing an instance of [Auth].
+ *
+ * The following fields are required:
+ * ```java
+ * .token()
+ * ```
+ */
@JvmStatic fun builder() = Builder()
}
- /** A builder for [Headers]. */
+ /** A builder for [Auth]. */
class Builder internal constructor() {
+ private var token: JsonField? = null
+ private var type: JsonValue = JsonValue.from("azureEntraId")
private var additionalProperties: MutableMap = mutableMapOf()
@JvmSynthetic
- internal fun from(headers: Headers) = apply {
- additionalProperties = headers.additionalProperties.toMutableMap()
+ internal fun from(auth: Auth) = apply {
+ token = auth.token
+ type = auth.type
+ additionalProperties = auth.additionalProperties.toMutableMap()
+ }
+
+ /** Microsoft Entra ID bearer token for Azure OpenAI */
+ fun token(token: String) = token(JsonField.of(token))
+
+ /**
+ * Sets [Builder.token] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.token] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun token(token: JsonField) = apply { this.token = token }
+
+ /**
+ * Sets the field to an arbitrary JSON value.
+ *
+ * It is usually unnecessary to call this method because the field defaults to the
+ * following:
+ * ```java
+ * JsonValue.from("azureEntraId")
+ * ```
+ *
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun type(type: JsonValue) = apply { this.type = type }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) =
+ apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply {
+ additionalProperties.remove(key)
+ }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [Auth].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .token()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): Auth =
+ Auth(checkRequired("token", token), type, additionalProperties.toMutableMap())
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing
+ * fields.
+ *
+ * @throws StagehandInvalidDataException if any value type in this object doesn't match
+ * its expected type.
+ */
+ fun validate(): Auth = apply {
+ if (validated) {
+ return@apply
+ }
+
+ token()
+ _type().let {
+ if (it != JsonValue.from("azureEntraId")) {
+ throw StagehandInvalidDataException("'type' is invalid, received $it")
+ }
+ }
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: StagehandInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic
+ internal fun validity(): Int =
+ (if (token.asKnown().isPresent) 1 else 0) +
+ type.let { if (it == JsonValue.from("azureEntraId")) 1 else 0 }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Auth &&
+ token == other.token &&
+ type == other.type &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(token, type, additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "Auth{token=$token, type=$type, additionalProperties=$additionalProperties}"
+ }
+
+ /** Azure provider-specific model configuration */
+ class ProviderOptions
+ @JsonCreator(mode = JsonCreator.Mode.DISABLED)
+ private constructor(
+ private val azure: JsonField,
+ private val additionalProperties: MutableMap,
+ ) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("azure") @ExcludeMissing azure: JsonField = JsonMissing.of()
+ ) : this(azure, mutableMapOf())
+
+ /**
+ * Azure OpenAI provider-specific settings
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected
+ * value).
+ */
+ fun azure(): Azure = azure.getRequired("azure")
+
+ /**
+ * Returns the raw JSON value of [azure].
+ *
+ * Unlike [azure], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("azure") @ExcludeMissing fun _azure(): JsonField = azure
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of [ProviderOptions].
+ *
+ * The following fields are required:
+ * ```java
+ * .azure()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [ProviderOptions]. */
+ class Builder internal constructor() {
+
+ private var azure: JsonField? = null
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(providerOptions: ProviderOptions) = apply {
+ azure = providerOptions.azure
+ additionalProperties = providerOptions.additionalProperties.toMutableMap()
+ }
+
+ /** Azure OpenAI provider-specific settings */
+ fun azure(azure: Azure) = azure(JsonField.of(azure))
+
+ /**
+ * Sets [Builder.azure] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.azure] with a well-typed [Azure] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun azure(azure: JsonField) = apply { this.azure = azure }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) =
+ apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply {
+ additionalProperties.remove(key)
+ }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [ProviderOptions].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .azure()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): ProviderOptions =
+ ProviderOptions(
+ checkRequired("azure", azure),
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing
+ * fields.
+ *
+ * @throws StagehandInvalidDataException if any value type in this object doesn't match
+ * its expected type.
+ */
+ fun validate(): ProviderOptions = apply {
+ if (validated) {
+ return@apply
+ }
+
+ azure().validate()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: StagehandInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic
+ internal fun validity(): Int = (azure.asKnown().getOrNull()?.validity() ?: 0)
+
+ /** Azure OpenAI provider-specific settings */
+ class Azure
+ @JsonCreator(mode = JsonCreator.Mode.DISABLED)
+ private constructor(
+ private val apiVersion: JsonField,
+ private val baseUrl: JsonField,
+ private val headers: JsonField,
+ private val resourceName: JsonField,
+ private val useDeploymentBasedUrls: JsonField,
+ private val additionalProperties: MutableMap,
+ ) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("apiVersion")
+ @ExcludeMissing
+ apiVersion: JsonField = JsonMissing.of(),
+ @JsonProperty("baseURL")
+ @ExcludeMissing
+ baseUrl: JsonField = JsonMissing.of(),
+ @JsonProperty("headers")
+ @ExcludeMissing
+ headers: JsonField = JsonMissing.of(),
+ @JsonProperty("resourceName")
+ @ExcludeMissing
+ resourceName: JsonField = JsonMissing.of(),
+ @JsonProperty("useDeploymentBasedUrls")
+ @ExcludeMissing
+ useDeploymentBasedUrls: JsonField = JsonMissing.of(),
+ ) : this(
+ apiVersion,
+ baseUrl,
+ headers,
+ resourceName,
+ useDeploymentBasedUrls,
+ mutableMapOf(),
+ )
+
+ /**
+ * Azure OpenAI API version
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun apiVersion(): Optional = apiVersion.getOptional("apiVersion")
+
+ /**
+ * Base URL for the Azure OpenAI provider
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun baseUrl(): Optional = baseUrl.getOptional("baseURL")
+
+ /**
+ * Custom headers sent with every request to the Azure OpenAI provider
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun headers(): Optional = headers.getOptional("headers")
+
+ /**
+ * Azure OpenAI resource name
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun resourceName(): Optional = resourceName.getOptional("resourceName")
+
+ /**
+ * Whether to use deployment-based Azure OpenAI URLs
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun useDeploymentBasedUrls(): Optional =
+ useDeploymentBasedUrls.getOptional("useDeploymentBasedUrls")
+
+ /**
+ * Returns the raw JSON value of [apiVersion].
+ *
+ * Unlike [apiVersion], this method doesn't throw if the JSON field has an
+ * unexpected type.
+ */
+ @JsonProperty("apiVersion")
+ @ExcludeMissing
+ fun _apiVersion(): JsonField = apiVersion
+
+ /**
+ * Returns the raw JSON value of [baseUrl].
+ *
+ * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("baseURL") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl
+
+ /**
+ * Returns the raw JSON value of [headers].
+ *
+ * Unlike [headers], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("headers")
+ @ExcludeMissing
+ fun _headers(): JsonField = headers
+
+ /**
+ * Returns the raw JSON value of [resourceName].
+ *
+ * Unlike [resourceName], this method doesn't throw if the JSON field has an
+ * unexpected type.
+ */
+ @JsonProperty("resourceName")
+ @ExcludeMissing
+ fun _resourceName(): JsonField = resourceName
+
+ /**
+ * Returns the raw JSON value of [useDeploymentBasedUrls].
+ *
+ * Unlike [useDeploymentBasedUrls], this method doesn't throw if the JSON field has
+ * an unexpected type.
+ */
+ @JsonProperty("useDeploymentBasedUrls")
+ @ExcludeMissing
+ fun _useDeploymentBasedUrls(): JsonField = useDeploymentBasedUrls
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /** Returns a mutable builder for constructing an instance of [Azure]. */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [Azure]. */
+ class Builder internal constructor() {
+
+ private var apiVersion: JsonField = JsonMissing.of()
+ private var baseUrl: JsonField = JsonMissing.of()
+ private var headers: JsonField = JsonMissing.of()
+ private var resourceName: JsonField = JsonMissing.of()
+ private var useDeploymentBasedUrls: JsonField = JsonMissing.of()
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(azure: Azure) = apply {
+ apiVersion = azure.apiVersion
+ baseUrl = azure.baseUrl
+ headers = azure.headers
+ resourceName = azure.resourceName
+ useDeploymentBasedUrls = azure.useDeploymentBasedUrls
+ additionalProperties = azure.additionalProperties.toMutableMap()
+ }
+
+ /** Azure OpenAI API version */
+ fun apiVersion(apiVersion: String) = apiVersion(JsonField.of(apiVersion))
+
+ /**
+ * Sets [Builder.apiVersion] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.apiVersion] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or
+ * not yet supported value.
+ */
+ fun apiVersion(apiVersion: JsonField) = apply {
+ this.apiVersion = apiVersion
+ }
+
+ /** Base URL for the Azure OpenAI provider */
+ fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl))
+
+ /**
+ * Sets [Builder.baseUrl] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.baseUrl] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or
+ * not yet supported value.
+ */
+ fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl }
+
+ /** Custom headers sent with every request to the Azure OpenAI provider */
+ fun headers(headers: Headers) = headers(JsonField.of(headers))
+
+ /**
+ * Sets [Builder.headers] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.headers] with a well-typed [Headers] value
+ * instead. This method is primarily for setting the field to an undocumented or
+ * not yet supported value.
+ */
+ fun headers(headers: JsonField) = apply { this.headers = headers }
+
+ /** Azure OpenAI resource name */
+ fun resourceName(resourceName: String) =
+ resourceName(JsonField.of(resourceName))
+
+ /**
+ * Sets [Builder.resourceName] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.resourceName] with a well-typed [String]
+ * value instead. This method is primarily for setting the field to an
+ * undocumented or not yet supported value.
+ */
+ fun resourceName(resourceName: JsonField) = apply {
+ this.resourceName = resourceName
+ }
+
+ /** Whether to use deployment-based Azure OpenAI URLs */
+ fun useDeploymentBasedUrls(useDeploymentBasedUrls: Boolean) =
+ useDeploymentBasedUrls(JsonField.of(useDeploymentBasedUrls))
+
+ /**
+ * Sets [Builder.useDeploymentBasedUrls] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.useDeploymentBasedUrls] with a well-typed
+ * [Boolean] value instead. This method is primarily for setting the field to an
+ * undocumented or not yet supported value.
+ */
+ fun useDeploymentBasedUrls(useDeploymentBasedUrls: JsonField) = apply {
+ this.useDeploymentBasedUrls = useDeploymentBasedUrls
+ }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) =
+ apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply {
+ additionalProperties.remove(key)
+ }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [Azure].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ */
+ fun build(): Azure =
+ Azure(
+ apiVersion,
+ baseUrl,
+ headers,
+ resourceName,
+ useDeploymentBasedUrls,
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing
+ * fields.
+ *
+ * @throws StagehandInvalidDataException if any value type in this object doesn't
+ * match its expected type.
+ */
+ fun validate(): Azure = apply {
+ if (validated) {
+ return@apply
+ }
+
+ apiVersion()
+ baseUrl()
+ headers().ifPresent { it.validate() }
+ resourceName()
+ useDeploymentBasedUrls()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: StagehandInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic
+ internal fun validity(): Int =
+ (if (apiVersion.asKnown().isPresent) 1 else 0) +
+ (if (baseUrl.asKnown().isPresent) 1 else 0) +
+ (headers.asKnown().getOrNull()?.validity() ?: 0) +
+ (if (resourceName.asKnown().isPresent) 1 else 0) +
+ (if (useDeploymentBasedUrls.asKnown().isPresent) 1 else 0)
+
+ /** Custom headers sent with every request to the Azure OpenAI provider */
+ class Headers
+ @JsonCreator
+ private constructor(
+ @com.fasterxml.jackson.annotation.JsonValue
+ private val additionalProperties: Map
+ ) {
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map = additionalProperties
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /** Returns a mutable builder for constructing an instance of [Headers]. */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [Headers]. */
+ class Builder internal constructor() {
+
+ private var additionalProperties: MutableMap =
+ mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(headers: Headers) = apply {
+ additionalProperties = headers.additionalProperties.toMutableMap()
+ }
+
+ fun additionalProperties(additionalProperties: Map) =
+ apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(
+ additionalProperties: Map
+ ) = apply { this.additionalProperties.putAll(additionalProperties) }
+
+ fun removeAdditionalProperty(key: String) = apply {
+ additionalProperties.remove(key)
+ }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [Headers].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ */
+ fun build(): Headers = Headers(additionalProperties.toImmutable())
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected
+ * types recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for
+ * existing fields.
+ *
+ * @throws StagehandInvalidDataException if any value type in this object
+ * doesn't match its expected type.
+ */
+ fun validate(): Headers = apply {
+ if (validated) {
+ return@apply
+ }
+
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: StagehandInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic
+ internal fun validity(): Int =
+ additionalProperties.count { (_, value) ->
+ !value.isNull() && !value.isMissing()
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Headers &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() = "Headers{additionalProperties=$additionalProperties}"
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Azure &&
+ apiVersion == other.apiVersion &&
+ baseUrl == other.baseUrl &&
+ headers == other.headers &&
+ resourceName == other.resourceName &&
+ useDeploymentBasedUrls == other.useDeploymentBasedUrls &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy {
+ Objects.hash(
+ apiVersion,
+ baseUrl,
+ headers,
+ resourceName,
+ useDeploymentBasedUrls,
+ additionalProperties,
+ )
+ }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "Azure{apiVersion=$apiVersion, baseUrl=$baseUrl, headers=$headers, resourceName=$resourceName, useDeploymentBasedUrls=$useDeploymentBasedUrls, additionalProperties=$additionalProperties}"
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is ProviderOptions &&
+ azure == other.azure &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(azure, additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "ProviderOptions{azure=$azure, additionalProperties=$additionalProperties}"
+ }
+
+ /** Custom headers sent with every request to the model provider */
+ class Headers
+ @JsonCreator
+ private constructor(
+ @com.fasterxml.jackson.annotation.JsonValue
+ private val additionalProperties: Map
+ ) {
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map = additionalProperties
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /** Returns a mutable builder for constructing an instance of [Headers]. */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [Headers]. */
+ class Builder internal constructor() {
+
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(headers: Headers) = apply {
+ additionalProperties = headers.additionalProperties.toMutableMap()
+ }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) =
+ apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply {
+ additionalProperties.remove(key)
+ }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [Headers].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ */
+ fun build(): Headers = Headers(additionalProperties.toImmutable())
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing
+ * fields.
+ *
+ * @throws StagehandInvalidDataException if any value type in this object doesn't match
+ * its expected type.
+ */
+ fun validate(): Headers = apply {
+ if (validated) {
+ return@apply
+ }
+
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: StagehandInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic
+ internal fun validity(): Int =
+ additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Headers && additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() = "Headers{additionalProperties=$additionalProperties}"
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is AzureEntraModelConfigObject &&
+ auth == other.auth &&
+ modelName == other.modelName &&
+ provider == other.provider &&
+ providerOptions == other.providerOptions &&
+ baseUrl == other.baseUrl &&
+ headers == other.headers &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy {
+ Objects.hash(
+ auth,
+ modelName,
+ provider,
+ providerOptions,
+ baseUrl,
+ headers,
+ additionalProperties,
+ )
+ }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "AzureEntraModelConfigObject{auth=$auth, modelName=$modelName, provider=$provider, providerOptions=$providerOptions, baseUrl=$baseUrl, headers=$headers, additionalProperties=$additionalProperties}"
+ }
+
+ class AzureApiKeyModelConfigObject
+ @JsonCreator(mode = JsonCreator.Mode.DISABLED)
+ private constructor(
+ private val modelName: JsonField,
+ private val provider: JsonValue,
+ private val providerOptions: JsonField,
+ private val apiKey: JsonField,
+ private val baseUrl: JsonField,
+ private val headers: JsonField,
+ private val additionalProperties: MutableMap,
+ ) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("modelName")
+ @ExcludeMissing
+ modelName: JsonField = JsonMissing.of(),
+ @JsonProperty("provider") @ExcludeMissing provider: JsonValue = JsonMissing.of(),
+ @JsonProperty("providerOptions")
+ @ExcludeMissing
+ providerOptions: JsonField = JsonMissing.of(),
+ @JsonProperty("apiKey") @ExcludeMissing apiKey: JsonField = JsonMissing.of(),
+ @JsonProperty("baseURL") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(),
+ @JsonProperty("headers") @ExcludeMissing headers: JsonField = JsonMissing.of(),
+ ) : this(modelName, provider, providerOptions, apiKey, baseUrl, headers, mutableMapOf())
+
+ /**
+ * Model name string with provider prefix (e.g., 'openai/gpt-5-nano')
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun modelName(): String = modelName.getRequired("modelName")
+
+ /**
+ * Azure OpenAI model provider
+ *
+ * Expected to always return the following:
+ * ```java
+ * JsonValue.from("azure")
+ * ```
+ *
+ * However, this method can be useful for debugging and logging (e.g. if the server
+ * responded with an unexpected value).
+ */
+ @JsonProperty("provider") @ExcludeMissing fun _provider(): JsonValue = provider
+
+ /**
+ * Azure provider-specific model configuration
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun providerOptions(): ProviderOptions = providerOptions.getRequired("providerOptions")
+
+ /**
+ * API key for the model provider
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if
+ * the server responded with an unexpected value).
+ */
+ fun apiKey(): Optional = apiKey.getOptional("apiKey")
+
+ /**
+ * Base URL for the model provider
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if
+ * the server responded with an unexpected value).
+ */
+ fun baseUrl(): Optional = baseUrl.getOptional("baseURL")
+
+ /**
+ * Custom headers sent with every request to the model provider
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if
+ * the server responded with an unexpected value).
+ */
+ fun headers(): Optional = headers.getOptional("headers")
+
+ /**
+ * Returns the raw JSON value of [modelName].
+ *
+ * Unlike [modelName], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("modelName") @ExcludeMissing fun _modelName(): JsonField = modelName
+
+ /**
+ * Returns the raw JSON value of [providerOptions].
+ *
+ * Unlike [providerOptions], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("providerOptions")
+ @ExcludeMissing
+ fun _providerOptions(): JsonField = providerOptions
+
+ /**
+ * Returns the raw JSON value of [apiKey].
+ *
+ * Unlike [apiKey], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("apiKey") @ExcludeMissing fun _apiKey(): JsonField = apiKey
+
+ /**
+ * Returns the raw JSON value of [baseUrl].
+ *
+ * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("baseURL") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl
+
+ /**
+ * Returns the raw JSON value of [headers].
+ *
+ * Unlike [headers], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonField = headers
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of
+ * [AzureApiKeyModelConfigObject].
+ *
+ * The following fields are required:
+ * ```java
+ * .modelName()
+ * .providerOptions()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [AzureApiKeyModelConfigObject]. */
+ class Builder internal constructor() {
+
+ private var modelName: JsonField? = null
+ private var provider: JsonValue = JsonValue.from("azure")
+ private var providerOptions: JsonField? = null
+ private var apiKey: JsonField = JsonMissing.of()
+ private var baseUrl: JsonField = JsonMissing.of()
+ private var headers: JsonField = JsonMissing.of()
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(azureApiKeyModelConfigObject: AzureApiKeyModelConfigObject) = apply {
+ modelName = azureApiKeyModelConfigObject.modelName
+ provider = azureApiKeyModelConfigObject.provider
+ providerOptions = azureApiKeyModelConfigObject.providerOptions
+ apiKey = azureApiKeyModelConfigObject.apiKey
+ baseUrl = azureApiKeyModelConfigObject.baseUrl
+ headers = azureApiKeyModelConfigObject.headers
+ additionalProperties =
+ azureApiKeyModelConfigObject.additionalProperties.toMutableMap()
+ }
+
+ /** Model name string with provider prefix (e.g., 'openai/gpt-5-nano') */
+ fun modelName(modelName: String) = modelName(JsonField.of(modelName))
+
+ /**
+ * Sets [Builder.modelName] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.modelName] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun modelName(modelName: JsonField) = apply { this.modelName = modelName }
+
+ /**
+ * Sets the field to an arbitrary JSON value.
+ *
+ * It is usually unnecessary to call this method because the field defaults to the
+ * following:
+ * ```java
+ * JsonValue.from("azure")
+ * ```
+ *
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun provider(provider: JsonValue) = apply { this.provider = provider }
+
+ /** Azure provider-specific model configuration */
+ fun providerOptions(providerOptions: ProviderOptions) =
+ providerOptions(JsonField.of(providerOptions))
+
+ /**
+ * Sets [Builder.providerOptions] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.providerOptions] with a well-typed [ProviderOptions]
+ * value instead. This method is primarily for setting the field to an undocumented or
+ * not yet supported value.
+ */
+ fun providerOptions(providerOptions: JsonField) = apply {
+ this.providerOptions = providerOptions
+ }
+
+ /** API key for the model provider */
+ fun apiKey(apiKey: String) = apiKey(JsonField.of(apiKey))
+
+ /**
+ * Sets [Builder.apiKey] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.apiKey] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun apiKey(apiKey: JsonField) = apply { this.apiKey = apiKey }
+
+ /** Base URL for the model provider */
+ fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl))
+
+ /**
+ * Sets [Builder.baseUrl] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.baseUrl] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl }
+
+ /** Custom headers sent with every request to the model provider */
+ fun headers(headers: Headers) = headers(JsonField.of(headers))
+
+ /**
+ * Sets [Builder.headers] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.headers] with a well-typed [Headers] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun headers(headers: JsonField) = apply { this.headers = headers }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [AzureApiKeyModelConfigObject].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .modelName()
+ * .providerOptions()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): AzureApiKeyModelConfigObject =
+ AzureApiKeyModelConfigObject(
+ checkRequired("modelName", modelName),
+ provider,
+ checkRequired("providerOptions", providerOptions),
+ apiKey,
+ baseUrl,
+ headers,
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws StagehandInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): AzureApiKeyModelConfigObject = apply {
+ if (validated) {
+ return@apply
+ }
+
+ modelName()
+ _provider().let {
+ if (it != JsonValue.from("azure")) {
+ throw StagehandInvalidDataException("'provider' is invalid, received $it")
+ }
+ }
+ providerOptions().validate()
+ apiKey()
+ baseUrl()
+ headers().ifPresent { it.validate() }
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: StagehandInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic
+ internal fun validity(): Int =
+ (if (modelName.asKnown().isPresent) 1 else 0) +
+ provider.let { if (it == JsonValue.from("azure")) 1 else 0 } +
+ (providerOptions.asKnown().getOrNull()?.validity() ?: 0) +
+ (if (apiKey.asKnown().isPresent) 1 else 0) +
+ (if (baseUrl.asKnown().isPresent) 1 else 0) +
+ (headers.asKnown().getOrNull()?.validity() ?: 0)
+
+ /** Azure provider-specific model configuration */
+ class ProviderOptions
+ @JsonCreator(mode = JsonCreator.Mode.DISABLED)
+ private constructor(
+ private val azure: JsonField,
+ private val additionalProperties: MutableMap,
+ ) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("azure") @ExcludeMissing azure: JsonField = JsonMissing.of()
+ ) : this(azure, mutableMapOf())
+
+ /**
+ * Azure OpenAI provider-specific settings
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected
+ * value).
+ */
+ fun azure(): Azure = azure.getRequired("azure")
+
+ /**
+ * Returns the raw JSON value of [azure].
+ *
+ * Unlike [azure], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("azure") @ExcludeMissing fun _azure(): JsonField = azure
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of [ProviderOptions].
+ *
+ * The following fields are required:
+ * ```java
+ * .azure()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [ProviderOptions]. */
+ class Builder internal constructor() {
+
+ private var azure: JsonField? = null
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(providerOptions: ProviderOptions) = apply {
+ azure = providerOptions.azure
+ additionalProperties = providerOptions.additionalProperties.toMutableMap()
+ }
+
+ /** Azure OpenAI provider-specific settings */
+ fun azure(azure: Azure) = azure(JsonField.of(azure))
+
+ /**
+ * Sets [Builder.azure] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.azure] with a well-typed [Azure] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun azure(azure: JsonField) = apply { this.azure = azure }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) =
+ apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply {
+ additionalProperties.remove(key)
+ }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [ProviderOptions].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .azure()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): ProviderOptions =
+ ProviderOptions(
+ checkRequired("azure", azure),
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing
+ * fields.
+ *
+ * @throws StagehandInvalidDataException if any value type in this object doesn't match
+ * its expected type.
+ */
+ fun validate(): ProviderOptions = apply {
+ if (validated) {
+ return@apply
+ }
+
+ azure().validate()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: StagehandInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic
+ internal fun validity(): Int = (azure.asKnown().getOrNull()?.validity() ?: 0)
+
+ /** Azure OpenAI provider-specific settings */
+ class Azure
+ @JsonCreator(mode = JsonCreator.Mode.DISABLED)
+ private constructor(
+ private val apiVersion: JsonField,
+ private val baseUrl: JsonField,
+ private val headers: JsonField,
+ private val resourceName: JsonField,
+ private val useDeploymentBasedUrls: JsonField,
+ private val additionalProperties: MutableMap,
+ ) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("apiVersion")
+ @ExcludeMissing
+ apiVersion: JsonField = JsonMissing.of(),
+ @JsonProperty("baseURL")
+ @ExcludeMissing
+ baseUrl: JsonField = JsonMissing.of(),
+ @JsonProperty("headers")
+ @ExcludeMissing
+ headers: JsonField = JsonMissing.of(),
+ @JsonProperty("resourceName")
+ @ExcludeMissing
+ resourceName: JsonField = JsonMissing.of(),
+ @JsonProperty("useDeploymentBasedUrls")
+ @ExcludeMissing
+ useDeploymentBasedUrls: JsonField = JsonMissing.of(),
+ ) : this(
+ apiVersion,
+ baseUrl,
+ headers,
+ resourceName,
+ useDeploymentBasedUrls,
+ mutableMapOf(),
+ )
+
+ /**
+ * Azure OpenAI API version
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun apiVersion(): Optional = apiVersion.getOptional("apiVersion")
+
+ /**
+ * Base URL for the Azure OpenAI provider
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun baseUrl(): Optional = baseUrl.getOptional("baseURL")
+
+ /**
+ * Custom headers sent with every request to the Azure OpenAI provider
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun headers(): Optional = headers.getOptional("headers")
+
+ /**
+ * Azure OpenAI resource name
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun resourceName(): Optional = resourceName.getOptional("resourceName")
+
+ /**
+ * Whether to use deployment-based Azure OpenAI URLs
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun useDeploymentBasedUrls(): Optional =
+ useDeploymentBasedUrls.getOptional("useDeploymentBasedUrls")
+
+ /**
+ * Returns the raw JSON value of [apiVersion].
+ *
+ * Unlike [apiVersion], this method doesn't throw if the JSON field has an
+ * unexpected type.
+ */
+ @JsonProperty("apiVersion")
+ @ExcludeMissing
+ fun _apiVersion(): JsonField = apiVersion
+
+ /**
+ * Returns the raw JSON value of [baseUrl].
+ *
+ * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("baseURL") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl
+
+ /**
+ * Returns the raw JSON value of [headers].
+ *
+ * Unlike [headers], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("headers")
+ @ExcludeMissing
+ fun _headers(): JsonField = headers
+
+ /**
+ * Returns the raw JSON value of [resourceName].
+ *
+ * Unlike [resourceName], this method doesn't throw if the JSON field has an
+ * unexpected type.
+ */
+ @JsonProperty("resourceName")
+ @ExcludeMissing
+ fun _resourceName(): JsonField = resourceName
+
+ /**
+ * Returns the raw JSON value of [useDeploymentBasedUrls].
+ *
+ * Unlike [useDeploymentBasedUrls], this method doesn't throw if the JSON field has
+ * an unexpected type.
+ */
+ @JsonProperty("useDeploymentBasedUrls")
+ @ExcludeMissing
+ fun _useDeploymentBasedUrls(): JsonField = useDeploymentBasedUrls
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /** Returns a mutable builder for constructing an instance of [Azure]. */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [Azure]. */
+ class Builder internal constructor() {
+
+ private var apiVersion: JsonField = JsonMissing.of()
+ private var baseUrl: JsonField = JsonMissing.of()
+ private var headers: JsonField = JsonMissing.of()
+ private var resourceName: JsonField = JsonMissing.of()
+ private var useDeploymentBasedUrls: JsonField = JsonMissing.of()
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(azure: Azure) = apply {
+ apiVersion = azure.apiVersion
+ baseUrl = azure.baseUrl
+ headers = azure.headers
+ resourceName = azure.resourceName
+ useDeploymentBasedUrls = azure.useDeploymentBasedUrls
+ additionalProperties = azure.additionalProperties.toMutableMap()
+ }
+
+ /** Azure OpenAI API version */
+ fun apiVersion(apiVersion: String) = apiVersion(JsonField.of(apiVersion))
+
+ /**
+ * Sets [Builder.apiVersion] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.apiVersion] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or
+ * not yet supported value.
+ */
+ fun apiVersion(apiVersion: JsonField) = apply {
+ this.apiVersion = apiVersion
+ }
+
+ /** Base URL for the Azure OpenAI provider */
+ fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl))
+
+ /**
+ * Sets [Builder.baseUrl] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.baseUrl] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or
+ * not yet supported value.
+ */
+ fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl }
+
+ /** Custom headers sent with every request to the Azure OpenAI provider */
+ fun headers(headers: Headers) = headers(JsonField.of(headers))
+
+ /**
+ * Sets [Builder.headers] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.headers] with a well-typed [Headers] value
+ * instead. This method is primarily for setting the field to an undocumented or
+ * not yet supported value.
+ */
+ fun headers(headers: JsonField) = apply { this.headers = headers }
+
+ /** Azure OpenAI resource name */
+ fun resourceName(resourceName: String) =
+ resourceName(JsonField.of(resourceName))
+
+ /**
+ * Sets [Builder.resourceName] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.resourceName] with a well-typed [String]
+ * value instead. This method is primarily for setting the field to an
+ * undocumented or not yet supported value.
+ */
+ fun resourceName(resourceName: JsonField) = apply {
+ this.resourceName = resourceName
+ }
+
+ /** Whether to use deployment-based Azure OpenAI URLs */
+ fun useDeploymentBasedUrls(useDeploymentBasedUrls: Boolean) =
+ useDeploymentBasedUrls(JsonField.of(useDeploymentBasedUrls))
+
+ /**
+ * Sets [Builder.useDeploymentBasedUrls] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.useDeploymentBasedUrls] with a well-typed
+ * [Boolean] value instead. This method is primarily for setting the field to an
+ * undocumented or not yet supported value.
+ */
+ fun useDeploymentBasedUrls(useDeploymentBasedUrls: JsonField) = apply {
+ this.useDeploymentBasedUrls = useDeploymentBasedUrls
+ }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) =
+ apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply {
+ additionalProperties.remove(key)
+ }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [Azure].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ */
+ fun build(): Azure =
+ Azure(
+ apiVersion,
+ baseUrl,
+ headers,
+ resourceName,
+ useDeploymentBasedUrls,
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing
+ * fields.
+ *
+ * @throws StagehandInvalidDataException if any value type in this object doesn't
+ * match its expected type.
+ */
+ fun validate(): Azure = apply {
+ if (validated) {
+ return@apply
+ }
+
+ apiVersion()
+ baseUrl()
+ headers().ifPresent { it.validate() }
+ resourceName()
+ useDeploymentBasedUrls()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: StagehandInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic
+ internal fun validity(): Int =
+ (if (apiVersion.asKnown().isPresent) 1 else 0) +
+ (if (baseUrl.asKnown().isPresent) 1 else 0) +
+ (headers.asKnown().getOrNull()?.validity() ?: 0) +
+ (if (resourceName.asKnown().isPresent) 1 else 0) +
+ (if (useDeploymentBasedUrls.asKnown().isPresent) 1 else 0)
+
+ /** Custom headers sent with every request to the Azure OpenAI provider */
+ class Headers
+ @JsonCreator
+ private constructor(
+ @com.fasterxml.jackson.annotation.JsonValue
+ private val additionalProperties: Map
+ ) {
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map = additionalProperties
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /** Returns a mutable builder for constructing an instance of [Headers]. */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [Headers]. */
+ class Builder internal constructor() {
+
+ private var additionalProperties: MutableMap =
+ mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(headers: Headers) = apply {
+ additionalProperties = headers.additionalProperties.toMutableMap()
+ }
+
+ fun additionalProperties(additionalProperties: Map) =
+ apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(
+ additionalProperties: Map
+ ) = apply { this.additionalProperties.putAll(additionalProperties) }
+
+ fun removeAdditionalProperty(key: String) = apply {
+ additionalProperties.remove(key)
+ }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [Headers].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ */
+ fun build(): Headers = Headers(additionalProperties.toImmutable())
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected
+ * types recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for
+ * existing fields.
+ *
+ * @throws StagehandInvalidDataException if any value type in this object
+ * doesn't match its expected type.
+ */
+ fun validate(): Headers = apply {
+ if (validated) {
+ return@apply
+ }
+
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: StagehandInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic
+ internal fun validity(): Int =
+ additionalProperties.count { (_, value) ->
+ !value.isNull() && !value.isMissing()
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Headers &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() = "Headers{additionalProperties=$additionalProperties}"
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Azure &&
+ apiVersion == other.apiVersion &&
+ baseUrl == other.baseUrl &&
+ headers == other.headers &&
+ resourceName == other.resourceName &&
+ useDeploymentBasedUrls == other.useDeploymentBasedUrls &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy {
+ Objects.hash(
+ apiVersion,
+ baseUrl,
+ headers,
+ resourceName,
+ useDeploymentBasedUrls,
+ additionalProperties,
+ )
+ }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "Azure{apiVersion=$apiVersion, baseUrl=$baseUrl, headers=$headers, resourceName=$resourceName, useDeploymentBasedUrls=$useDeploymentBasedUrls, additionalProperties=$additionalProperties}"
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is ProviderOptions &&
+ azure == other.azure &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(azure, additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "ProviderOptions{azure=$azure, additionalProperties=$additionalProperties}"
+ }
+
+ /** Custom headers sent with every request to the model provider */
+ class Headers
+ @JsonCreator
+ private constructor(
+ @com.fasterxml.jackson.annotation.JsonValue
+ private val additionalProperties: Map
+ ) {
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map = additionalProperties
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /** Returns a mutable builder for constructing an instance of [Headers]. */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [Headers]. */
+ class Builder internal constructor() {
+
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(headers: Headers) = apply {
+ additionalProperties = headers.additionalProperties.toMutableMap()
+ }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) =
+ apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply {
+ additionalProperties.remove(key)
+ }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [Headers].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ */
+ fun build(): Headers = Headers(additionalProperties.toImmutable())
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing
+ * fields.
+ *
+ * @throws StagehandInvalidDataException if any value type in this object doesn't match
+ * its expected type.
+ */
+ fun validate(): Headers = apply {
+ if (validated) {
+ return@apply
+ }
+
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: StagehandInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic
+ internal fun validity(): Int =
+ additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Headers && additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() = "Headers{additionalProperties=$additionalProperties}"
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is AzureApiKeyModelConfigObject &&
+ modelName == other.modelName &&
+ provider == other.provider &&
+ providerOptions == other.providerOptions &&
+ apiKey == other.apiKey &&
+ baseUrl == other.baseUrl &&
+ headers == other.headers &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy {
+ Objects.hash(
+ modelName,
+ provider,
+ providerOptions,
+ apiKey,
+ baseUrl,
+ headers,
+ additionalProperties,
+ )
+ }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "AzureApiKeyModelConfigObject{modelName=$modelName, provider=$provider, providerOptions=$providerOptions, apiKey=$apiKey, baseUrl=$baseUrl, headers=$headers, additionalProperties=$additionalProperties}"
+ }
+
+ class GenericModelConfigObject
+ @JsonCreator(mode = JsonCreator.Mode.DISABLED)
+ private constructor(
+ private val modelName: JsonField,
+ private val apiKey: JsonField,
+ private val baseUrl: JsonField,
+ private val headers: JsonField,
+ private val openaiEndpointFormat: JsonField,
+ private val provider: JsonField,
+ private val additionalProperties: MutableMap,
+ ) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("modelName")
+ @ExcludeMissing
+ modelName: JsonField = JsonMissing.of(),
+ @JsonProperty("apiKey") @ExcludeMissing apiKey: JsonField = JsonMissing.of(),
+ @JsonProperty("baseURL") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(),
+ @JsonProperty("headers") @ExcludeMissing headers: JsonField = JsonMissing.of(),
+ @JsonProperty("openaiEndpointFormat")
+ @ExcludeMissing
+ openaiEndpointFormat: JsonField = JsonMissing.of(),
+ @JsonProperty("provider")
+ @ExcludeMissing
+ provider: JsonField = JsonMissing.of(),
+ ) : this(
+ modelName,
+ apiKey,
+ baseUrl,
+ headers,
+ openaiEndpointFormat,
+ provider,
+ mutableMapOf(),
+ )
+
+ /**
+ * Model name string with provider prefix (e.g., 'openai/gpt-5-nano')
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun modelName(): String = modelName.getRequired("modelName")
+
+ /**
+ * API key for the model provider
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if
+ * the server responded with an unexpected value).
+ */
+ fun apiKey(): Optional = apiKey.getOptional("apiKey")
+
+ /**
+ * Base URL for the model provider
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if
+ * the server responded with an unexpected value).
+ */
+ fun baseUrl(): Optional = baseUrl.getOptional("baseURL")
+
+ /**
+ * Custom headers sent with every request to the model provider
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if
+ * the server responded with an unexpected value).
+ */
+ fun headers(): Optional = headers.getOptional("headers")
+
+ /**
+ * Wire format used by an OpenAI-compatible endpoint. Defaults to the Responses API; use
+ * chat for Chat Completions-only endpoints.
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if
+ * the server responded with an unexpected value).
+ */
+ fun openaiEndpointFormat(): Optional =
+ openaiEndpointFormat.getOptional("openaiEndpointFormat")
+
+ /**
+ * AI provider for the model (or provide a baseURL endpoint instead)
+ *
+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if
+ * the server responded with an unexpected value).
+ */
+ fun provider(): Optional = provider.getOptional("provider")
+
+ /**
+ * Returns the raw JSON value of [modelName].
+ *
+ * Unlike [modelName], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("modelName") @ExcludeMissing fun _modelName(): JsonField = modelName
+
+ /**
+ * Returns the raw JSON value of [apiKey].
+ *
+ * Unlike [apiKey], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("apiKey") @ExcludeMissing fun _apiKey(): JsonField = apiKey
+
+ /**
+ * Returns the raw JSON value of [baseUrl].
+ *
+ * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("baseURL") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl
+
+ /**
+ * Returns the raw JSON value of [headers].
+ *
+ * Unlike [headers], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonField = headers
+
+ /**
+ * Returns the raw JSON value of [openaiEndpointFormat].
+ *
+ * Unlike [openaiEndpointFormat], this method doesn't throw if the JSON field has an
+ * unexpected type.
+ */
+ @JsonProperty("openaiEndpointFormat")
+ @ExcludeMissing
+ fun _openaiEndpointFormat(): JsonField = openaiEndpointFormat
+
+ /**
+ * Returns the raw JSON value of [provider].
+ *
+ * Unlike [provider], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("provider") @ExcludeMissing fun _provider(): JsonField = provider
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of [GenericModelConfigObject].
+ *
+ * The following fields are required:
+ * ```java
+ * .modelName()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [GenericModelConfigObject]. */
+ class Builder internal constructor() {
+
+ private var modelName: JsonField? = null
+ private var apiKey: JsonField = JsonMissing.of()
+ private var baseUrl: JsonField = JsonMissing.of()
+ private var headers: JsonField = JsonMissing.of()
+ private var openaiEndpointFormat: JsonField = JsonMissing.of()
+ private var provider: JsonField = JsonMissing.of()
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(genericModelConfigObject: GenericModelConfigObject) = apply {
+ modelName = genericModelConfigObject.modelName
+ apiKey = genericModelConfigObject.apiKey
+ baseUrl = genericModelConfigObject.baseUrl
+ headers = genericModelConfigObject.headers
+ openaiEndpointFormat = genericModelConfigObject.openaiEndpointFormat
+ provider = genericModelConfigObject.provider
+ additionalProperties = genericModelConfigObject.additionalProperties.toMutableMap()
+ }
+
+ /** Model name string with provider prefix (e.g., 'openai/gpt-5-nano') */
+ fun modelName(modelName: String) = modelName(JsonField.of(modelName))
+
+ /**
+ * Sets [Builder.modelName] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.modelName] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun modelName(modelName: JsonField) = apply { this.modelName = modelName }
+
+ /** API key for the model provider */
+ fun apiKey(apiKey: String) = apiKey(JsonField.of(apiKey))
+
+ /**
+ * Sets [Builder.apiKey] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.apiKey] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun apiKey(apiKey: JsonField) = apply { this.apiKey = apiKey }
+
+ /** Base URL for the model provider */
+ fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl))
+
+ /**
+ * Sets [Builder.baseUrl] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.baseUrl] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl }
+
+ /** Custom headers sent with every request to the model provider */
+ fun headers(headers: Headers) = headers(JsonField.of(headers))
+
+ /**
+ * Sets [Builder.headers] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.headers] with a well-typed [Headers] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun headers(headers: JsonField) = apply { this.headers = headers }
+
+ /**
+ * Wire format used by an OpenAI-compatible endpoint. Defaults to the Responses API; use
+ * chat for Chat Completions-only endpoints.
+ */
+ fun openaiEndpointFormat(openaiEndpointFormat: OpenAIEndpointFormat) =
+ openaiEndpointFormat(JsonField.of(openaiEndpointFormat))
+
+ /**
+ * Sets [Builder.openaiEndpointFormat] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.openaiEndpointFormat] with a well-typed
+ * [OpenAIEndpointFormat] value instead. This method is primarily for setting the field
+ * to an undocumented or not yet supported value.
+ */
+ fun openaiEndpointFormat(openaiEndpointFormat: JsonField) =
+ apply {
+ this.openaiEndpointFormat = openaiEndpointFormat
+ }
+
+ /** AI provider for the model (or provide a baseURL endpoint instead) */
+ fun provider(provider: Provider) = provider(JsonField.of(provider))
+
+ /**
+ * Sets [Builder.provider] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.provider] with a well-typed [Provider] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun provider(provider: JsonField) = apply { this.provider = provider }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [GenericModelConfigObject].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .modelName()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): GenericModelConfigObject =
+ GenericModelConfigObject(
+ checkRequired("modelName", modelName),
+ apiKey,
+ baseUrl,
+ headers,
+ openaiEndpointFormat,
+ provider,
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws StagehandInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): GenericModelConfigObject = apply {
+ if (validated) {
+ return@apply
+ }
+
+ modelName()
+ apiKey()
+ baseUrl()
+ headers().ifPresent { it.validate() }
+ openaiEndpointFormat().ifPresent { it.validate() }
+ provider().ifPresent { it.validate() }
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: StagehandInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic
+ internal fun validity(): Int =
+ (if (modelName.asKnown().isPresent) 1 else 0) +
+ (if (apiKey.asKnown().isPresent) 1 else 0) +
+ (if (baseUrl.asKnown().isPresent) 1 else 0) +
+ (headers.asKnown().getOrNull()?.validity() ?: 0) +
+ (openaiEndpointFormat.asKnown().getOrNull()?.validity() ?: 0) +
+ (provider.asKnown().getOrNull()?.validity() ?: 0)
+
+ /** Custom headers sent with every request to the model provider */
+ class Headers
+ @JsonCreator
+ private constructor(
+ @com.fasterxml.jackson.annotation.JsonValue
+ private val additionalProperties: Map
+ ) {
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map