diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 141929c0..f3ab3a80 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "4.25.0"
+ ".": "4.26.0"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index 2e994a70..ccceab37 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 147
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-9c802d45a9bf2a896b5fd22ac22bba185e8a145bd40ed242df9bb87a05e954eb.yml
openapi_spec_hash: 97984ed69285e660b7d5c810c69ed449
-config_hash: acb0b1eb5d7284bfedaddb29f7f5a691
+config_hash: 8240b8a7a7fc145a45b93bda435612d6
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5f979247..241ac288 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,18 @@
# Changelog
+## 4.26.0 (2026-03-05)
+
+Full Changelog: [v4.25.0...v4.26.0](https://github.com/openai/openai-java/compare/v4.25.0...v4.26.0)
+
+### Features
+
+* **api:** The GA ComputerTool now uses the CompuerTool class. The 'computer_use_preview' tool is moved to ComputerUsePreview ([a8d8de8](https://github.com/openai/openai-java/commit/a8d8de803d9df873eb13ecd912cdea096532a062))
+
+
+### Bug Fixes
+
+* **api:** update structured response tool overloads ([5562fc1](https://github.com/openai/openai-java/commit/5562fc13a259d567aa03c59f36e74825effa53da))
+
## 4.25.0 (2026-03-05)
Full Changelog: [v4.24.1...v4.25.0](https://github.com/openai/openai-java/compare/v4.24.1...v4.25.0)
diff --git a/README.md b/README.md
index 21d3f965..c95df5d7 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,8 @@
-[](https://central.sonatype.com/artifact/com.openai/openai-java/4.25.0)
-[](https://javadoc.io/doc/com.openai/openai-java/4.25.0)
+[](https://central.sonatype.com/artifact/com.openai/openai-java/4.26.0)
+[](https://javadoc.io/doc/com.openai/openai-java/4.26.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.25.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.26.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.25.0")
+implementation("com.openai:openai-java:4.26.0")
```
### Maven
@@ -33,7 +33,7 @@ implementation("com.openai:openai-java:4.25.0")
com.openai
openai-java
- 4.25.0
+ 4.26.0
```
@@ -1342,7 +1342,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.25.0")
+implementation("com.openai:openai-java-spring-boot-starter:4.26.0")
```
#### Maven
@@ -1351,7 +1351,7 @@ implementation("com.openai:openai-java-spring-boot-starter:4.25.0")
com.openai
openai-java-spring-boot-starter
- 4.25.0
+ 4.26.0
```
diff --git a/build.gradle.kts b/build.gradle.kts
index 7fe32ceb..7796e489 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -8,7 +8,7 @@ repositories {
allprojects {
group = "com.openai"
- version = "4.25.0" // x-release-please-version
+ version = "4.26.0" // x-release-please-version
}
subprojects {
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt
index 77e8ecc3..310b9b65 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt
@@ -32,7 +32,7 @@ import com.openai.models.ResponseFormatText
import com.openai.models.graders.gradermodels.EvalContentItem
import com.openai.models.responses.ApplyPatchTool
import com.openai.models.responses.ComputerTool
-import com.openai.models.responses.ComputerUseTool
+import com.openai.models.responses.ComputerUsePreviewTool
import com.openai.models.responses.CustomTool
import com.openai.models.responses.FileSearchTool
import com.openai.models.responses.FunctionShellTool
@@ -6383,13 +6383,13 @@ private constructor(
addTool(FileSearchTool.builder().vectorStoreIds(vectorStoreIds).build())
/** Alias for calling [addTool] with `Tool.ofComputer(computer)`. */
- fun addTool(computer: ComputerUseTool) = addTool(Tool.ofComputer(computer))
+ fun addTool(computer: ComputerTool) = addTool(Tool.ofComputer(computer))
/**
* Alias for calling [addTool] with
* `Tool.ofComputerUsePreview(computerUsePreview)`.
*/
- fun addTool(computerUsePreview: ComputerTool) =
+ fun addTool(computerUsePreview: ComputerUsePreviewTool) =
addTool(Tool.ofComputerUsePreview(computerUsePreview))
/** Alias for calling [addTool] with `Tool.ofWebSearch(webSearch)`. */
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt
index 7987b436..a4cfb63a 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt
@@ -35,7 +35,7 @@ import com.openai.models.ResponseFormatText
import com.openai.models.graders.gradermodels.EvalContentItem
import com.openai.models.responses.ApplyPatchTool
import com.openai.models.responses.ComputerTool
-import com.openai.models.responses.ComputerUseTool
+import com.openai.models.responses.ComputerUsePreviewTool
import com.openai.models.responses.CustomTool
import com.openai.models.responses.FileSearchTool
import com.openai.models.responses.FunctionShellTool
@@ -6268,13 +6268,13 @@ private constructor(
addTool(FileSearchTool.builder().vectorStoreIds(vectorStoreIds).build())
/** Alias for calling [addTool] with `Tool.ofComputer(computer)`. */
- fun addTool(computer: ComputerUseTool) = addTool(Tool.ofComputer(computer))
+ fun addTool(computer: ComputerTool) = addTool(Tool.ofComputer(computer))
/**
* Alias for calling [addTool] with
* `Tool.ofComputerUsePreview(computerUsePreview)`.
*/
- fun addTool(computerUsePreview: ComputerTool) =
+ fun addTool(computerUsePreview: ComputerUsePreviewTool) =
addTool(Tool.ofComputerUsePreview(computerUsePreview))
/** Alias for calling [addTool] with `Tool.ofWebSearch(webSearch)`. */
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt
index 5ea1b847..7908c481 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt
@@ -32,7 +32,7 @@ import com.openai.models.ResponseFormatText
import com.openai.models.graders.gradermodels.EvalContentItem
import com.openai.models.responses.ApplyPatchTool
import com.openai.models.responses.ComputerTool
-import com.openai.models.responses.ComputerUseTool
+import com.openai.models.responses.ComputerUsePreviewTool
import com.openai.models.responses.CustomTool
import com.openai.models.responses.FileSearchTool
import com.openai.models.responses.FunctionShellTool
@@ -6383,13 +6383,13 @@ private constructor(
addTool(FileSearchTool.builder().vectorStoreIds(vectorStoreIds).build())
/** Alias for calling [addTool] with `Tool.ofComputer(computer)`. */
- fun addTool(computer: ComputerUseTool) = addTool(Tool.ofComputer(computer))
+ fun addTool(computer: ComputerTool) = addTool(Tool.ofComputer(computer))
/**
* Alias for calling [addTool] with
* `Tool.ofComputerUsePreview(computerUsePreview)`.
*/
- fun addTool(computerUsePreview: ComputerTool) =
+ fun addTool(computerUsePreview: ComputerUsePreviewTool) =
addTool(Tool.ofComputerUsePreview(computerUsePreview))
/** Alias for calling [addTool] with `Tool.ofWebSearch(webSearch)`. */
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt
index 4ea2fcb3..1bba7278 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt
@@ -32,7 +32,7 @@ import com.openai.models.ResponseFormatText
import com.openai.models.graders.gradermodels.EvalContentItem
import com.openai.models.responses.ApplyPatchTool
import com.openai.models.responses.ComputerTool
-import com.openai.models.responses.ComputerUseTool
+import com.openai.models.responses.ComputerUsePreviewTool
import com.openai.models.responses.CustomTool
import com.openai.models.responses.FileSearchTool
import com.openai.models.responses.FunctionShellTool
@@ -6383,13 +6383,13 @@ private constructor(
addTool(FileSearchTool.builder().vectorStoreIds(vectorStoreIds).build())
/** Alias for calling [addTool] with `Tool.ofComputer(computer)`. */
- fun addTool(computer: ComputerUseTool) = addTool(Tool.ofComputer(computer))
+ fun addTool(computer: ComputerTool) = addTool(Tool.ofComputer(computer))
/**
* Alias for calling [addTool] with
* `Tool.ofComputerUsePreview(computerUsePreview)`.
*/
- fun addTool(computerUsePreview: ComputerTool) =
+ fun addTool(computerUsePreview: ComputerUsePreviewTool) =
addTool(Tool.ofComputerUsePreview(computerUsePreview))
/** Alias for calling [addTool] with `Tool.ofWebSearch(webSearch)`. */
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt
index c13a0eaf..a0456b58 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt
@@ -32,7 +32,7 @@ import com.openai.models.ResponseFormatText
import com.openai.models.graders.gradermodels.EvalContentItem
import com.openai.models.responses.ApplyPatchTool
import com.openai.models.responses.ComputerTool
-import com.openai.models.responses.ComputerUseTool
+import com.openai.models.responses.ComputerUsePreviewTool
import com.openai.models.responses.CustomTool
import com.openai.models.responses.FileSearchTool
import com.openai.models.responses.FunctionShellTool
@@ -6383,13 +6383,13 @@ private constructor(
addTool(FileSearchTool.builder().vectorStoreIds(vectorStoreIds).build())
/** Alias for calling [addTool] with `Tool.ofComputer(computer)`. */
- fun addTool(computer: ComputerUseTool) = addTool(Tool.ofComputer(computer))
+ fun addTool(computer: ComputerTool) = addTool(Tool.ofComputer(computer))
/**
* Alias for calling [addTool] with
* `Tool.ofComputerUsePreview(computerUsePreview)`.
*/
- fun addTool(computerUsePreview: ComputerTool) =
+ fun addTool(computerUsePreview: ComputerUsePreviewTool) =
addTool(Tool.ofComputerUsePreview(computerUsePreview))
/** Alias for calling [addTool] with `Tool.ofWebSearch(webSearch)`. */
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ComputerTool.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ComputerTool.kt
index 9628870f..ec857f56 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ComputerTool.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ComputerTool.kt
@@ -6,16 +6,12 @@ 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.checkRequired
import com.openai.errors.OpenAIInvalidDataException
import java.util.Collections
import java.util.Objects
-import kotlin.jvm.optionals.getOrNull
/**
* A tool that controls a virtual computer. Learn more about the
@@ -24,57 +20,21 @@ import kotlin.jvm.optionals.getOrNull
class ComputerTool
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
private constructor(
- private val displayHeight: JsonField,
- private val displayWidth: JsonField,
- private val environment: JsonField,
private val type: JsonValue,
private val additionalProperties: MutableMap,
) {
@JsonCreator
private constructor(
- @JsonProperty("display_height")
- @ExcludeMissing
- displayHeight: JsonField = JsonMissing.of(),
- @JsonProperty("display_width")
- @ExcludeMissing
- displayWidth: JsonField = JsonMissing.of(),
- @JsonProperty("environment")
- @ExcludeMissing
- environment: JsonField = JsonMissing.of(),
- @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(),
- ) : this(displayHeight, displayWidth, environment, type, mutableMapOf())
+ @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of()
+ ) : this(type, mutableMapOf())
/**
- * The height of the computer display.
- *
- * @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 displayHeight(): Long = displayHeight.getRequired("display_height")
-
- /**
- * The width of the computer display.
- *
- * @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 displayWidth(): Long = displayWidth.getRequired("display_width")
-
- /**
- * The type of computer environment to control.
- *
- * @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 environment(): Environment = environment.getRequired("environment")
-
- /**
- * The type of the computer use tool. Always `computer_use_preview`.
+ * The type of the computer tool. Always `computer`.
*
* Expected to always return the following:
* ```java
- * JsonValue.from("computer_use_preview")
+ * JsonValue.from("computer")
* ```
*
* However, this method can be useful for debugging and logging (e.g. if the server responded
@@ -82,33 +42,6 @@ private constructor(
*/
@JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type
- /**
- * Returns the raw JSON value of [displayHeight].
- *
- * Unlike [displayHeight], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("display_height")
- @ExcludeMissing
- fun _displayHeight(): JsonField = displayHeight
-
- /**
- * Returns the raw JSON value of [displayWidth].
- *
- * Unlike [displayWidth], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("display_width")
- @ExcludeMissing
- fun _displayWidth(): JsonField = displayWidth
-
- /**
- * Returns the raw JSON value of [environment].
- *
- * Unlike [environment], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("environment")
- @ExcludeMissing
- fun _environment(): JsonField = environment
-
@JsonAnySetter
private fun putAdditionalProperty(key: String, value: JsonValue) {
additionalProperties.put(key, value)
@@ -123,84 +56,29 @@ private constructor(
companion object {
- /**
- * Returns a mutable builder for constructing an instance of [ComputerTool].
- *
- * The following fields are required:
- * ```java
- * .displayHeight()
- * .displayWidth()
- * .environment()
- * ```
- */
+ /** Returns a mutable builder for constructing an instance of [ComputerTool]. */
@JvmStatic fun builder() = Builder()
}
/** A builder for [ComputerTool]. */
class Builder internal constructor() {
- private var displayHeight: JsonField? = null
- private var displayWidth: JsonField? = null
- private var environment: JsonField? = null
- private var type: JsonValue = JsonValue.from("computer_use_preview")
+ private var type: JsonValue = JsonValue.from("computer")
private var additionalProperties: MutableMap = mutableMapOf()
@JvmSynthetic
internal fun from(computerTool: ComputerTool) = apply {
- displayHeight = computerTool.displayHeight
- displayWidth = computerTool.displayWidth
- environment = computerTool.environment
type = computerTool.type
additionalProperties = computerTool.additionalProperties.toMutableMap()
}
- /** The height of the computer display. */
- fun displayHeight(displayHeight: Long) = displayHeight(JsonField.of(displayHeight))
-
- /**
- * Sets [Builder.displayHeight] to an arbitrary JSON value.
- *
- * You should usually call [Builder.displayHeight] with a well-typed [Long] value instead.
- * This method is primarily for setting the field to an undocumented or not yet supported
- * value.
- */
- fun displayHeight(displayHeight: JsonField) = apply {
- this.displayHeight = displayHeight
- }
-
- /** The width of the computer display. */
- fun displayWidth(displayWidth: Long) = displayWidth(JsonField.of(displayWidth))
-
- /**
- * Sets [Builder.displayWidth] to an arbitrary JSON value.
- *
- * You should usually call [Builder.displayWidth] with a well-typed [Long] value instead.
- * This method is primarily for setting the field to an undocumented or not yet supported
- * value.
- */
- fun displayWidth(displayWidth: JsonField) = apply { this.displayWidth = displayWidth }
-
- /** The type of computer environment to control. */
- fun environment(environment: Environment) = environment(JsonField.of(environment))
-
- /**
- * Sets [Builder.environment] to an arbitrary JSON value.
- *
- * You should usually call [Builder.environment] with a well-typed [Environment] value
- * instead. This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun environment(environment: JsonField) = apply {
- this.environment = environment
- }
-
/**
* 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("computer_use_preview")
+ * JsonValue.from("computer")
* ```
*
* This method is primarily for setting the field to an undocumented or not yet supported
@@ -231,24 +109,8 @@ private constructor(
* Returns an immutable instance of [ComputerTool].
*
* Further updates to this [Builder] will not mutate the returned instance.
- *
- * The following fields are required:
- * ```java
- * .displayHeight()
- * .displayWidth()
- * .environment()
- * ```
- *
- * @throws IllegalStateException if any required field is unset.
*/
- fun build(): ComputerTool =
- ComputerTool(
- checkRequired("displayHeight", displayHeight),
- checkRequired("displayWidth", displayWidth),
- checkRequired("environment", environment),
- type,
- additionalProperties.toMutableMap(),
- )
+ fun build(): ComputerTool = ComputerTool(type, additionalProperties.toMutableMap())
}
private var validated: Boolean = false
@@ -258,11 +120,8 @@ private constructor(
return@apply
}
- displayHeight()
- displayWidth()
- environment().validate()
_type().let {
- if (it != JsonValue.from("computer_use_preview")) {
+ if (it != JsonValue.from("computer")) {
throw OpenAIInvalidDataException("'type' is invalid, received $it")
}
}
@@ -283,158 +142,7 @@ private constructor(
* Used for best match union deserialization.
*/
@JvmSynthetic
- internal fun validity(): Int =
- (if (displayHeight.asKnown().isPresent) 1 else 0) +
- (if (displayWidth.asKnown().isPresent) 1 else 0) +
- (environment.asKnown().getOrNull()?.validity() ?: 0) +
- type.let { if (it == JsonValue.from("computer_use_preview")) 1 else 0 }
-
- /** The type of computer environment to control. */
- class Environment @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 WINDOWS = of("windows")
-
- @JvmField val MAC = of("mac")
-
- @JvmField val LINUX = of("linux")
-
- @JvmField val UBUNTU = of("ubuntu")
-
- @JvmField val BROWSER = of("browser")
-
- @JvmStatic fun of(value: String) = Environment(JsonField.of(value))
- }
-
- /** An enum containing [Environment]'s known values. */
- enum class Known {
- WINDOWS,
- MAC,
- LINUX,
- UBUNTU,
- BROWSER,
- }
-
- /**
- * An enum containing [Environment]'s known values, as well as an [_UNKNOWN] member.
- *
- * An instance of [Environment] 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 {
- WINDOWS,
- MAC,
- LINUX,
- UBUNTU,
- BROWSER,
- /**
- * An enum member indicating that [Environment] 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) {
- WINDOWS -> Value.WINDOWS
- MAC -> Value.MAC
- LINUX -> Value.LINUX
- UBUNTU -> Value.UBUNTU
- BROWSER -> Value.BROWSER
- 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) {
- WINDOWS -> Known.WINDOWS
- MAC -> Known.MAC
- LINUX -> Known.LINUX
- UBUNTU -> Known.UBUNTU
- BROWSER -> Known.BROWSER
- else -> throw OpenAIInvalidDataException("Unknown Environment: $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
-
- fun validate(): Environment = 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 Environment && value == other.value
- }
-
- override fun hashCode() = value.hashCode()
-
- override fun toString() = value.toString()
- }
+ internal fun validity(): Int = type.let { if (it == JsonValue.from("computer")) 1 else 0 }
override fun equals(other: Any?): Boolean {
if (this === other) {
@@ -442,19 +150,13 @@ private constructor(
}
return other is ComputerTool &&
- displayHeight == other.displayHeight &&
- displayWidth == other.displayWidth &&
- environment == other.environment &&
type == other.type &&
additionalProperties == other.additionalProperties
}
- private val hashCode: Int by lazy {
- Objects.hash(displayHeight, displayWidth, environment, type, additionalProperties)
- }
+ private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) }
override fun hashCode(): Int = hashCode
- override fun toString() =
- "ComputerTool{displayHeight=$displayHeight, displayWidth=$displayWidth, environment=$environment, type=$type, additionalProperties=$additionalProperties}"
+ override fun toString() = "ComputerTool{type=$type, additionalProperties=$additionalProperties}"
}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ComputerUsePreviewTool.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ComputerUsePreviewTool.kt
new file mode 100644
index 00000000..ca5da959
--- /dev/null
+++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ComputerUsePreviewTool.kt
@@ -0,0 +1,460 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.openai.models.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.checkRequired
+import com.openai.errors.OpenAIInvalidDataException
+import java.util.Collections
+import java.util.Objects
+import kotlin.jvm.optionals.getOrNull
+
+/**
+ * A tool that controls a virtual computer. Learn more about the
+ * [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
+ */
+class ComputerUsePreviewTool
+@JsonCreator(mode = JsonCreator.Mode.DISABLED)
+private constructor(
+ private val displayHeight: JsonField,
+ private val displayWidth: JsonField,
+ private val environment: JsonField,
+ private val type: JsonValue,
+ private val additionalProperties: MutableMap,
+) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("display_height")
+ @ExcludeMissing
+ displayHeight: JsonField = JsonMissing.of(),
+ @JsonProperty("display_width")
+ @ExcludeMissing
+ displayWidth: JsonField = JsonMissing.of(),
+ @JsonProperty("environment")
+ @ExcludeMissing
+ environment: JsonField = JsonMissing.of(),
+ @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(),
+ ) : this(displayHeight, displayWidth, environment, type, mutableMapOf())
+
+ /**
+ * The height of the computer display.
+ *
+ * @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 displayHeight(): Long = displayHeight.getRequired("display_height")
+
+ /**
+ * The width of the computer display.
+ *
+ * @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 displayWidth(): Long = displayWidth.getRequired("display_width")
+
+ /**
+ * The type of computer environment to control.
+ *
+ * @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 environment(): Environment = environment.getRequired("environment")
+
+ /**
+ * The type of the computer use tool. Always `computer_use_preview`.
+ *
+ * Expected to always return the following:
+ * ```java
+ * JsonValue.from("computer_use_preview")
+ * ```
+ *
+ * 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 [displayHeight].
+ *
+ * Unlike [displayHeight], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("display_height")
+ @ExcludeMissing
+ fun _displayHeight(): JsonField = displayHeight
+
+ /**
+ * Returns the raw JSON value of [displayWidth].
+ *
+ * Unlike [displayWidth], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("display_width")
+ @ExcludeMissing
+ fun _displayWidth(): JsonField = displayWidth
+
+ /**
+ * Returns the raw JSON value of [environment].
+ *
+ * Unlike [environment], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("environment")
+ @ExcludeMissing
+ fun _environment(): JsonField = environment
+
+ @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 [ComputerUsePreviewTool].
+ *
+ * The following fields are required:
+ * ```java
+ * .displayHeight()
+ * .displayWidth()
+ * .environment()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [ComputerUsePreviewTool]. */
+ class Builder internal constructor() {
+
+ private var displayHeight: JsonField? = null
+ private var displayWidth: JsonField? = null
+ private var environment: JsonField? = null
+ private var type: JsonValue = JsonValue.from("computer_use_preview")
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(computerUsePreviewTool: ComputerUsePreviewTool) = apply {
+ displayHeight = computerUsePreviewTool.displayHeight
+ displayWidth = computerUsePreviewTool.displayWidth
+ environment = computerUsePreviewTool.environment
+ type = computerUsePreviewTool.type
+ additionalProperties = computerUsePreviewTool.additionalProperties.toMutableMap()
+ }
+
+ /** The height of the computer display. */
+ fun displayHeight(displayHeight: Long) = displayHeight(JsonField.of(displayHeight))
+
+ /**
+ * Sets [Builder.displayHeight] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.displayHeight] with a well-typed [Long] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet supported
+ * value.
+ */
+ fun displayHeight(displayHeight: JsonField) = apply {
+ this.displayHeight = displayHeight
+ }
+
+ /** The width of the computer display. */
+ fun displayWidth(displayWidth: Long) = displayWidth(JsonField.of(displayWidth))
+
+ /**
+ * Sets [Builder.displayWidth] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.displayWidth] with a well-typed [Long] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet supported
+ * value.
+ */
+ fun displayWidth(displayWidth: JsonField) = apply { this.displayWidth = displayWidth }
+
+ /** The type of computer environment to control. */
+ fun environment(environment: Environment) = environment(JsonField.of(environment))
+
+ /**
+ * Sets [Builder.environment] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.environment] with a well-typed [Environment] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun environment(environment: JsonField) = apply {
+ this.environment = environment
+ }
+
+ /**
+ * 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("computer_use_preview")
+ * ```
+ *
+ * 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 [ComputerUsePreviewTool].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .displayHeight()
+ * .displayWidth()
+ * .environment()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): ComputerUsePreviewTool =
+ ComputerUsePreviewTool(
+ checkRequired("displayHeight", displayHeight),
+ checkRequired("displayWidth", displayWidth),
+ checkRequired("environment", environment),
+ type,
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): ComputerUsePreviewTool = apply {
+ if (validated) {
+ return@apply
+ }
+
+ displayHeight()
+ displayWidth()
+ environment().validate()
+ _type().let {
+ if (it != JsonValue.from("computer_use_preview")) {
+ throw OpenAIInvalidDataException("'type' 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 =
+ (if (displayHeight.asKnown().isPresent) 1 else 0) +
+ (if (displayWidth.asKnown().isPresent) 1 else 0) +
+ (environment.asKnown().getOrNull()?.validity() ?: 0) +
+ type.let { if (it == JsonValue.from("computer_use_preview")) 1 else 0 }
+
+ /** The type of computer environment to control. */
+ class Environment @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 WINDOWS = of("windows")
+
+ @JvmField val MAC = of("mac")
+
+ @JvmField val LINUX = of("linux")
+
+ @JvmField val UBUNTU = of("ubuntu")
+
+ @JvmField val BROWSER = of("browser")
+
+ @JvmStatic fun of(value: String) = Environment(JsonField.of(value))
+ }
+
+ /** An enum containing [Environment]'s known values. */
+ enum class Known {
+ WINDOWS,
+ MAC,
+ LINUX,
+ UBUNTU,
+ BROWSER,
+ }
+
+ /**
+ * An enum containing [Environment]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [Environment] 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 {
+ WINDOWS,
+ MAC,
+ LINUX,
+ UBUNTU,
+ BROWSER,
+ /**
+ * An enum member indicating that [Environment] 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) {
+ WINDOWS -> Value.WINDOWS
+ MAC -> Value.MAC
+ LINUX -> Value.LINUX
+ UBUNTU -> Value.UBUNTU
+ BROWSER -> Value.BROWSER
+ 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) {
+ WINDOWS -> Known.WINDOWS
+ MAC -> Known.MAC
+ LINUX -> Known.LINUX
+ UBUNTU -> Known.UBUNTU
+ BROWSER -> Known.BROWSER
+ else -> throw OpenAIInvalidDataException("Unknown Environment: $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
+
+ fun validate(): Environment = 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 Environment && 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 ComputerUsePreviewTool &&
+ displayHeight == other.displayHeight &&
+ displayWidth == other.displayWidth &&
+ environment == other.environment &&
+ type == other.type &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy {
+ Objects.hash(displayHeight, displayWidth, environment, type, additionalProperties)
+ }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "ComputerUsePreviewTool{displayHeight=$displayHeight, displayWidth=$displayWidth, environment=$environment, type=$type, additionalProperties=$additionalProperties}"
+}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ComputerUseTool.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ComputerUseTool.kt
deleted file mode 100644
index 3fe4111c..00000000
--- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ComputerUseTool.kt
+++ /dev/null
@@ -1,163 +0,0 @@
-// File generated from our OpenAPI spec by Stainless.
-
-package com.openai.models.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.JsonMissing
-import com.openai.core.JsonValue
-import com.openai.errors.OpenAIInvalidDataException
-import java.util.Collections
-import java.util.Objects
-
-/**
- * A tool that controls a virtual computer. Learn more about the
- * [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
- */
-class ComputerUseTool
-@JsonCreator(mode = JsonCreator.Mode.DISABLED)
-private constructor(
- private val type: JsonValue,
- private val additionalProperties: MutableMap,
-) {
-
- @JsonCreator
- private constructor(
- @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of()
- ) : this(type, mutableMapOf())
-
- /**
- * The type of the computer tool. Always `computer`.
- *
- * Expected to always return the following:
- * ```java
- * JsonValue.from("computer")
- * ```
- *
- * 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
-
- @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 [ComputerUseTool]. */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [ComputerUseTool]. */
- class Builder internal constructor() {
-
- private var type: JsonValue = JsonValue.from("computer")
- private var additionalProperties: MutableMap = mutableMapOf()
-
- @JvmSynthetic
- internal fun from(computerUseTool: ComputerUseTool) = apply {
- type = computerUseTool.type
- additionalProperties = computerUseTool.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("computer")
- * ```
- *
- * 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 [ComputerUseTool].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- */
- fun build(): ComputerUseTool = ComputerUseTool(type, additionalProperties.toMutableMap())
- }
-
- private var validated: Boolean = false
-
- fun validate(): ComputerUseTool = apply {
- if (validated) {
- return@apply
- }
-
- _type().let {
- if (it != JsonValue.from("computer")) {
- throw OpenAIInvalidDataException("'type' 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 = type.let { if (it == JsonValue.from("computer")) 1 else 0 }
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return other is ComputerUseTool &&
- type == other.type &&
- additionalProperties == other.additionalProperties
- }
-
- private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) }
-
- override fun hashCode(): Int = hashCode
-
- override fun toString() =
- "ComputerUseTool{type=$type, additionalProperties=$additionalProperties}"
-}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/Response.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/Response.kt
index 5e6f7472..5cb6d21b 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/responses/Response.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/Response.kt
@@ -1336,10 +1336,10 @@ private constructor(
addTool(FileSearchTool.builder().vectorStoreIds(vectorStoreIds).build())
/** Alias for calling [addTool] with `Tool.ofComputer(computer)`. */
- fun addTool(computer: ComputerUseTool) = addTool(Tool.ofComputer(computer))
+ fun addTool(computer: ComputerTool) = addTool(Tool.ofComputer(computer))
/** Alias for calling [addTool] with `Tool.ofComputerUsePreview(computerUsePreview)`. */
- fun addTool(computerUsePreview: ComputerTool) =
+ fun addTool(computerUsePreview: ComputerUsePreviewTool) =
addTool(Tool.ofComputerUsePreview(computerUsePreview))
/** Alias for calling [addTool] with `Tool.ofWebSearch(webSearch)`. */
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt
index 01862e49..f1116557 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt
@@ -1333,10 +1333,12 @@ private constructor(
}
/** Alias for calling [addTool] with `Tool.ofComputer(computer)`. */
- fun addTool(computer: ComputerUseTool) = apply { body.addTool(computer) }
+ fun addTool(computer: ComputerTool) = apply { body.addTool(computer) }
/** Alias for calling [addTool] with `Tool.ofComputerUsePreview(computerUsePreview)`. */
- fun addTool(computerUsePreview: ComputerTool) = apply { body.addTool(computerUsePreview) }
+ fun addTool(computerUsePreview: ComputerUsePreviewTool) = apply {
+ body.addTool(computerUsePreview)
+ }
/** Alias for calling [addTool] with `Tool.ofWebSearch(webSearch)`. */
fun addTool(webSearch: WebSearchTool) = apply { body.addTool(webSearch) }
@@ -3133,10 +3135,10 @@ private constructor(
addTool(FileSearchTool.builder().vectorStoreIds(vectorStoreIds).build())
/** Alias for calling [addTool] with `Tool.ofComputer(computer)`. */
- fun addTool(computer: ComputerUseTool) = addTool(Tool.ofComputer(computer))
+ fun addTool(computer: ComputerTool) = addTool(Tool.ofComputer(computer))
/** Alias for calling [addTool] with `Tool.ofComputerUsePreview(computerUsePreview)`. */
- fun addTool(computerUsePreview: ComputerTool) =
+ fun addTool(computerUsePreview: ComputerUsePreviewTool) =
addTool(Tool.ofComputerUsePreview(computerUsePreview))
/** Alias for calling [addTool] with `Tool.ofWebSearch(webSearch)`. */
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseToolSearchOutputItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseToolSearchOutputItem.kt
index 05c1f21c..a0a48c05 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseToolSearchOutputItem.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseToolSearchOutputItem.kt
@@ -292,10 +292,10 @@ private constructor(
addTool(FileSearchTool.builder().vectorStoreIds(vectorStoreIds).build())
/** Alias for calling [addTool] with `Tool.ofComputer(computer)`. */
- fun addTool(computer: ComputerUseTool) = addTool(Tool.ofComputer(computer))
+ fun addTool(computer: ComputerTool) = addTool(Tool.ofComputer(computer))
/** Alias for calling [addTool] with `Tool.ofComputerUsePreview(computerUsePreview)`. */
- fun addTool(computerUsePreview: ComputerTool) =
+ fun addTool(computerUsePreview: ComputerUsePreviewTool) =
addTool(Tool.ofComputerUsePreview(computerUsePreview))
/** Alias for calling [addTool] with `Tool.ofWebSearch(webSearch)`. */
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseToolSearchOutputItemParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseToolSearchOutputItemParam.kt
index 9dbba729..86f15740 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseToolSearchOutputItemParam.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseToolSearchOutputItemParam.kt
@@ -224,10 +224,10 @@ private constructor(
addTool(FileSearchTool.builder().vectorStoreIds(vectorStoreIds).build())
/** Alias for calling [addTool] with `Tool.ofComputer(computer)`. */
- fun addTool(computer: ComputerUseTool) = addTool(Tool.ofComputer(computer))
+ fun addTool(computer: ComputerTool) = addTool(Tool.ofComputer(computer))
/** Alias for calling [addTool] with `Tool.ofComputerUsePreview(computerUsePreview)`. */
- fun addTool(computerUsePreview: ComputerTool) =
+ fun addTool(computerUsePreview: ComputerUsePreviewTool) =
addTool(Tool.ofComputerUsePreview(computerUsePreview))
/** Alias for calling [addTool] with `Tool.ofWebSearch(webSearch)`. */
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponsesClientEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponsesClientEvent.kt
index b266aa08..87598506 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponsesClientEvent.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponsesClientEvent.kt
@@ -1558,10 +1558,10 @@ private constructor(
addTool(FileSearchTool.builder().vectorStoreIds(vectorStoreIds).build())
/** Alias for calling [addTool] with `Tool.ofComputer(computer)`. */
- fun addTool(computer: ComputerUseTool) = addTool(Tool.ofComputer(computer))
+ fun addTool(computer: ComputerTool) = addTool(Tool.ofComputer(computer))
/** Alias for calling [addTool] with `Tool.ofComputerUsePreview(computerUsePreview)`. */
- fun addTool(computerUsePreview: ComputerTool) =
+ fun addTool(computerUsePreview: ComputerUsePreviewTool) =
addTool(Tool.ofComputerUsePreview(computerUsePreview))
/** Alias for calling [addTool] with `Tool.ofWebSearch(webSearch)`. */
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/StructuredResponseCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/StructuredResponseCreateParams.kt
index 6841eba2..05353f4c 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/responses/StructuredResponseCreateParams.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/StructuredResponseCreateParams.kt
@@ -473,7 +473,7 @@ class StructuredResponseCreateParams(
}
/** @see ResponseCreateParams.Builder.addTool */
- fun addTool(computer: ComputerUseTool) = apply { paramsBuilder.addTool(computer) }
+ fun addTool(computer: ComputerTool) = apply { paramsBuilder.addTool(computer) }
/** @see ResponseCreateParams.Builder.addTool */
fun addTool(webSearch: WebSearchTool) = apply { paramsBuilder.addTool(webSearch) }
@@ -487,7 +487,7 @@ class StructuredResponseCreateParams(
fun addTool(applyPatch: ApplyPatchTool) = apply { paramsBuilder.addTool(applyPatch) }
/** @see ResponseCreateParams.Builder.addTool */
- fun addTool(computerUsePreview: ComputerTool) = apply {
+ fun addTool(computerUsePreview: ComputerUsePreviewTool) = apply {
paramsBuilder.addTool(computerUsePreview)
}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/Tool.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/Tool.kt
index 32d042c9..06918e8a 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/responses/Tool.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/Tool.kt
@@ -38,8 +38,8 @@ class Tool
private constructor(
private val function: FunctionTool? = null,
private val fileSearch: FileSearchTool? = null,
- private val computer: ComputerUseTool? = null,
- private val computerUsePreview: ComputerTool? = null,
+ private val computer: ComputerTool? = null,
+ private val computerUsePreview: ComputerUsePreviewTool? = null,
private val webSearch: WebSearchTool? = null,
private val mcp: Mcp? = null,
private val codeInterpreter: CodeInterpreter? = null,
@@ -70,13 +70,14 @@ private constructor(
* A tool that controls a virtual computer. Learn more about the
* [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
*/
- fun computer(): Optional = Optional.ofNullable(computer)
+ fun computer(): Optional = Optional.ofNullable(computer)
/**
* A tool that controls a virtual computer. Learn more about the
* [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
*/
- fun computerUsePreview(): Optional = Optional.ofNullable(computerUsePreview)
+ fun computerUsePreview(): Optional =
+ Optional.ofNullable(computerUsePreview)
/**
* Search the Internet for sources related to the prompt. Learn more about the
@@ -169,13 +170,14 @@ private constructor(
* A tool that controls a virtual computer. Learn more about the
* [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
*/
- fun asComputer(): ComputerUseTool = computer.getOrThrow("computer")
+ fun asComputer(): ComputerTool = computer.getOrThrow("computer")
/**
* A tool that controls a virtual computer. Learn more about the
* [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
*/
- fun asComputerUsePreview(): ComputerTool = computerUsePreview.getOrThrow("computerUsePreview")
+ fun asComputerUsePreview(): ComputerUsePreviewTool =
+ computerUsePreview.getOrThrow("computerUsePreview")
/**
* Search the Internet for sources related to the prompt. Learn more about the
@@ -261,11 +263,11 @@ private constructor(
fileSearch.validate()
}
- override fun visitComputer(computer: ComputerUseTool) {
+ override fun visitComputer(computer: ComputerTool) {
computer.validate()
}
- override fun visitComputerUsePreview(computerUsePreview: ComputerTool) {
+ override fun visitComputerUsePreview(computerUsePreview: ComputerUsePreviewTool) {
computerUsePreview.validate()
}
@@ -344,9 +346,9 @@ private constructor(
override fun visitFileSearch(fileSearch: FileSearchTool) = fileSearch.validity()
- override fun visitComputer(computer: ComputerUseTool) = computer.validity()
+ override fun visitComputer(computer: ComputerTool) = computer.validity()
- override fun visitComputerUsePreview(computerUsePreview: ComputerTool) =
+ override fun visitComputerUsePreview(computerUsePreview: ComputerUsePreviewTool) =
computerUsePreview.validity()
override fun visitWebSearch(webSearch: WebSearchTool) = webSearch.validity()
@@ -462,14 +464,14 @@ private constructor(
* A tool that controls a virtual computer. Learn more about the
* [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
*/
- @JvmStatic fun ofComputer(computer: ComputerUseTool) = Tool(computer = computer)
+ @JvmStatic fun ofComputer(computer: ComputerTool) = Tool(computer = computer)
/**
* A tool that controls a virtual computer. Learn more about the
* [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
*/
@JvmStatic
- fun ofComputerUsePreview(computerUsePreview: ComputerTool) =
+ fun ofComputerUsePreview(computerUsePreview: ComputerUsePreviewTool) =
Tool(computerUsePreview = computerUsePreview)
/**
@@ -545,13 +547,13 @@ private constructor(
* A tool that controls a virtual computer. Learn more about the
* [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
*/
- fun visitComputer(computer: ComputerUseTool): T
+ fun visitComputer(computer: ComputerTool): T
/**
* A tool that controls a virtual computer. Learn more about the
* [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
*/
- fun visitComputerUsePreview(computerUsePreview: ComputerTool): T
+ fun visitComputerUsePreview(computerUsePreview: ComputerUsePreviewTool): T
/**
* Search the Internet for sources related to the prompt. Learn more about the
@@ -631,12 +633,12 @@ private constructor(
} ?: Tool(_json = json)
}
"computer" -> {
- return tryDeserialize(node, jacksonTypeRef())?.let {
+ return tryDeserialize(node, jacksonTypeRef())?.let {
Tool(computer = it, _json = json)
} ?: Tool(_json = json)
}
"computer_use_preview" -> {
- return tryDeserialize(node, jacksonTypeRef())?.let {
+ return tryDeserialize(node, jacksonTypeRef())?.let {
Tool(computerUsePreview = it, _json = json)
} ?: Tool(_json = json)
}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/inputtokens/InputTokenCountParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/inputtokens/InputTokenCountParams.kt
index e1135504..6cba86db 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/responses/inputtokens/InputTokenCountParams.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/inputtokens/InputTokenCountParams.kt
@@ -33,7 +33,7 @@ import com.openai.models.ResponseFormatJsonObject
import com.openai.models.ResponseFormatText
import com.openai.models.responses.ApplyPatchTool
import com.openai.models.responses.ComputerTool
-import com.openai.models.responses.ComputerUseTool
+import com.openai.models.responses.ComputerUsePreviewTool
import com.openai.models.responses.CustomTool
import com.openai.models.responses.FileSearchTool
import com.openai.models.responses.FunctionShellTool
@@ -576,10 +576,12 @@ private constructor(
}
/** Alias for calling [addTool] with `Tool.ofComputer(computer)`. */
- fun addTool(computer: ComputerUseTool) = apply { body.addTool(computer) }
+ fun addTool(computer: ComputerTool) = apply { body.addTool(computer) }
/** Alias for calling [addTool] with `Tool.ofComputerUsePreview(computerUsePreview)`. */
- fun addTool(computerUsePreview: ComputerTool) = apply { body.addTool(computerUsePreview) }
+ fun addTool(computerUsePreview: ComputerUsePreviewTool) = apply {
+ body.addTool(computerUsePreview)
+ }
/** Alias for calling [addTool] with `Tool.ofWebSearch(webSearch)`. */
fun addTool(webSearch: WebSearchTool) = apply { body.addTool(webSearch) }
@@ -1417,10 +1419,10 @@ private constructor(
addTool(FileSearchTool.builder().vectorStoreIds(vectorStoreIds).build())
/** Alias for calling [addTool] with `Tool.ofComputer(computer)`. */
- fun addTool(computer: ComputerUseTool) = addTool(Tool.ofComputer(computer))
+ fun addTool(computer: ComputerTool) = addTool(Tool.ofComputer(computer))
/** Alias for calling [addTool] with `Tool.ofComputerUsePreview(computerUsePreview)`. */
- fun addTool(computerUsePreview: ComputerTool) =
+ fun addTool(computerUsePreview: ComputerUsePreviewTool) =
addTool(Tool.ofComputerUsePreview(computerUsePreview))
/** Alias for calling [addTool] with `Tool.ofWebSearch(webSearch)`. */
diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ComputerToolTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ComputerToolTest.kt
index 42640334..c354647c 100644
--- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ComputerToolTest.kt
+++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ComputerToolTest.kt
@@ -11,27 +11,13 @@ internal class ComputerToolTest {
@Test
fun create() {
- val computerTool =
- ComputerTool.builder()
- .displayHeight(0L)
- .displayWidth(0L)
- .environment(ComputerTool.Environment.WINDOWS)
- .build()
-
- assertThat(computerTool.displayHeight()).isEqualTo(0L)
- assertThat(computerTool.displayWidth()).isEqualTo(0L)
- assertThat(computerTool.environment()).isEqualTo(ComputerTool.Environment.WINDOWS)
+ val computerTool = ComputerTool.builder().build()
}
@Test
fun roundtrip() {
val jsonMapper = jsonMapper()
- val computerTool =
- ComputerTool.builder()
- .displayHeight(0L)
- .displayWidth(0L)
- .environment(ComputerTool.Environment.WINDOWS)
- .build()
+ val computerTool = ComputerTool.builder().build()
val roundtrippedComputerTool =
jsonMapper.readValue(
diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ComputerUsePreviewToolTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ComputerUsePreviewToolTest.kt
new file mode 100644
index 00000000..e47a8513
--- /dev/null
+++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ComputerUsePreviewToolTest.kt
@@ -0,0 +1,45 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.openai.models.responses
+
+import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
+import com.openai.core.jsonMapper
+import org.assertj.core.api.Assertions.assertThat
+import org.junit.jupiter.api.Test
+
+internal class ComputerUsePreviewToolTest {
+
+ @Test
+ fun create() {
+ val computerUsePreviewTool =
+ ComputerUsePreviewTool.builder()
+ .displayHeight(0L)
+ .displayWidth(0L)
+ .environment(ComputerUsePreviewTool.Environment.WINDOWS)
+ .build()
+
+ assertThat(computerUsePreviewTool.displayHeight()).isEqualTo(0L)
+ assertThat(computerUsePreviewTool.displayWidth()).isEqualTo(0L)
+ assertThat(computerUsePreviewTool.environment())
+ .isEqualTo(ComputerUsePreviewTool.Environment.WINDOWS)
+ }
+
+ @Test
+ fun roundtrip() {
+ val jsonMapper = jsonMapper()
+ val computerUsePreviewTool =
+ ComputerUsePreviewTool.builder()
+ .displayHeight(0L)
+ .displayWidth(0L)
+ .environment(ComputerUsePreviewTool.Environment.WINDOWS)
+ .build()
+
+ val roundtrippedComputerUsePreviewTool =
+ jsonMapper.readValue(
+ jsonMapper.writeValueAsString(computerUsePreviewTool),
+ jacksonTypeRef(),
+ )
+
+ assertThat(roundtrippedComputerUsePreviewTool).isEqualTo(computerUsePreviewTool)
+ }
+}
diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ComputerUseToolTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ComputerUseToolTest.kt
deleted file mode 100644
index 162ba691..00000000
--- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ComputerUseToolTest.kt
+++ /dev/null
@@ -1,30 +0,0 @@
-// File generated from our OpenAPI spec by Stainless.
-
-package com.openai.models.responses
-
-import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
-import com.openai.core.jsonMapper
-import org.assertj.core.api.Assertions.assertThat
-import org.junit.jupiter.api.Test
-
-internal class ComputerUseToolTest {
-
- @Test
- fun create() {
- val computerUseTool = ComputerUseTool.builder().build()
- }
-
- @Test
- fun roundtrip() {
- val jsonMapper = jsonMapper()
- val computerUseTool = ComputerUseTool.builder().build()
-
- val roundtrippedComputerUseTool =
- jsonMapper.readValue(
- jsonMapper.writeValueAsString(computerUseTool),
- jacksonTypeRef(),
- )
-
- assertThat(roundtrippedComputerUseTool).isEqualTo(computerUseTool)
- }
-}
diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/StructuredResponseCreateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/StructuredResponseCreateParamsTest.kt
index 88deaeb4..9e86b178 100644
--- a/openai-java-core/src/test/kotlin/com/openai/models/responses/StructuredResponseCreateParamsTest.kt
+++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/StructuredResponseCreateParamsTest.kt
@@ -93,12 +93,12 @@ internal class StructuredResponseCreateParamsTest {
WebSearchPreviewTool.builder()
.type(WebSearchPreviewTool.Type.WEB_SEARCH_PREVIEW)
.build()
- private val COMPUTER_USE_TOOL = ComputerUseTool.builder().build()
- private val COMPUTER_TOOL =
- ComputerTool.builder()
+ private val COMPUTER_TOOL = ComputerTool.builder().build()
+ private val COMPUTER_USE_PREVIEW_TOOL =
+ ComputerUsePreviewTool.builder()
.displayWidth(LONG)
.displayHeight(LONG)
- .environment(ComputerTool.Environment.LINUX)
+ .environment(ComputerUsePreviewTool.Environment.LINUX)
.build()
private val TOOL = Tool.ofFunction(FUNCTION_TOOL)
private val MCP_TOOL = Tool.Mcp.builder().serverLabel(STRING).serverUrl(STRING).build()
@@ -223,11 +223,11 @@ internal class StructuredResponseCreateParamsTest {
DelegationWriteTestCase("addTool", CLASS, VALIDATION),
DelegationWriteTestCase("addTool", FILE_SEARCH_TOOL),
DelegationWriteTestCase("addFileSearchTool", LIST),
- DelegationWriteTestCase("addTool", COMPUTER_USE_TOOL),
+ DelegationWriteTestCase("addTool", COMPUTER_TOOL),
DelegationWriteTestCase("addTool", WEB_SEARCH_TOOL),
DelegationWriteTestCase("addTool", WEB_SEARCH_PREVIEW_TOOL),
DelegationWriteTestCase("addTool", APPLY_PATCH_TOOL),
- DelegationWriteTestCase("addTool", COMPUTER_TOOL),
+ DelegationWriteTestCase("addTool", COMPUTER_USE_PREVIEW_TOOL),
DelegationWriteTestCase("addTool", MCP_TOOL),
DelegationWriteTestCase("addMcpTool", STRING),
DelegationWriteTestCase("addTool", CODE_INTERPRETER_TOOL),
diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ToolTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ToolTest.kt
index 5676c879..f2a92903 100644
--- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ToolTest.kt
+++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ToolTest.kt
@@ -157,7 +157,7 @@ internal class ToolTest {
@Test
fun ofComputer() {
- val computer = ComputerUseTool.builder().build()
+ val computer = ComputerTool.builder().build()
val tool = Tool.ofComputer(computer)
@@ -181,7 +181,7 @@ internal class ToolTest {
@Test
fun ofComputerRoundtrip() {
val jsonMapper = jsonMapper()
- val tool = Tool.ofComputer(ComputerUseTool.builder().build())
+ val tool = Tool.ofComputer(ComputerTool.builder().build())
val roundtrippedTool =
jsonMapper.readValue(jsonMapper.writeValueAsString(tool), jacksonTypeRef())
@@ -192,10 +192,10 @@ internal class ToolTest {
@Test
fun ofComputerUsePreview() {
val computerUsePreview =
- ComputerTool.builder()
+ ComputerUsePreviewTool.builder()
.displayHeight(0L)
.displayWidth(0L)
- .environment(ComputerTool.Environment.WINDOWS)
+ .environment(ComputerUsePreviewTool.Environment.WINDOWS)
.build()
val tool = Tool.ofComputerUsePreview(computerUsePreview)
@@ -222,10 +222,10 @@ internal class ToolTest {
val jsonMapper = jsonMapper()
val tool =
Tool.ofComputerUsePreview(
- ComputerTool.builder()
+ ComputerUsePreviewTool.builder()
.displayHeight(0L)
.displayWidth(0L)
- .environment(ComputerTool.Environment.WINDOWS)
+ .environment(ComputerUsePreviewTool.Environment.WINDOWS)
.build()
)