diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 807cc3abe..803fec4ac 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "4.41.0"
+ ".": "4.42.0"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index fe88e03e3..2fd90dc18 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
-configured_endpoints: 263
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-b5b621065906a2579dc180db1236ee3b08a4fca9539accc2fbbf88da0ca3923f.yml
-openapi_spec_hash: 45b1b4692b26e714008d8120ccfc7433
-config_hash: ef3ce17315a31703e7af0567b3e9738c
+configured_endpoints: 270
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-39637fc9365e6f80f12424e7c87179553f157b96b47c599b96d5a02f6966d3da.yml
+openapi_spec_hash: 885864ae98a443166f585f856c464fb2
+config_hash: b40012963b4619be8229fcca0105b627
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3b43c539f..4d98688b0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,23 @@
# Changelog
+## [4.42.0](https://github.com/openai/openai-java/compare/v4.41.0...v4.42.0) (2026-07-09)
+
+
+### Features
+
+* **api:** gpt-5.6-sol updates ([2ca768a](https://github.com/openai/openai-java/commit/2ca768ad80da1643680ce99fee977080e19f2e2b))
+
+
+### Bug Fixes
+
+* **api:** preserve deprecated beta realtime accessors ([a1cd1f1](https://github.com/openai/openai-java/commit/a1cd1f1ad58f7009073819765792d62995650da7))
+* **api:** restore beta responses custom code ([73f67f2](https://github.com/openai/openai-java/commit/73f67f286ef5147fc252090f9d3b8e44a857a208))
+
+
+### Chores
+
+* retrigger release automation ([a3006ee](https://github.com/openai/openai-java/commit/a3006ee468a3e4d4167368cf5a2e66590e4a65a0))
+
## 4.41.0 (2026-06-17)
Full Changelog: [v4.40.0...v4.41.0](https://github.com/openai/openai-java/compare/v4.40.0...v4.41.0)
diff --git a/README.md b/README.md
index 3fc418846..e8ba7a1ec 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,8 @@
-[](https://central.sonatype.com/artifact/com.openai/openai-java/4.41.0)
-[](https://javadoc.io/doc/com.openai/openai-java/4.41.0)
+[](https://central.sonatype.com/artifact/com.openai/openai-java/4.42.0)
+[](https://javadoc.io/doc/com.openai/openai-java/4.42.0)
@@ -11,7 +11,7 @@ The OpenAI Java SDK provides convenient access to the [OpenAI REST API](https://
-The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/4.41.0).
+The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/4.42.0).
@@ -24,7 +24,7 @@ The REST API documentation can be found on [platform.openai.com](https://platfor
### Gradle
```kotlin
-implementation("com.openai:openai-java:4.41.0")
+implementation("com.openai:openai-java:4.42.0")
```
### Maven
@@ -33,7 +33,7 @@ implementation("com.openai:openai-java:4.41.0")
com.openaiopenai-java
- 4.41.0
+ 4.42.0
```
@@ -1433,7 +1433,7 @@ If you're using Spring Boot, then you can use the SDK's [Spring Boot starter](ht
#### Gradle
```kotlin
-implementation("com.openai:openai-java-spring-boot-starter:4.41.0")
+implementation("com.openai:openai-java-spring-boot-starter:4.42.0")
```
#### Maven
@@ -1442,7 +1442,7 @@ implementation("com.openai:openai-java-spring-boot-starter:4.41.0")
com.openaiopenai-java-spring-boot-starter
- 4.41.0
+ 4.42.0
```
diff --git a/build.gradle.kts b/build.gradle.kts
index 0a533a3ee..98cc6dac2 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -8,7 +8,7 @@ repositories {
allprojects {
group = "com.openai"
- version = "4.41.0" // x-release-please-version
+ version = "4.42.0" // x-release-please-version
}
subprojects {
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ChatModel.kt b/openai-java-core/src/main/kotlin/com/openai/models/ChatModel.kt
index 16bf07847..35755e10b 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/ChatModel.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/ChatModel.kt
@@ -20,6 +20,12 @@ class ChatModel @JsonCreator private constructor(private val value: JsonField Value.GPT_5_6_SOL
+ GPT_5_6_TERRA -> Value.GPT_5_6_TERRA
+ GPT_5_6_LUNA -> Value.GPT_5_6_LUNA
GPT_5_4 -> Value.GPT_5_4
GPT_5_4_MINI -> Value.GPT_5_4_MINI
GPT_5_4_NANO -> Value.GPT_5_4_NANO
@@ -455,6 +470,9 @@ class ChatModel @JsonCreator private constructor(private val value: JsonField Known.GPT_5_6_SOL
+ GPT_5_6_TERRA -> Known.GPT_5_6_TERRA
+ GPT_5_6_LUNA -> Known.GPT_5_6_LUNA
GPT_5_4 -> Known.GPT_5_4
GPT_5_4_MINI -> Known.GPT_5_4_MINI
GPT_5_4_NANO -> Known.GPT_5_4_NANO
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/Reasoning.kt b/openai-java-core/src/main/kotlin/com/openai/models/Reasoning.kt
index 285ebff40..df225da7f 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/Reasoning.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/Reasoning.kt
@@ -28,6 +28,7 @@ private constructor(
private val context: JsonField,
private val effort: JsonField,
private val generateSummary: JsonField,
+ private val mode: JsonField,
private val summary: JsonField,
private val additionalProperties: MutableMap,
) {
@@ -41,8 +42,9 @@ private constructor(
@JsonProperty("generate_summary")
@ExcludeMissing
generateSummary: JsonField = JsonMissing.of(),
+ @JsonProperty("mode") @ExcludeMissing mode: JsonField = JsonMissing.of(),
@JsonProperty("summary") @ExcludeMissing summary: JsonField = JsonMissing.of(),
- ) : this(context, effort, generateSummary, summary, mutableMapOf())
+ ) : this(context, effort, generateSummary, mode, summary, mutableMapOf())
/**
* Controls which reasoning items are rendered back to the model on later turns. When returned
@@ -54,17 +56,12 @@ private constructor(
fun context(): Optional = context.getOptional("context")
/**
- * Constrains effort on reasoning for
- * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported
- * values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing reasoning effort
- * can result in faster responses and fewer tokens used on reasoning in a response.
- * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning
- * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported for
- * all reasoning values in gpt-5.1.
- * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support
- * `none`.
- * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
- * - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
+ * Constrains effort on reasoning for reasoning models. Currently supported values are `none`,
+ * `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Reducing reasoning effort can result
+ * in faster responses and fewer tokens used on reasoning in a response. Not all reasoning
+ * models support every value. See the
+ * [reasoning guide](https://platform.openai.com/docs/guides/reasoning) for model-specific
+ * support.
*
* @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
@@ -84,6 +81,16 @@ private constructor(
fun generateSummary(): Optional =
generateSummary.getOptional("generate_summary")
+ /**
+ * Controls the reasoning execution mode for the request.
+ *
+ * When returned on a response, this is the effective execution mode.
+ *
+ * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun mode(): Optional = mode.getOptional("mode")
+
/**
* A summary of the reasoning performed by the model. This can be useful for debugging and
* understanding the model's reasoning process. One of `auto`, `concise`, or `detailed`.
@@ -120,6 +127,13 @@ private constructor(
@ExcludeMissing
fun _generateSummary(): JsonField = generateSummary
+ /**
+ * Returns the raw JSON value of [mode].
+ *
+ * Unlike [mode], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode
+
/**
* Returns the raw JSON value of [summary].
*
@@ -151,6 +165,7 @@ private constructor(
private var context: JsonField = JsonMissing.of()
private var effort: JsonField = JsonMissing.of()
private var generateSummary: JsonField = JsonMissing.of()
+ private var mode: JsonField = JsonMissing.of()
private var summary: JsonField = JsonMissing.of()
private var additionalProperties: MutableMap = mutableMapOf()
@@ -159,6 +174,7 @@ private constructor(
context = reasoning.context
effort = reasoning.effort
generateSummary = reasoning.generateSummary
+ mode = reasoning.mode
summary = reasoning.summary
additionalProperties = reasoning.additionalProperties.toMutableMap()
}
@@ -182,18 +198,12 @@ private constructor(
fun context(context: JsonField) = apply { this.context = context }
/**
- * Constrains effort on reasoning for
- * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
- * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing
- * reasoning effort can result in faster responses and fewer tokens used on reasoning in a
- * response.
- * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning
- * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported
- * for all reasoning values in gpt-5.1.
- * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support
- * `none`.
- * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
- * - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
+ * Constrains effort on reasoning for reasoning models. Currently supported values are
+ * `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Reducing reasoning effort
+ * can result in faster responses and fewer tokens used on reasoning in a response. Not all
+ * reasoning models support every value. See the
+ * [reasoning guide](https://platform.openai.com/docs/guides/reasoning) for model-specific
+ * support.
*/
fun effort(effort: ReasoningEffort?) = effort(JsonField.ofNullable(effort))
@@ -236,6 +246,29 @@ private constructor(
this.generateSummary = generateSummary
}
+ /**
+ * Controls the reasoning execution mode for the request.
+ *
+ * When returned on a response, this is the effective execution mode.
+ */
+ fun mode(mode: Mode) = mode(JsonField.of(mode))
+
+ /**
+ * Sets [Builder.mode] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.mode] with a well-typed [Mode] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun mode(mode: JsonField) = apply { this.mode = mode }
+
+ /**
+ * Sets [mode] to an arbitrary [String].
+ *
+ * You should usually call [mode] with a well-typed [Mode] constant instead. This method is
+ * primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun mode(value: String) = mode(Mode.of(value))
+
/**
* A summary of the reasoning performed by the model. This can be useful for debugging and
* understanding the model's reasoning process. One of `auto`, `concise`, or `detailed`.
@@ -285,6 +318,7 @@ private constructor(
context,
effort,
generateSummary,
+ mode,
summary,
additionalProperties.toMutableMap(),
)
@@ -308,6 +342,7 @@ private constructor(
context().ifPresent { it.validate() }
effort().ifPresent { it.validate() }
generateSummary().ifPresent { it.validate() }
+ mode()
summary().ifPresent { it.validate() }
validated = true
}
@@ -330,6 +365,7 @@ private constructor(
(context.asKnown().getOrNull()?.validity() ?: 0) +
(effort.asKnown().getOrNull()?.validity() ?: 0) +
(generateSummary.asKnown().getOrNull()?.validity() ?: 0) +
+ (if (mode.asKnown().isPresent) 1 else 0) +
(summary.asKnown().getOrNull()?.validity() ?: 0)
/**
@@ -627,6 +663,145 @@ private constructor(
override fun toString() = value.toString()
}
+ /**
+ * Controls the reasoning execution mode for the request.
+ *
+ * When returned on a response, this is the effective execution mode.
+ */
+ class Mode @JsonCreator private constructor(private val value: JsonField) : Enum {
+
+ /**
+ * Returns this class instance's raw value.
+ *
+ * This is usually only useful if this instance was deserialized from data that doesn't
+ * match any known member, and you want to know that value. For example, if the SDK is on an
+ * older version than the API, then the API may respond with new members that the SDK is
+ * unaware of.
+ */
+ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value
+
+ companion object {
+
+ @JvmField val STANDARD = of("standard")
+
+ @JvmField val PRO = of("pro")
+
+ @JvmStatic fun of(value: String) = Mode(JsonField.of(value))
+ }
+
+ /** An enum containing [Mode]'s known values. */
+ enum class Known {
+ STANDARD,
+ PRO,
+ }
+
+ /**
+ * An enum containing [Mode]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [Mode] can contain an unknown value in a couple of cases:
+ * - It was deserialized from data that doesn't match any known member. For example, if the
+ * SDK is on an older version than the API, then the API may respond with new members that
+ * the SDK is unaware of.
+ * - It was constructed with an arbitrary value using the [of] method.
+ */
+ enum class Value {
+ STANDARD,
+ PRO,
+ /** An enum member indicating that [Mode] was instantiated with an unknown value. */
+ _UNKNOWN,
+ }
+
+ /**
+ * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN]
+ * if the class was instantiated with an unknown value.
+ *
+ * Use the [known] method instead if you're certain the value is always known or if you want
+ * to throw for the unknown case.
+ */
+ fun value(): Value =
+ when (this) {
+ STANDARD -> Value.STANDARD
+ PRO -> Value.PRO
+ else -> Value._UNKNOWN
+ }
+
+ /**
+ * Returns an enum member corresponding to this class instance's value.
+ *
+ * Use the [value] method instead if you're uncertain the value is always known and don't
+ * want to throw for the unknown case.
+ *
+ * @throws OpenAIInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ STANDARD -> Known.STANDARD
+ PRO -> Known.PRO
+ else -> throw OpenAIInvalidDataException("Unknown Mode: $value")
+ }
+
+ /**
+ * Returns this class instance's primitive wire representation.
+ *
+ * This differs from the [toString] method because that method is primarily for debugging
+ * and generally doesn't throw.
+ *
+ * @throws OpenAIInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow { OpenAIInvalidDataException("Value is not a String") }
+
+ 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 OpenAIInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): Mode = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: OpenAIInvalidDataException) {
+ 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 (value() == Value._UNKNOWN) 0 else 1
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Mode && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+ }
+
/**
* A summary of the reasoning performed by the model. This can be useful for debugging and
* understanding the model's reasoning process. One of `auto`, `concise`, or `detailed`.
@@ -783,16 +958,17 @@ private constructor(
context == other.context &&
effort == other.effort &&
generateSummary == other.generateSummary &&
+ mode == other.mode &&
summary == other.summary &&
additionalProperties == other.additionalProperties
}
private val hashCode: Int by lazy {
- Objects.hash(context, effort, generateSummary, summary, additionalProperties)
+ Objects.hash(context, effort, generateSummary, mode, summary, additionalProperties)
}
override fun hashCode(): Int = hashCode
override fun toString() =
- "Reasoning{context=$context, effort=$effort, generateSummary=$generateSummary, summary=$summary, additionalProperties=$additionalProperties}"
+ "Reasoning{context=$context, effort=$effort, generateSummary=$generateSummary, mode=$mode, summary=$summary, additionalProperties=$additionalProperties}"
}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ReasoningEffort.kt b/openai-java-core/src/main/kotlin/com/openai/models/ReasoningEffort.kt
index 0bead0c0a..24e86d596 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/ReasoningEffort.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/ReasoningEffort.kt
@@ -8,16 +8,11 @@ import com.openai.core.JsonField
import com.openai.errors.OpenAIInvalidDataException
/**
- * Constrains effort on reasoning for
- * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported values
- * are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing reasoning effort can result
- * in faster responses and fewer tokens used on reasoning in a response.
- * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning values
- * for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported for all
- * reasoning values in gpt-5.1.
- * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support `none`.
- * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
- * - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
+ * Constrains effort on reasoning for reasoning models. Currently supported values are `none`,
+ * `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Reducing reasoning effort can result in
+ * faster responses and fewer tokens used on reasoning in a response. Not all reasoning models
+ * support every value. See the [reasoning guide](https://platform.openai.com/docs/guides/reasoning)
+ * for model-specific support.
*/
class ReasoningEffort @JsonCreator private constructor(private val value: JsonField) :
Enum {
@@ -45,6 +40,8 @@ class ReasoningEffort @JsonCreator private constructor(private val value: JsonFi
@JvmField val XHIGH = of("xhigh")
+ @JvmField val MAX = of("max")
+
@JvmStatic fun of(value: String) = ReasoningEffort(JsonField.of(value))
}
@@ -56,6 +53,7 @@ class ReasoningEffort @JsonCreator private constructor(private val value: JsonFi
MEDIUM,
HIGH,
XHIGH,
+ MAX,
}
/**
@@ -74,6 +72,7 @@ class ReasoningEffort @JsonCreator private constructor(private val value: JsonFi
MEDIUM,
HIGH,
XHIGH,
+ MAX,
/**
* An enum member indicating that [ReasoningEffort] was instantiated with an unknown value.
*/
@@ -95,6 +94,7 @@ class ReasoningEffort @JsonCreator private constructor(private val value: JsonFi
MEDIUM -> Value.MEDIUM
HIGH -> Value.HIGH
XHIGH -> Value.XHIGH
+ MAX -> Value.MAX
else -> Value._UNKNOWN
}
@@ -114,6 +114,7 @@ class ReasoningEffort @JsonCreator private constructor(private val value: JsonFi
MEDIUM -> Known.MEDIUM
HIGH -> Known.HIGH
XHIGH -> Known.XHIGH
+ MAX -> Known.MAX
else -> throw OpenAIInvalidDataException("Unknown ReasoningEffort: $value")
}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantCreateParams.kt
index 0613798c1..4dc7723f5 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantCreateParams.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantCreateParams.kt
@@ -97,17 +97,12 @@ private constructor(
fun name(): Optional = body.name()
/**
- * Constrains effort on reasoning for
- * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported
- * values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing reasoning effort
- * can result in faster responses and fewer tokens used on reasoning in a response.
- * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning
- * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported for
- * all reasoning values in gpt-5.1.
- * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support
- * `none`.
- * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
- * - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
+ * Constrains effort on reasoning for reasoning models. Currently supported values are `none`,
+ * `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Reducing reasoning effort can result
+ * in faster responses and fewer tokens used on reasoning in a response. Not all reasoning
+ * models support every value. See the
+ * [reasoning guide](https://platform.openai.com/docs/guides/reasoning) for model-specific
+ * support.
*
* @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
@@ -403,18 +398,12 @@ private constructor(
fun name(name: JsonField) = apply { body.name(name) }
/**
- * Constrains effort on reasoning for
- * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
- * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing
- * reasoning effort can result in faster responses and fewer tokens used on reasoning in a
- * response.
- * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning
- * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported
- * for all reasoning values in gpt-5.1.
- * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support
- * `none`.
- * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
- * - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
+ * Constrains effort on reasoning for reasoning models. Currently supported values are
+ * `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Reducing reasoning effort
+ * can result in faster responses and fewer tokens used on reasoning in a response. Not all
+ * reasoning models support every value. See the
+ * [reasoning guide](https://platform.openai.com/docs/guides/reasoning) for model-specific
+ * support.
*/
fun reasoningEffort(reasoningEffort: ReasoningEffort?) = apply {
body.reasoningEffort(reasoningEffort)
@@ -873,18 +862,12 @@ private constructor(
fun name(): Optional = name.getOptional("name")
/**
- * Constrains effort on reasoning for
- * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
- * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing
- * reasoning effort can result in faster responses and fewer tokens used on reasoning in a
- * response.
- * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning
- * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported
- * for all reasoning values in gpt-5.1.
- * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support
- * `none`.
- * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
- * - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
+ * Constrains effort on reasoning for reasoning models. Currently supported values are
+ * `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Reducing reasoning effort
+ * can result in faster responses and fewer tokens used on reasoning in a response. Not all
+ * reasoning models support every value. See the
+ * [reasoning guide](https://platform.openai.com/docs/guides/reasoning) for model-specific
+ * support.
*
* @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
@@ -1212,18 +1195,12 @@ private constructor(
fun name(name: JsonField) = apply { this.name = name }
/**
- * Constrains effort on reasoning for
- * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
- * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
- * Reducing reasoning effort can result in faster responses and fewer tokens used on
- * reasoning in a response.
- * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
- * reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls
- * are supported for all reasoning values in gpt-5.1.
- * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
- * support `none`.
- * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
- * - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
+ * Constrains effort on reasoning for reasoning models. Currently supported values are
+ * `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Reducing reasoning
+ * effort can result in faster responses and fewer tokens used on reasoning in a
+ * response. Not all reasoning models support every value. See the
+ * [reasoning guide](https://platform.openai.com/docs/guides/reasoning) for
+ * model-specific support.
*/
fun reasoningEffort(reasoningEffort: ReasoningEffort?) =
reasoningEffort(JsonField.ofNullable(reasoningEffort))
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantUpdateParams.kt
index 93e6ecff9..4115e8f65 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantUpdateParams.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantUpdateParams.kt
@@ -89,17 +89,12 @@ private constructor(
fun name(): Optional = body.name()
/**
- * Constrains effort on reasoning for
- * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported
- * values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing reasoning effort
- * can result in faster responses and fewer tokens used on reasoning in a response.
- * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning
- * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported for
- * all reasoning values in gpt-5.1.
- * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support
- * `none`.
- * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
- * - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
+ * Constrains effort on reasoning for reasoning models. Currently supported values are `none`,
+ * `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Reducing reasoning effort can result
+ * in faster responses and fewer tokens used on reasoning in a response. Not all reasoning
+ * models support every value. See the
+ * [reasoning guide](https://platform.openai.com/docs/guides/reasoning) for model-specific
+ * support.
*
* @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
@@ -397,18 +392,12 @@ private constructor(
fun name(name: JsonField) = apply { body.name(name) }
/**
- * Constrains effort on reasoning for
- * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
- * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing
- * reasoning effort can result in faster responses and fewer tokens used on reasoning in a
- * response.
- * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning
- * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported
- * for all reasoning values in gpt-5.1.
- * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support
- * `none`.
- * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
- * - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
+ * Constrains effort on reasoning for reasoning models. Currently supported values are
+ * `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Reducing reasoning effort
+ * can result in faster responses and fewer tokens used on reasoning in a response. Not all
+ * reasoning models support every value. See the
+ * [reasoning guide](https://platform.openai.com/docs/guides/reasoning) for model-specific
+ * support.
*/
fun reasoningEffort(reasoningEffort: ReasoningEffort?) = apply {
body.reasoningEffort(reasoningEffort)
@@ -867,18 +856,12 @@ private constructor(
fun name(): Optional = name.getOptional("name")
/**
- * Constrains effort on reasoning for
- * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
- * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing
- * reasoning effort can result in faster responses and fewer tokens used on reasoning in a
- * response.
- * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning
- * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported
- * for all reasoning values in gpt-5.1.
- * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support
- * `none`.
- * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
- * - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
+ * Constrains effort on reasoning for reasoning models. Currently supported values are
+ * `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Reducing reasoning effort
+ * can result in faster responses and fewer tokens used on reasoning in a response. Not all
+ * reasoning models support every value. See the
+ * [reasoning guide](https://platform.openai.com/docs/guides/reasoning) for model-specific
+ * support.
*
* @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
@@ -1199,18 +1182,12 @@ private constructor(
fun name(name: JsonField) = apply { this.name = name }
/**
- * Constrains effort on reasoning for
- * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
- * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
- * Reducing reasoning effort can result in faster responses and fewer tokens used on
- * reasoning in a response.
- * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
- * reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls
- * are supported for all reasoning values in gpt-5.1.
- * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
- * support `none`.
- * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
- * - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
+ * Constrains effort on reasoning for reasoning models. Currently supported values are
+ * `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Reducing reasoning
+ * effort can result in faster responses and fewer tokens used on reasoning in a
+ * response. Not all reasoning models support every value. See the
+ * [reasoning guide](https://platform.openai.com/docs/guides/reasoning) for
+ * model-specific support.
*/
fun reasoningEffort(reasoningEffort: ReasoningEffort?) =
reasoningEffort(JsonField.ofNullable(reasoningEffort))
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaApplyPatchTool.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaApplyPatchTool.kt
new file mode 100644
index 000000000..c0b39c34e
--- /dev/null
+++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaApplyPatchTool.kt
@@ -0,0 +1,376 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.openai.models.beta.responses
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter
+import com.fasterxml.jackson.annotation.JsonAnySetter
+import com.fasterxml.jackson.annotation.JsonCreator
+import com.fasterxml.jackson.annotation.JsonProperty
+import com.openai.core.Enum
+import com.openai.core.ExcludeMissing
+import com.openai.core.JsonField
+import com.openai.core.JsonMissing
+import com.openai.core.JsonValue
+import com.openai.core.checkKnown
+import com.openai.core.toImmutable
+import com.openai.errors.OpenAIInvalidDataException
+import java.util.Collections
+import java.util.Objects
+import java.util.Optional
+import kotlin.jvm.optionals.getOrNull
+
+/** Allows the assistant to create, delete, or update files using unified diffs. */
+class BetaApplyPatchTool
+@JsonCreator(mode = JsonCreator.Mode.DISABLED)
+private constructor(
+ private val type: JsonValue,
+ private val allowedCallers: JsonField>,
+ private val additionalProperties: MutableMap,
+) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(),
+ @JsonProperty("allowed_callers")
+ @ExcludeMissing
+ allowedCallers: JsonField> = JsonMissing.of(),
+ ) : this(type, allowedCallers, mutableMapOf())
+
+ /**
+ * The type of the tool. Always `apply_patch`.
+ *
+ * Expected to always return the following:
+ * ```java
+ * JsonValue.from("apply_patch")
+ * ```
+ *
+ * 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
+
+ /**
+ * The tool invocation context(s).
+ *
+ * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun allowedCallers(): Optional> =
+ allowedCallers.getOptional("allowed_callers")
+
+ /**
+ * Returns the raw JSON value of [allowedCallers].
+ *
+ * Unlike [allowedCallers], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("allowed_callers")
+ @ExcludeMissing
+ fun _allowedCallers(): JsonField> = allowedCallers
+
+ @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 [BetaApplyPatchTool]. */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [BetaApplyPatchTool]. */
+ class Builder internal constructor() {
+
+ private var type: JsonValue = JsonValue.from("apply_patch")
+ private var allowedCallers: JsonField>? = null
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(betaApplyPatchTool: BetaApplyPatchTool) = apply {
+ type = betaApplyPatchTool.type
+ allowedCallers = betaApplyPatchTool.allowedCallers.map { it.toMutableList() }
+ additionalProperties = betaApplyPatchTool.additionalProperties.toMutableMap()
+ }
+
+ /**
+ * 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("apply_patch")
+ * ```
+ *
+ * This method is primarily for setting the field to an undocumented or not yet supported
+ * value.
+ */
+ fun type(type: JsonValue) = apply { this.type = type }
+
+ /** The tool invocation context(s). */
+ fun allowedCallers(allowedCallers: List?) =
+ allowedCallers(JsonField.ofNullable(allowedCallers))
+
+ /** Alias for calling [Builder.allowedCallers] with `allowedCallers.orElse(null)`. */
+ fun allowedCallers(allowedCallers: Optional>) =
+ allowedCallers(allowedCallers.getOrNull())
+
+ /**
+ * Sets [Builder.allowedCallers] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.allowedCallers] with a well-typed `List`
+ * value instead. This method is primarily for setting the field to an undocumented or not
+ * yet supported value.
+ */
+ fun allowedCallers(allowedCallers: JsonField>) = apply {
+ this.allowedCallers = allowedCallers.map { it.toMutableList() }
+ }
+
+ /**
+ * Adds a single [AllowedCaller] to [allowedCallers].
+ *
+ * @throws IllegalStateException if the field was previously set to a non-list.
+ */
+ fun addAllowedCaller(allowedCaller: AllowedCaller) = apply {
+ allowedCallers =
+ (allowedCallers ?: JsonField.of(mutableListOf())).also {
+ checkKnown("allowedCallers", it).add(allowedCaller)
+ }
+ }
+
+ 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 [BetaApplyPatchTool].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ */
+ fun build(): BetaApplyPatchTool =
+ BetaApplyPatchTool(
+ type,
+ (allowedCallers ?: JsonMissing.of()).map { it.toImmutable() },
+ 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 OpenAIInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): BetaApplyPatchTool = apply {
+ if (validated) {
+ return@apply
+ }
+
+ _type().let {
+ if (it != JsonValue.from("apply_patch")) {
+ throw OpenAIInvalidDataException("'type' is invalid, received $it")
+ }
+ }
+ allowedCallers().ifPresent { it.forEach { it.validate() } }
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: OpenAIInvalidDataException) {
+ 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 =
+ type.let { if (it == JsonValue.from("apply_patch")) 1 else 0 } +
+ (allowedCallers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0)
+
+ class AllowedCaller @JsonCreator private constructor(private val value: JsonField) :
+ Enum {
+
+ /**
+ * Returns this class instance's raw value.
+ *
+ * This is usually only useful if this instance was deserialized from data that doesn't
+ * match any known member, and you want to know that value. For example, if the SDK is on an
+ * older version than the API, then the API may respond with new members that the SDK is
+ * unaware of.
+ */
+ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value
+
+ companion object {
+
+ @JvmField val DIRECT = of("direct")
+
+ @JvmField val PROGRAMMATIC = of("programmatic")
+
+ @JvmStatic fun of(value: String) = AllowedCaller(JsonField.of(value))
+ }
+
+ /** An enum containing [AllowedCaller]'s known values. */
+ enum class Known {
+ DIRECT,
+ PROGRAMMATIC,
+ }
+
+ /**
+ * An enum containing [AllowedCaller]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [AllowedCaller] can contain an unknown value in a couple of cases:
+ * - It was deserialized from data that doesn't match any known member. For example, if the
+ * SDK is on an older version than the API, then the API may respond with new members that
+ * the SDK is unaware of.
+ * - It was constructed with an arbitrary value using the [of] method.
+ */
+ enum class Value {
+ DIRECT,
+ PROGRAMMATIC,
+ /**
+ * An enum member indicating that [AllowedCaller] was instantiated with an unknown
+ * value.
+ */
+ _UNKNOWN,
+ }
+
+ /**
+ * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN]
+ * if the class was instantiated with an unknown value.
+ *
+ * Use the [known] method instead if you're certain the value is always known or if you want
+ * to throw for the unknown case.
+ */
+ fun value(): Value =
+ when (this) {
+ DIRECT -> Value.DIRECT
+ PROGRAMMATIC -> Value.PROGRAMMATIC
+ else -> Value._UNKNOWN
+ }
+
+ /**
+ * Returns an enum member corresponding to this class instance's value.
+ *
+ * Use the [value] method instead if you're uncertain the value is always known and don't
+ * want to throw for the unknown case.
+ *
+ * @throws OpenAIInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ DIRECT -> Known.DIRECT
+ PROGRAMMATIC -> Known.PROGRAMMATIC
+ else -> throw OpenAIInvalidDataException("Unknown AllowedCaller: $value")
+ }
+
+ /**
+ * Returns this class instance's primitive wire representation.
+ *
+ * This differs from the [toString] method because that method is primarily for debugging
+ * and generally doesn't throw.
+ *
+ * @throws OpenAIInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow { OpenAIInvalidDataException("Value is not a String") }
+
+ 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 OpenAIInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): AllowedCaller = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: OpenAIInvalidDataException) {
+ 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 (value() == Value._UNKNOWN) 0 else 1
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is AllowedCaller && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is BetaApplyPatchTool &&
+ type == other.type &&
+ allowedCallers == other.allowedCallers &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(type, allowedCallers, additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "BetaApplyPatchTool{type=$type, allowedCallers=$allowedCallers, additionalProperties=$additionalProperties}"
+}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaCompactedResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaCompactedResponse.kt
new file mode 100644
index 000000000..ddc58444a
--- /dev/null
+++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaCompactedResponse.kt
@@ -0,0 +1,558 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.openai.models.beta.responses
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter
+import com.fasterxml.jackson.annotation.JsonAnySetter
+import com.fasterxml.jackson.annotation.JsonCreator
+import com.fasterxml.jackson.annotation.JsonProperty
+import com.openai.core.ExcludeMissing
+import com.openai.core.JsonField
+import com.openai.core.JsonMissing
+import com.openai.core.JsonValue
+import com.openai.core.checkKnown
+import com.openai.core.checkRequired
+import com.openai.core.toImmutable
+import com.openai.errors.OpenAIInvalidDataException
+import java.util.Collections
+import java.util.Objects
+import kotlin.jvm.optionals.getOrNull
+
+class BetaCompactedResponse
+@JsonCreator(mode = JsonCreator.Mode.DISABLED)
+private constructor(
+ private val id: JsonField,
+ private val createdAt: JsonField,
+ private val object_: JsonValue,
+ private val output: JsonField>,
+ private val usage: JsonField,
+ private val additionalProperties: MutableMap,
+) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(),
+ @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(),
+ @JsonProperty("object") @ExcludeMissing object_: JsonValue = JsonMissing.of(),
+ @JsonProperty("output")
+ @ExcludeMissing
+ output: JsonField> = JsonMissing.of(),
+ @JsonProperty("usage")
+ @ExcludeMissing
+ usage: JsonField = JsonMissing.of(),
+ ) : this(id, createdAt, object_, output, usage, mutableMapOf())
+
+ /**
+ * The unique identifier for the compacted response.
+ *
+ * @throws OpenAIInvalidDataException 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 id(): String = id.getRequired("id")
+
+ /**
+ * Unix timestamp (in seconds) when the compacted conversation was created.
+ *
+ * @throws OpenAIInvalidDataException 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 createdAt(): Long = createdAt.getRequired("created_at")
+
+ /**
+ * The object type. Always `response.compaction`.
+ *
+ * Expected to always return the following:
+ * ```java
+ * JsonValue.from("response.compaction")
+ * ```
+ *
+ * However, this method can be useful for debugging and logging (e.g. if the server responded
+ * with an unexpected value).
+ */
+ @JsonProperty("object") @ExcludeMissing fun _object_(): JsonValue = object_
+
+ /**
+ * The compacted list of output items. This is a list of all user messages, followed by a single
+ * compaction item.
+ *
+ * @throws OpenAIInvalidDataException 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 output(): List = output.getRequired("output")
+
+ /**
+ * Token accounting for the compaction pass, including cached, reasoning, and total tokens.
+ *
+ * @throws OpenAIInvalidDataException 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 usage(): BetaResponseUsage = usage.getRequired("usage")
+
+ /**
+ * Returns the raw JSON value of [id].
+ *
+ * Unlike [id], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id
+
+ /**
+ * Returns the raw JSON value of [createdAt].
+ *
+ * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField = createdAt
+
+ /**
+ * Returns the raw JSON value of [output].
+ *
+ * Unlike [output], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("output")
+ @ExcludeMissing
+ fun _output(): JsonField> = output
+
+ /**
+ * Returns the raw JSON value of [usage].
+ *
+ * Unlike [usage], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("usage") @ExcludeMissing fun _usage(): JsonField = usage
+
+ @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 [BetaCompactedResponse].
+ *
+ * The following fields are required:
+ * ```java
+ * .id()
+ * .createdAt()
+ * .output()
+ * .usage()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [BetaCompactedResponse]. */
+ class Builder internal constructor() {
+
+ private var id: JsonField? = null
+ private var createdAt: JsonField? = null
+ private var object_: JsonValue = JsonValue.from("response.compaction")
+ private var output: JsonField>? = null
+ private var usage: JsonField? = null
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(betaCompactedResponse: BetaCompactedResponse) = apply {
+ id = betaCompactedResponse.id
+ createdAt = betaCompactedResponse.createdAt
+ object_ = betaCompactedResponse.object_
+ output = betaCompactedResponse.output.map { it.toMutableList() }
+ usage = betaCompactedResponse.usage
+ additionalProperties = betaCompactedResponse.additionalProperties.toMutableMap()
+ }
+
+ /** The unique identifier for the compacted response. */
+ fun id(id: String) = id(JsonField.of(id))
+
+ /**
+ * Sets [Builder.id] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.id] with a well-typed [String] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun id(id: JsonField) = apply { this.id = id }
+
+ /** Unix timestamp (in seconds) when the compacted conversation was created. */
+ fun createdAt(createdAt: Long) = createdAt(JsonField.of(createdAt))
+
+ /**
+ * Sets [Builder.createdAt] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.createdAt] with a well-typed [Long] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt }
+
+ /**
+ * 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("response.compaction")
+ * ```
+ *
+ * This method is primarily for setting the field to an undocumented or not yet supported
+ * value.
+ */
+ fun object_(object_: JsonValue) = apply { this.object_ = object_ }
+
+ /**
+ * The compacted list of output items. This is a list of all user messages, followed by a
+ * single compaction item.
+ */
+ fun output(output: List) = output(JsonField.of(output))
+
+ /**
+ * Sets [Builder.output] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.output] with a well-typed `List`
+ * value instead. This method is primarily for setting the field to an undocumented or not
+ * yet supported value.
+ */
+ fun output(output: JsonField>) = apply {
+ this.output = output.map { it.toMutableList() }
+ }
+
+ /**
+ * Adds a single [BetaResponseOutputItem] to [Builder.output].
+ *
+ * @throws IllegalStateException if the field was previously set to a non-list.
+ */
+ fun addOutput(output: BetaResponseOutputItem) = apply {
+ this.output =
+ (this.output ?: JsonField.of(mutableListOf())).also {
+ checkKnown("output", it).add(output)
+ }
+ }
+
+ /** Alias for calling [addOutput] with `BetaResponseOutputItem.ofMessage(message)`. */
+ fun addOutput(message: BetaResponseOutputMessage) =
+ addOutput(BetaResponseOutputItem.ofMessage(message))
+
+ /**
+ * Alias for calling [addOutput] with
+ * `BetaResponseOutputItem.ofFileSearchCall(fileSearchCall)`.
+ */
+ fun addOutput(fileSearchCall: BetaResponseFileSearchToolCall) =
+ addOutput(BetaResponseOutputItem.ofFileSearchCall(fileSearchCall))
+
+ /**
+ * Alias for calling [addOutput] with `BetaResponseOutputItem.ofFunctionCall(functionCall)`.
+ */
+ fun addOutput(functionCall: BetaResponseFunctionToolCall) =
+ addOutput(BetaResponseOutputItem.ofFunctionCall(functionCall))
+
+ /**
+ * Alias for calling [addOutput] with
+ * `BetaResponseOutputItem.ofFunctionCallOutput(functionCallOutput)`.
+ */
+ fun addOutput(functionCallOutput: BetaResponseFunctionToolCallOutputItem) =
+ addOutput(BetaResponseOutputItem.ofFunctionCallOutput(functionCallOutput))
+
+ /**
+ * Alias for calling [addOutput] with `BetaResponseOutputItem.ofAgentMessage(agentMessage)`.
+ */
+ fun addOutput(agentMessage: BetaResponseOutputItem.AgentMessage) =
+ addOutput(BetaResponseOutputItem.ofAgentMessage(agentMessage))
+
+ /**
+ * Alias for calling [addOutput] with
+ * `BetaResponseOutputItem.ofMultiAgentCall(multiAgentCall)`.
+ */
+ fun addOutput(multiAgentCall: BetaResponseOutputItem.MultiAgentCall) =
+ addOutput(BetaResponseOutputItem.ofMultiAgentCall(multiAgentCall))
+
+ /**
+ * Alias for calling [addOutput] with
+ * `BetaResponseOutputItem.ofMultiAgentCallOutput(multiAgentCallOutput)`.
+ */
+ fun addOutput(multiAgentCallOutput: BetaResponseOutputItem.MultiAgentCallOutput) =
+ addOutput(BetaResponseOutputItem.ofMultiAgentCallOutput(multiAgentCallOutput))
+
+ /**
+ * Alias for calling [addOutput] with
+ * `BetaResponseOutputItem.ofWebSearchCall(webSearchCall)`.
+ */
+ fun addOutput(webSearchCall: BetaResponseFunctionWebSearch) =
+ addOutput(BetaResponseOutputItem.ofWebSearchCall(webSearchCall))
+
+ /**
+ * Alias for calling [addOutput] with `BetaResponseOutputItem.ofComputerCall(computerCall)`.
+ */
+ fun addOutput(computerCall: BetaResponseComputerToolCall) =
+ addOutput(BetaResponseOutputItem.ofComputerCall(computerCall))
+
+ /**
+ * Alias for calling [addOutput] with
+ * `BetaResponseOutputItem.ofComputerCallOutput(computerCallOutput)`.
+ */
+ fun addOutput(computerCallOutput: BetaResponseComputerToolCallOutputItem) =
+ addOutput(BetaResponseOutputItem.ofComputerCallOutput(computerCallOutput))
+
+ /** Alias for calling [addOutput] with `BetaResponseOutputItem.ofReasoning(reasoning)`. */
+ fun addOutput(reasoning: BetaResponseReasoningItem) =
+ addOutput(BetaResponseOutputItem.ofReasoning(reasoning))
+
+ /** Alias for calling [addOutput] with `BetaResponseOutputItem.ofProgram(program)`. */
+ fun addOutput(program: BetaResponseOutputItem.Program) =
+ addOutput(BetaResponseOutputItem.ofProgram(program))
+
+ /**
+ * Alias for calling [addOutput] with
+ * `BetaResponseOutputItem.ofProgramOutput(programOutput)`.
+ */
+ fun addOutput(programOutput: BetaResponseOutputItem.ProgramOutput) =
+ addOutput(BetaResponseOutputItem.ofProgramOutput(programOutput))
+
+ /**
+ * Alias for calling [addOutput] with
+ * `BetaResponseOutputItem.ofToolSearchCall(toolSearchCall)`.
+ */
+ fun addOutput(toolSearchCall: BetaResponseToolSearchCall) =
+ addOutput(BetaResponseOutputItem.ofToolSearchCall(toolSearchCall))
+
+ /**
+ * Alias for calling [addOutput] with
+ * `BetaResponseOutputItem.ofToolSearchOutput(toolSearchOutput)`.
+ */
+ fun addOutput(toolSearchOutput: BetaResponseToolSearchOutputItem) =
+ addOutput(BetaResponseOutputItem.ofToolSearchOutput(toolSearchOutput))
+
+ /**
+ * Alias for calling [addOutput] with
+ * `BetaResponseOutputItem.ofAdditionalTools(additionalTools)`.
+ */
+ fun addOutput(additionalTools: BetaResponseOutputItem.AdditionalTools) =
+ addOutput(BetaResponseOutputItem.ofAdditionalTools(additionalTools))
+
+ /** Alias for calling [addOutput] with `BetaResponseOutputItem.ofCompaction(compaction)`. */
+ fun addOutput(compaction: BetaResponseCompactionItem) =
+ addOutput(BetaResponseOutputItem.ofCompaction(compaction))
+
+ /**
+ * Alias for calling [addOutput] with
+ * `BetaResponseOutputItem.ofImageGenerationCall(imageGenerationCall)`.
+ */
+ fun addOutput(imageGenerationCall: BetaResponseOutputItem.ImageGenerationCall) =
+ addOutput(BetaResponseOutputItem.ofImageGenerationCall(imageGenerationCall))
+
+ /**
+ * Alias for calling [addOutput] with
+ * `BetaResponseOutputItem.ofCodeInterpreterCall(codeInterpreterCall)`.
+ */
+ fun addOutput(codeInterpreterCall: BetaResponseCodeInterpreterToolCall) =
+ addOutput(BetaResponseOutputItem.ofCodeInterpreterCall(codeInterpreterCall))
+
+ /**
+ * Alias for calling [addOutput] with
+ * `BetaResponseOutputItem.ofLocalShellCall(localShellCall)`.
+ */
+ fun addOutput(localShellCall: BetaResponseOutputItem.LocalShellCall) =
+ addOutput(BetaResponseOutputItem.ofLocalShellCall(localShellCall))
+
+ /**
+ * Alias for calling [addOutput] with
+ * `BetaResponseOutputItem.ofLocalShellCallOutput(localShellCallOutput)`.
+ */
+ fun addOutput(localShellCallOutput: BetaResponseOutputItem.LocalShellCallOutput) =
+ addOutput(BetaResponseOutputItem.ofLocalShellCallOutput(localShellCallOutput))
+
+ /** Alias for calling [addOutput] with `BetaResponseOutputItem.ofShellCall(shellCall)`. */
+ fun addOutput(shellCall: BetaResponseFunctionShellToolCall) =
+ addOutput(BetaResponseOutputItem.ofShellCall(shellCall))
+
+ /**
+ * Alias for calling [addOutput] with
+ * `BetaResponseOutputItem.ofShellCallOutput(shellCallOutput)`.
+ */
+ fun addOutput(shellCallOutput: BetaResponseFunctionShellToolCallOutput) =
+ addOutput(BetaResponseOutputItem.ofShellCallOutput(shellCallOutput))
+
+ /**
+ * Alias for calling [addOutput] with
+ * `BetaResponseOutputItem.ofApplyPatchCall(applyPatchCall)`.
+ */
+ fun addOutput(applyPatchCall: BetaResponseApplyPatchToolCall) =
+ addOutput(BetaResponseOutputItem.ofApplyPatchCall(applyPatchCall))
+
+ /**
+ * Alias for calling [addOutput] with
+ * `BetaResponseOutputItem.ofApplyPatchCallOutput(applyPatchCallOutput)`.
+ */
+ fun addOutput(applyPatchCallOutput: BetaResponseApplyPatchToolCallOutput) =
+ addOutput(BetaResponseOutputItem.ofApplyPatchCallOutput(applyPatchCallOutput))
+
+ /** Alias for calling [addOutput] with `BetaResponseOutputItem.ofMcpCall(mcpCall)`. */
+ fun addOutput(mcpCall: BetaResponseOutputItem.McpCall) =
+ addOutput(BetaResponseOutputItem.ofMcpCall(mcpCall))
+
+ /**
+ * Alias for calling [addOutput] with `BetaResponseOutputItem.ofMcpListTools(mcpListTools)`.
+ */
+ fun addOutput(mcpListTools: BetaResponseOutputItem.McpListTools) =
+ addOutput(BetaResponseOutputItem.ofMcpListTools(mcpListTools))
+
+ /**
+ * Alias for calling [addOutput] with
+ * `BetaResponseOutputItem.ofMcpApprovalRequest(mcpApprovalRequest)`.
+ */
+ fun addOutput(mcpApprovalRequest: BetaResponseOutputItem.McpApprovalRequest) =
+ addOutput(BetaResponseOutputItem.ofMcpApprovalRequest(mcpApprovalRequest))
+
+ /**
+ * Alias for calling [addOutput] with
+ * `BetaResponseOutputItem.ofMcpApprovalResponse(mcpApprovalResponse)`.
+ */
+ fun addOutput(mcpApprovalResponse: BetaResponseOutputItem.McpApprovalResponse) =
+ addOutput(BetaResponseOutputItem.ofMcpApprovalResponse(mcpApprovalResponse))
+
+ /**
+ * Alias for calling [addOutput] with
+ * `BetaResponseOutputItem.ofCustomToolCall(customToolCall)`.
+ */
+ fun addOutput(customToolCall: BetaResponseCustomToolCall) =
+ addOutput(BetaResponseOutputItem.ofCustomToolCall(customToolCall))
+
+ /**
+ * Alias for calling [addOutput] with
+ * `BetaResponseOutputItem.ofCustomToolCallOutput(customToolCallOutput)`.
+ */
+ fun addOutput(customToolCallOutput: BetaResponseCustomToolCallOutputItem) =
+ addOutput(BetaResponseOutputItem.ofCustomToolCallOutput(customToolCallOutput))
+
+ /**
+ * Token accounting for the compaction pass, including cached, reasoning, and total tokens.
+ */
+ fun usage(usage: BetaResponseUsage) = usage(JsonField.of(usage))
+
+ /**
+ * Sets [Builder.usage] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.usage] with a well-typed [BetaResponseUsage] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun usage(usage: JsonField) = apply { this.usage = usage }
+
+ 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 [BetaCompactedResponse].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .id()
+ * .createdAt()
+ * .output()
+ * .usage()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): BetaCompactedResponse =
+ BetaCompactedResponse(
+ checkRequired("id", id),
+ checkRequired("createdAt", createdAt),
+ object_,
+ checkRequired("output", output).map { it.toImmutable() },
+ checkRequired("usage", usage),
+ 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 OpenAIInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): BetaCompactedResponse = apply {
+ if (validated) {
+ return@apply
+ }
+
+ id()
+ createdAt()
+ _object_().let {
+ if (it != JsonValue.from("response.compaction")) {
+ throw OpenAIInvalidDataException("'object_' is invalid, received $it")
+ }
+ }
+ output().forEach { it.validate() }
+ usage().validate()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: OpenAIInvalidDataException) {
+ 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 (id.asKnown().isPresent) 1 else 0) +
+ (if (createdAt.asKnown().isPresent) 1 else 0) +
+ object_.let { if (it == JsonValue.from("response.compaction")) 1 else 0 } +
+ (output.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
+ (usage.asKnown().getOrNull()?.validity() ?: 0)
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is BetaCompactedResponse &&
+ id == other.id &&
+ createdAt == other.createdAt &&
+ object_ == other.object_ &&
+ output == other.output &&
+ usage == other.usage &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy {
+ Objects.hash(id, createdAt, object_, output, usage, additionalProperties)
+ }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "BetaCompactedResponse{id=$id, createdAt=$createdAt, object_=$object_, output=$output, usage=$usage, additionalProperties=$additionalProperties}"
+}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaComputerAction.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaComputerAction.kt
new file mode 100644
index 000000000..b9585d360
--- /dev/null
+++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaComputerAction.kt
@@ -0,0 +1,2881 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.openai.models.beta.responses
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter
+import com.fasterxml.jackson.annotation.JsonAnySetter
+import com.fasterxml.jackson.annotation.JsonCreator
+import com.fasterxml.jackson.annotation.JsonProperty
+import com.fasterxml.jackson.core.JsonGenerator
+import com.fasterxml.jackson.core.ObjectCodec
+import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.SerializerProvider
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize
+import com.fasterxml.jackson.databind.annotation.JsonSerialize
+import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
+import com.openai.core.BaseDeserializer
+import com.openai.core.BaseSerializer
+import com.openai.core.Enum
+import com.openai.core.ExcludeMissing
+import com.openai.core.JsonField
+import com.openai.core.JsonMissing
+import com.openai.core.JsonValue
+import com.openai.core.checkKnown
+import com.openai.core.checkRequired
+import com.openai.core.getOrThrow
+import com.openai.core.toImmutable
+import com.openai.errors.OpenAIInvalidDataException
+import java.util.Collections
+import java.util.Objects
+import java.util.Optional
+import kotlin.jvm.optionals.getOrNull
+
+/** A click action. */
+@JsonDeserialize(using = BetaComputerAction.Deserializer::class)
+@JsonSerialize(using = BetaComputerAction.Serializer::class)
+class BetaComputerAction
+private constructor(
+ private val click: Click? = null,
+ private val doubleClick: DoubleClick? = null,
+ private val drag: Drag? = null,
+ private val keypress: Keypress? = null,
+ private val move: Move? = null,
+ private val screenshot: JsonValue? = null,
+ private val scroll: Scroll? = null,
+ private val type: Type? = null,
+ private val wait: JsonValue? = null,
+ private val _json: JsonValue? = null,
+) {
+
+ /** A click action. */
+ fun click(): Optional = Optional.ofNullable(click)
+
+ /** A double click action. */
+ fun doubleClick(): Optional = Optional.ofNullable(doubleClick)
+
+ /** A drag action. */
+ fun drag(): Optional = Optional.ofNullable(drag)
+
+ /** A collection of keypresses the model would like to perform. */
+ fun keypress(): Optional = Optional.ofNullable(keypress)
+
+ /** A mouse move action. */
+ fun move(): Optional = Optional.ofNullable(move)
+
+ /** A screenshot action. */
+ fun screenshot(): Optional = Optional.ofNullable(screenshot)
+
+ /** A scroll action. */
+ fun scroll(): Optional = Optional.ofNullable(scroll)
+
+ /** An action to type in text. */
+ fun type(): Optional = Optional.ofNullable(type)
+
+ /** A wait action. */
+ fun wait(): Optional = Optional.ofNullable(wait)
+
+ fun isClick(): Boolean = click != null
+
+ fun isDoubleClick(): Boolean = doubleClick != null
+
+ fun isDrag(): Boolean = drag != null
+
+ fun isKeypress(): Boolean = keypress != null
+
+ fun isMove(): Boolean = move != null
+
+ fun isScreenshot(): Boolean = screenshot != null
+
+ fun isScroll(): Boolean = scroll != null
+
+ fun isType(): Boolean = type != null
+
+ fun isWait(): Boolean = wait != null
+
+ /** A click action. */
+ fun asClick(): Click = click.getOrThrow("click")
+
+ /** A double click action. */
+ fun asDoubleClick(): DoubleClick = doubleClick.getOrThrow("doubleClick")
+
+ /** A drag action. */
+ fun asDrag(): Drag = drag.getOrThrow("drag")
+
+ /** A collection of keypresses the model would like to perform. */
+ fun asKeypress(): Keypress = keypress.getOrThrow("keypress")
+
+ /** A mouse move action. */
+ fun asMove(): Move = move.getOrThrow("move")
+
+ /** A screenshot action. */
+ fun asScreenshot(): JsonValue = screenshot.getOrThrow("screenshot")
+
+ /** A scroll action. */
+ fun asScroll(): Scroll = scroll.getOrThrow("scroll")
+
+ /** An action to type in text. */
+ fun asType(): Type = type.getOrThrow("type")
+
+ /** A wait action. */
+ fun asWait(): JsonValue = wait.getOrThrow("wait")
+
+ fun _json(): Optional = Optional.ofNullable(_json)
+
+ /**
+ * Maps this instance's current variant to a value of type [T] using the given [visitor].
+ *
+ * Note that this method is _not_ forwards compatible with new variants from the API, unless
+ * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the
+ * SDK gracefully, consider overriding [Visitor.unknown]:
+ * ```java
+ * import com.openai.core.JsonValue;
+ * import java.util.Optional;
+ *
+ * Optional result = betaComputerAction.accept(new BetaComputerAction.Visitor>() {
+ * @Override
+ * public Optional visitClick(Click click) {
+ * return Optional.of(click.toString());
+ * }
+ *
+ * // ...
+ *
+ * @Override
+ * public Optional unknown(JsonValue json) {
+ * // Or inspect the `json`.
+ * return Optional.empty();
+ * }
+ * });
+ * ```
+ *
+ * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and
+ * the current variant is unknown.
+ */
+ fun accept(visitor: Visitor): T =
+ when {
+ click != null -> visitor.visitClick(click)
+ doubleClick != null -> visitor.visitDoubleClick(doubleClick)
+ drag != null -> visitor.visitDrag(drag)
+ keypress != null -> visitor.visitKeypress(keypress)
+ move != null -> visitor.visitMove(move)
+ screenshot != null -> visitor.visitScreenshot(screenshot)
+ scroll != null -> visitor.visitScroll(scroll)
+ type != null -> visitor.visitType(type)
+ wait != null -> visitor.visitWait(wait)
+ else -> visitor.unknown(_json)
+ }
+
+ 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 OpenAIInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): BetaComputerAction = apply {
+ if (validated) {
+ return@apply
+ }
+
+ accept(
+ object : Visitor {
+ override fun visitClick(click: Click) {
+ click.validate()
+ }
+
+ override fun visitDoubleClick(doubleClick: DoubleClick) {
+ doubleClick.validate()
+ }
+
+ override fun visitDrag(drag: Drag) {
+ drag.validate()
+ }
+
+ override fun visitKeypress(keypress: Keypress) {
+ keypress.validate()
+ }
+
+ override fun visitMove(move: Move) {
+ move.validate()
+ }
+
+ override fun visitScreenshot(screenshot: JsonValue) {
+ screenshot.let {
+ if (it != JsonValue.from(mapOf("type" to "screenshot"))) {
+ throw OpenAIInvalidDataException(
+ "'screenshot' is invalid, received $it"
+ )
+ }
+ }
+ }
+
+ override fun visitScroll(scroll: Scroll) {
+ scroll.validate()
+ }
+
+ override fun visitType(type: Type) {
+ type.validate()
+ }
+
+ override fun visitWait(wait: JsonValue) {
+ wait.let {
+ if (it != JsonValue.from(mapOf("type" to "wait"))) {
+ throw OpenAIInvalidDataException("'wait' is invalid, received $it")
+ }
+ }
+ }
+ }
+ )
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: OpenAIInvalidDataException) {
+ 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 =
+ accept(
+ object : Visitor {
+ override fun visitClick(click: Click) = click.validity()
+
+ override fun visitDoubleClick(doubleClick: DoubleClick) = doubleClick.validity()
+
+ override fun visitDrag(drag: Drag) = drag.validity()
+
+ override fun visitKeypress(keypress: Keypress) = keypress.validity()
+
+ override fun visitMove(move: Move) = move.validity()
+
+ override fun visitScreenshot(screenshot: JsonValue) =
+ screenshot.let {
+ if (it == JsonValue.from(mapOf("type" to "screenshot"))) 1 else 0
+ }
+
+ override fun visitScroll(scroll: Scroll) = scroll.validity()
+
+ override fun visitType(type: Type) = type.validity()
+
+ override fun visitWait(wait: JsonValue) =
+ wait.let { if (it == JsonValue.from(mapOf("type" to "wait"))) 1 else 0 }
+
+ override fun unknown(json: JsonValue?) = 0
+ }
+ )
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is BetaComputerAction &&
+ click == other.click &&
+ doubleClick == other.doubleClick &&
+ drag == other.drag &&
+ keypress == other.keypress &&
+ move == other.move &&
+ screenshot == other.screenshot &&
+ scroll == other.scroll &&
+ type == other.type &&
+ wait == other.wait
+ }
+
+ override fun hashCode(): Int =
+ Objects.hash(click, doubleClick, drag, keypress, move, screenshot, scroll, type, wait)
+
+ override fun toString(): String =
+ when {
+ click != null -> "BetaComputerAction{click=$click}"
+ doubleClick != null -> "BetaComputerAction{doubleClick=$doubleClick}"
+ drag != null -> "BetaComputerAction{drag=$drag}"
+ keypress != null -> "BetaComputerAction{keypress=$keypress}"
+ move != null -> "BetaComputerAction{move=$move}"
+ screenshot != null -> "BetaComputerAction{screenshot=$screenshot}"
+ scroll != null -> "BetaComputerAction{scroll=$scroll}"
+ type != null -> "BetaComputerAction{type=$type}"
+ wait != null -> "BetaComputerAction{wait=$wait}"
+ _json != null -> "BetaComputerAction{_unknown=$_json}"
+ else -> throw IllegalStateException("Invalid BetaComputerAction")
+ }
+
+ companion object {
+
+ /** A click action. */
+ @JvmStatic fun ofClick(click: Click) = BetaComputerAction(click = click)
+
+ /** A double click action. */
+ @JvmStatic
+ fun ofDoubleClick(doubleClick: DoubleClick) = BetaComputerAction(doubleClick = doubleClick)
+
+ /** A drag action. */
+ @JvmStatic fun ofDrag(drag: Drag) = BetaComputerAction(drag = drag)
+
+ /** A collection of keypresses the model would like to perform. */
+ @JvmStatic fun ofKeypress(keypress: Keypress) = BetaComputerAction(keypress = keypress)
+
+ /** A mouse move action. */
+ @JvmStatic fun ofMove(move: Move) = BetaComputerAction(move = move)
+
+ /** A screenshot action. */
+ @JvmStatic
+ fun ofScreenshot() =
+ BetaComputerAction(screenshot = JsonValue.from(mapOf("type" to "screenshot")))
+
+ /** A scroll action. */
+ @JvmStatic fun ofScroll(scroll: Scroll) = BetaComputerAction(scroll = scroll)
+
+ /** An action to type in text. */
+ @JvmStatic fun ofType(type: Type) = BetaComputerAction(type = type)
+
+ /** A wait action. */
+ @JvmStatic fun ofWait() = BetaComputerAction(wait = JsonValue.from(mapOf("type" to "wait")))
+ }
+
+ /**
+ * An interface that defines how to map each variant of [BetaComputerAction] to a value of type
+ * [T].
+ */
+ interface Visitor {
+
+ /** A click action. */
+ fun visitClick(click: Click): T
+
+ /** A double click action. */
+ fun visitDoubleClick(doubleClick: DoubleClick): T
+
+ /** A drag action. */
+ fun visitDrag(drag: Drag): T
+
+ /** A collection of keypresses the model would like to perform. */
+ fun visitKeypress(keypress: Keypress): T
+
+ /** A mouse move action. */
+ fun visitMove(move: Move): T
+
+ /** A screenshot action. */
+ fun visitScreenshot(screenshot: JsonValue): T
+
+ /** A scroll action. */
+ fun visitScroll(scroll: Scroll): T
+
+ /** An action to type in text. */
+ fun visitType(type: Type): T
+
+ /** A wait action. */
+ fun visitWait(wait: JsonValue): T
+
+ /**
+ * Maps an unknown variant of [BetaComputerAction] to a value of type [T].
+ *
+ * An instance of [BetaComputerAction] can contain an unknown variant if it was deserialized
+ * from data that doesn't match any known variant. For example, if the SDK is on an older
+ * version than the API, then the API may respond with new variants that the SDK is unaware
+ * of.
+ *
+ * @throws OpenAIInvalidDataException in the default implementation.
+ */
+ fun unknown(json: JsonValue?): T {
+ throw OpenAIInvalidDataException("Unknown BetaComputerAction: $json")
+ }
+ }
+
+ internal class Deserializer : BaseDeserializer(BetaComputerAction::class) {
+
+ override fun ObjectCodec.deserialize(node: JsonNode): BetaComputerAction {
+ val json = JsonValue.fromJsonNode(node)
+ val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull()
+
+ when (type) {
+ "click" -> {
+ return tryDeserialize(node, jacksonTypeRef())?.let {
+ BetaComputerAction(click = it, _json = json)
+ } ?: BetaComputerAction(_json = json)
+ }
+ "double_click" -> {
+ return tryDeserialize(node, jacksonTypeRef())?.let {
+ BetaComputerAction(doubleClick = it, _json = json)
+ } ?: BetaComputerAction(_json = json)
+ }
+ "drag" -> {
+ return tryDeserialize(node, jacksonTypeRef())?.let {
+ BetaComputerAction(drag = it, _json = json)
+ } ?: BetaComputerAction(_json = json)
+ }
+ "keypress" -> {
+ return tryDeserialize(node, jacksonTypeRef())?.let {
+ BetaComputerAction(keypress = it, _json = json)
+ } ?: BetaComputerAction(_json = json)
+ }
+ "move" -> {
+ return tryDeserialize(node, jacksonTypeRef())?.let {
+ BetaComputerAction(move = it, _json = json)
+ } ?: BetaComputerAction(_json = json)
+ }
+ "screenshot" -> {
+ return tryDeserialize(node, jacksonTypeRef())
+ ?.let { BetaComputerAction(screenshot = it, _json = json) }
+ ?.takeIf { it.isValid() } ?: BetaComputerAction(_json = json)
+ }
+ "scroll" -> {
+ return tryDeserialize(node, jacksonTypeRef())?.let {
+ BetaComputerAction(scroll = it, _json = json)
+ } ?: BetaComputerAction(_json = json)
+ }
+ "type" -> {
+ return tryDeserialize(node, jacksonTypeRef())?.let {
+ BetaComputerAction(type = it, _json = json)
+ } ?: BetaComputerAction(_json = json)
+ }
+ "wait" -> {
+ return tryDeserialize(node, jacksonTypeRef())
+ ?.let { BetaComputerAction(wait = it, _json = json) }
+ ?.takeIf { it.isValid() } ?: BetaComputerAction(_json = json)
+ }
+ }
+
+ return BetaComputerAction(_json = json)
+ }
+ }
+
+ internal class Serializer : BaseSerializer(BetaComputerAction::class) {
+
+ override fun serialize(
+ value: BetaComputerAction,
+ generator: JsonGenerator,
+ provider: SerializerProvider,
+ ) {
+ when {
+ value.click != null -> generator.writeObject(value.click)
+ value.doubleClick != null -> generator.writeObject(value.doubleClick)
+ value.drag != null -> generator.writeObject(value.drag)
+ value.keypress != null -> generator.writeObject(value.keypress)
+ value.move != null -> generator.writeObject(value.move)
+ value.screenshot != null -> generator.writeObject(value.screenshot)
+ value.scroll != null -> generator.writeObject(value.scroll)
+ value.type != null -> generator.writeObject(value.type)
+ value.wait != null -> generator.writeObject(value.wait)
+ value._json != null -> generator.writeObject(value._json)
+ else -> throw IllegalStateException("Invalid BetaComputerAction")
+ }
+ }
+ }
+
+ /** A click action. */
+ class Click
+ @JsonCreator(mode = JsonCreator.Mode.DISABLED)
+ private constructor(
+ private val button: JsonField