diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 9e5024f2..052d78b7 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "4.17.0"
+ ".": "4.18.0"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index 74eed78e..766c6aef 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 136
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-7a6ba5212fa9680f9489f4e73c298e1e8f78106b83a465e76290d45fc2fccb70.yml
-openapi_spec_hash: 3d3379b7dbf6af484944bc678ec9bf4c
-config_hash: a08002d1759a1d0bde3429dccc58d1ef
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-64c3a646eb5dcad2b7ff7bd976c0e312b886676a542f6ffcd9a6c8503ae24c58.yml
+openapi_spec_hash: 91b1b7bf3c1a6b6c9c7507d4cac8fe2a
+config_hash: f8e6baff429cf000b8e4ba1da08dff47
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5f6ac49b..68a88259 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,24 @@
# Changelog
+## 4.18.0 (2026-02-04)
+
+Full Changelog: [v4.17.0...v4.18.0](https://github.com/openai/openai-java/compare/v4.17.0...v4.18.0)
+
+### Features
+
+* **api:** image generation actions for responses; ResponseFunctionCallArgumentsDoneEvent.name ([a0cc1d8](https://github.com/openai/openai-java/commit/a0cc1d81ca67e8618f51df4359b2877d27cba572))
+
+
+### Bug Fixes
+
+* **client:** undo change to web search Find action ([7b2ebe5](https://github.com/openai/openai-java/commit/7b2ebe54b58b97fbc9ad1bba5cb54cb346606483))
+* **client:** update type for `find_in_page` action ([2cde783](https://github.com/openai/openai-java/commit/2cde783b5d33d7498548074ad45ee04d4d9d7c05))
+
+
+### Chores
+
+* **internal:** allow passing args to `./scripts/test` ([ce2c0ed](https://github.com/openai/openai-java/commit/ce2c0edb51c10779f3c7bb68aef8666057d4e400))
+
## 4.17.0 (2026-01-30)
Full Changelog: [v4.16.1...v4.17.0](https://github.com/openai/openai-java/compare/v4.16.1...v4.17.0)
diff --git a/README.md b/README.md
index 68a7d13a..be008a1e 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,8 @@
-[](https://central.sonatype.com/artifact/com.openai/openai-java/4.17.0)
-[](https://javadoc.io/doc/com.openai/openai-java/4.17.0)
+[](https://central.sonatype.com/artifact/com.openai/openai-java/4.18.0)
+[](https://javadoc.io/doc/com.openai/openai-java/4.18.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.17.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.18.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.17.0")
+implementation("com.openai:openai-java:4.18.0")
```
### Maven
@@ -33,7 +33,7 @@ implementation("com.openai:openai-java:4.17.0")
com.openai
openai-java
- 4.17.0
+ 4.18.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.17.0")
+implementation("com.openai:openai-java-spring-boot-starter:4.18.0")
```
#### Maven
@@ -1351,7 +1351,7 @@ implementation("com.openai:openai-java-spring-boot-starter:4.17.0")
com.openai
openai-java-spring-boot-starter
- 4.17.0
+ 4.18.0
```
diff --git a/build.gradle.kts b/build.gradle.kts
index e9669d37..bbfa8a07 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -8,7 +8,7 @@ repositories {
allprojects {
group = "com.openai"
- version = "4.17.0" // x-release-please-version
+ version = "4.18.0" // x-release-please-version
}
subprojects {
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ResponseFunctionCallArgumentsDoneEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ResponseFunctionCallArgumentsDoneEvent.kt
index 57f77a0d..7948fe5b 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ResponseFunctionCallArgumentsDoneEvent.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ResponseFunctionCallArgumentsDoneEvent.kt
@@ -26,6 +26,7 @@ private constructor(
private val callId: JsonField,
private val eventId: JsonField,
private val itemId: JsonField,
+ private val name: JsonField,
private val outputIndex: JsonField,
private val responseId: JsonField,
private val type: JsonValue,
@@ -38,6 +39,7 @@ private constructor(
@JsonProperty("call_id") @ExcludeMissing callId: JsonField = JsonMissing.of(),
@JsonProperty("event_id") @ExcludeMissing eventId: JsonField = JsonMissing.of(),
@JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(),
+ @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(),
@JsonProperty("output_index")
@ExcludeMissing
outputIndex: JsonField = JsonMissing.of(),
@@ -45,7 +47,17 @@ private constructor(
@ExcludeMissing
responseId: JsonField = JsonMissing.of(),
@JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(),
- ) : this(arguments, callId, eventId, itemId, outputIndex, responseId, type, mutableMapOf())
+ ) : this(
+ arguments,
+ callId,
+ eventId,
+ itemId,
+ name,
+ outputIndex,
+ responseId,
+ type,
+ mutableMapOf(),
+ )
/**
* The final arguments as a JSON string.
@@ -79,6 +91,14 @@ private constructor(
*/
fun itemId(): String = itemId.getRequired("item_id")
+ /**
+ * The name of the function that was called.
+ *
+ * @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 name(): String = name.getRequired("name")
+
/**
* The index of the output item in the response.
*
@@ -136,6 +156,13 @@ private constructor(
*/
@JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId
+ /**
+ * Returns the raw JSON value of [name].
+ *
+ * Unlike [name], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name
+
/**
* Returns the raw JSON value of [outputIndex].
*
@@ -174,6 +201,7 @@ private constructor(
* .callId()
* .eventId()
* .itemId()
+ * .name()
* .outputIndex()
* .responseId()
* ```
@@ -188,6 +216,7 @@ private constructor(
private var callId: JsonField? = null
private var eventId: JsonField? = null
private var itemId: JsonField? = null
+ private var name: JsonField? = null
private var outputIndex: JsonField? = null
private var responseId: JsonField? = null
private var type: JsonValue = JsonValue.from("response.function_call_arguments.done")
@@ -201,6 +230,7 @@ private constructor(
callId = responseFunctionCallArgumentsDoneEvent.callId
eventId = responseFunctionCallArgumentsDoneEvent.eventId
itemId = responseFunctionCallArgumentsDoneEvent.itemId
+ name = responseFunctionCallArgumentsDoneEvent.name
outputIndex = responseFunctionCallArgumentsDoneEvent.outputIndex
responseId = responseFunctionCallArgumentsDoneEvent.responseId
type = responseFunctionCallArgumentsDoneEvent.type
@@ -253,6 +283,17 @@ private constructor(
*/
fun itemId(itemId: JsonField) = apply { this.itemId = itemId }
+ /** The name of the function that was called. */
+ fun name(name: String) = name(JsonField.of(name))
+
+ /**
+ * Sets [Builder.name] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.name] with a well-typed [String] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun name(name: JsonField) = apply { this.name = name }
+
/** The index of the output item in the response. */
fun outputIndex(outputIndex: Long) = outputIndex(JsonField.of(outputIndex))
@@ -321,6 +362,7 @@ private constructor(
* .callId()
* .eventId()
* .itemId()
+ * .name()
* .outputIndex()
* .responseId()
* ```
@@ -333,6 +375,7 @@ private constructor(
checkRequired("callId", callId),
checkRequired("eventId", eventId),
checkRequired("itemId", itemId),
+ checkRequired("name", name),
checkRequired("outputIndex", outputIndex),
checkRequired("responseId", responseId),
type,
@@ -351,6 +394,7 @@ private constructor(
callId()
eventId()
itemId()
+ name()
outputIndex()
responseId()
_type().let {
@@ -380,6 +424,7 @@ private constructor(
(if (callId.asKnown().isPresent) 1 else 0) +
(if (eventId.asKnown().isPresent) 1 else 0) +
(if (itemId.asKnown().isPresent) 1 else 0) +
+ (if (name.asKnown().isPresent) 1 else 0) +
(if (outputIndex.asKnown().isPresent) 1 else 0) +
(if (responseId.asKnown().isPresent) 1 else 0) +
type.let { if (it == JsonValue.from("response.function_call_arguments.done")) 1 else 0 }
@@ -394,6 +439,7 @@ private constructor(
callId == other.callId &&
eventId == other.eventId &&
itemId == other.itemId &&
+ name == other.name &&
outputIndex == other.outputIndex &&
responseId == other.responseId &&
type == other.type &&
@@ -406,6 +452,7 @@ private constructor(
callId,
eventId,
itemId,
+ name,
outputIndex,
responseId,
type,
@@ -416,5 +463,5 @@ private constructor(
override fun hashCode(): Int = hashCode
override fun toString() =
- "ResponseFunctionCallArgumentsDoneEvent{arguments=$arguments, callId=$callId, eventId=$eventId, itemId=$itemId, outputIndex=$outputIndex, responseId=$responseId, type=$type, additionalProperties=$additionalProperties}"
+ "ResponseFunctionCallArgumentsDoneEvent{arguments=$arguments, callId=$callId, eventId=$eventId, itemId=$itemId, name=$name, outputIndex=$outputIndex, responseId=$responseId, type=$type, additionalProperties=$additionalProperties}"
}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionWebSearch.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionWebSearch.kt
index f0590b84..e5f8a66d 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionWebSearch.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionWebSearch.kt
@@ -63,7 +63,7 @@ private constructor(
/**
* An object describing the specific action taken in this web search call. Includes details on
- * how the model used the web (search, open_page, find).
+ * how the model used the web (search, open_page, find_in_page).
*
* @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).
@@ -170,7 +170,7 @@ private constructor(
/**
* An object describing the specific action taken in this web search call. Includes details
- * on how the model used the web (search, open_page, find).
+ * on how the model used the web (search, open_page, find_in_page).
*/
fun action(action: Action) = action(JsonField.of(action))
@@ -198,18 +198,8 @@ private constructor(
/** Alias for calling [action] with `Action.ofOpenPage(openPage)`. */
fun action(openPage: Action.OpenPage) = action(Action.ofOpenPage(openPage))
- /**
- * Alias for calling [action] with the following:
- * ```java
- * Action.OpenPage.builder()
- * .url(url)
- * .build()
- * ```
- */
- fun openPageAction(url: String) = action(Action.OpenPage.builder().url(url).build())
-
- /** Alias for calling [action] with `Action.ofFind(find)`. */
- fun action(find: Action.Find) = action(Action.ofFind(find))
+ /** Alias for calling [action] with `Action.ofFind(findInPage)`. */
+ fun action(findInPage: Action.Find) = action(Action.ofFind(findInPage))
/** The status of the web search tool call. */
fun status(status: Status) = status(JsonField.of(status))
@@ -319,7 +309,7 @@ private constructor(
/**
* An object describing the specific action taken in this web search call. Includes details on
- * how the model used the web (search, open_page, find).
+ * how the model used the web (search, open_page, find_in_page).
*/
@JsonDeserialize(using = Action.Deserializer::class)
@JsonSerialize(using = Action.Serializer::class)
@@ -327,7 +317,7 @@ private constructor(
private constructor(
private val search: Search? = null,
private val openPage: OpenPage? = null,
- private val find: Find? = null,
+ private val findInPage: Find? = null,
private val _json: JsonValue? = null,
) {
@@ -337,14 +327,14 @@ private constructor(
/** Action type "open_page" - Opens a specific URL from search results. */
fun openPage(): Optional = Optional.ofNullable(openPage)
- /** Action type "find": Searches for a pattern within a loaded page. */
- fun find(): Optional = Optional.ofNullable(find)
+ /** Action type "find_in_page": Searches for a pattern within a loaded page. */
+ fun findInPage(): Optional = Optional.ofNullable(findInPage)
fun isSearch(): Boolean = search != null
fun isOpenPage(): Boolean = openPage != null
- fun isFind(): Boolean = find != null
+ fun isFind(): Boolean = findInPage != null
/** Action type "search" - Performs a web search query. */
fun asSearch(): Search = search.getOrThrow("search")
@@ -352,8 +342,8 @@ private constructor(
/** Action type "open_page" - Opens a specific URL from search results. */
fun asOpenPage(): OpenPage = openPage.getOrThrow("openPage")
- /** Action type "find": Searches for a pattern within a loaded page. */
- fun asFind(): Find = find.getOrThrow("find")
+ /** Action type "find_in_page": Searches for a pattern within a loaded page. */
+ fun asFind(): Find = findInPage.getOrThrow("findInPage")
fun _json(): Optional = Optional.ofNullable(_json)
@@ -361,7 +351,7 @@ private constructor(
when {
search != null -> visitor.visitSearch(search)
openPage != null -> visitor.visitOpenPage(openPage)
- find != null -> visitor.visitFind(find)
+ findInPage != null -> visitor.visitFind(findInPage)
else -> visitor.unknown(_json)
}
@@ -382,8 +372,8 @@ private constructor(
openPage.validate()
}
- override fun visitFind(find: Find) {
- find.validate()
+ override fun visitFind(findInPage: Find) {
+ findInPage.validate()
}
}
)
@@ -412,7 +402,7 @@ private constructor(
override fun visitOpenPage(openPage: OpenPage) = openPage.validity()
- override fun visitFind(find: Find) = find.validity()
+ override fun visitFind(findInPage: Find) = findInPage.validity()
override fun unknown(json: JsonValue?) = 0
}
@@ -426,16 +416,16 @@ private constructor(
return other is Action &&
search == other.search &&
openPage == other.openPage &&
- find == other.find
+ findInPage == other.findInPage
}
- override fun hashCode(): Int = Objects.hash(search, openPage, find)
+ override fun hashCode(): Int = Objects.hash(search, openPage, findInPage)
override fun toString(): String =
when {
search != null -> "Action{search=$search}"
openPage != null -> "Action{openPage=$openPage}"
- find != null -> "Action{find=$find}"
+ findInPage != null -> "Action{findInPage=$findInPage}"
_json != null -> "Action{_unknown=$_json}"
else -> throw IllegalStateException("Invalid Action")
}
@@ -448,8 +438,8 @@ private constructor(
/** Action type "open_page" - Opens a specific URL from search results. */
@JvmStatic fun ofOpenPage(openPage: OpenPage) = Action(openPage = openPage)
- /** Action type "find": Searches for a pattern within a loaded page. */
- @JvmStatic fun ofFind(find: Find) = Action(find = find)
+ /** Action type "find_in_page": Searches for a pattern within a loaded page. */
+ @JvmStatic fun ofFind(findInPage: Find) = Action(findInPage = findInPage)
}
/** An interface that defines how to map each variant of [Action] to a value of type [T]. */
@@ -461,8 +451,8 @@ private constructor(
/** Action type "open_page" - Opens a specific URL from search results. */
fun visitOpenPage(openPage: OpenPage): T
- /** Action type "find": Searches for a pattern within a loaded page. */
- fun visitFind(find: Find): T
+ /** Action type "find_in_page": Searches for a pattern within a loaded page. */
+ fun visitFind(findInPage: Find): T
/**
* Maps an unknown variant of [Action] to a value of type [T].
@@ -496,9 +486,9 @@ private constructor(
Action(openPage = it, _json = json)
} ?: Action(_json = json)
}
- "find" -> {
+ "find_in_page" -> {
return tryDeserialize(node, jacksonTypeRef())?.let {
- Action(find = it, _json = json)
+ Action(findInPage = it, _json = json)
} ?: Action(_json = json)
}
}
@@ -517,7 +507,7 @@ private constructor(
when {
value.search != null -> generator.writeObject(value.search)
value.openPage != null -> generator.writeObject(value.openPage)
- value.find != null -> generator.writeObject(value.find)
+ value.findInPage != null -> generator.writeObject(value.findInPage)
value._json != null -> generator.writeObject(value._json)
else -> throw IllegalStateException("Invalid Action")
}
@@ -1069,11 +1059,10 @@ private constructor(
/**
* The URL opened by the model.
*
- * @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).
+ * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if
+ * the server responded with an unexpected value).
*/
- fun url(): String = url.getRequired("url")
+ fun url(): Optional = url.getOptional("url")
/**
* Returns the raw JSON value of [url].
@@ -1096,14 +1085,7 @@ private constructor(
companion object {
- /**
- * Returns a mutable builder for constructing an instance of [OpenPage].
- *
- * The following fields are required:
- * ```java
- * .url()
- * ```
- */
+ /** Returns a mutable builder for constructing an instance of [OpenPage]. */
@JvmStatic fun builder() = Builder()
}
@@ -1111,7 +1093,7 @@ private constructor(
class Builder internal constructor() {
private var type: JsonValue = JsonValue.from("open_page")
- private var url: JsonField? = null
+ private var url: JsonField = JsonMissing.of()
private var additionalProperties: MutableMap = mutableMapOf()
@JvmSynthetic
@@ -1136,7 +1118,10 @@ private constructor(
fun type(type: JsonValue) = apply { this.type = type }
/** The URL opened by the model. */
- fun url(url: String) = url(JsonField.of(url))
+ fun url(url: String?) = url(JsonField.ofNullable(url))
+
+ /** Alias for calling [Builder.url] with `url.orElse(null)`. */
+ fun url(url: Optional) = url(url.getOrNull())
/**
* Sets [Builder.url] to an arbitrary JSON value.
@@ -1173,16 +1158,8 @@ private constructor(
* Returns an immutable instance of [OpenPage].
*
* Further updates to this [Builder] will not mutate the returned instance.
- *
- * The following fields are required:
- * ```java
- * .url()
- * ```
- *
- * @throws IllegalStateException if any required field is unset.
*/
- fun build(): OpenPage =
- OpenPage(type, checkRequired("url", url), additionalProperties.toMutableMap())
+ fun build(): OpenPage = OpenPage(type, url, additionalProperties.toMutableMap())
}
private var validated: Boolean = false
@@ -1239,7 +1216,7 @@ private constructor(
"OpenPage{type=$type, url=$url, additionalProperties=$additionalProperties}"
}
- /** Action type "find": Searches for a pattern within a loaded page. */
+ /** Action type "find_in_page": Searches for a pattern within a loaded page. */
class Find
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
private constructor(
@@ -1272,7 +1249,7 @@ private constructor(
*
* Expected to always return the following:
* ```java
- * JsonValue.from("find")
+ * JsonValue.from("find_in_page")
* ```
*
* However, this method can be useful for debugging and logging (e.g. if the server
@@ -1333,16 +1310,16 @@ private constructor(
class Builder internal constructor() {
private var pattern: JsonField? = null
- private var type: JsonValue = JsonValue.from("find")
+ private var type: JsonValue = JsonValue.from("find_in_page")
private var url: JsonField? = null
private var additionalProperties: MutableMap = mutableMapOf()
@JvmSynthetic
- internal fun from(find: Find) = apply {
- pattern = find.pattern
- type = find.type
- url = find.url
- additionalProperties = find.additionalProperties.toMutableMap()
+ internal fun from(findInPage: Find) = apply {
+ pattern = findInPage.pattern
+ type = findInPage.type
+ url = findInPage.url
+ additionalProperties = findInPage.additionalProperties.toMutableMap()
}
/** The pattern or text to search for within the page. */
@@ -1363,7 +1340,7 @@ private constructor(
* It is usually unnecessary to call this method because the field defaults to the
* following:
* ```java
- * JsonValue.from("find")
+ * JsonValue.from("find_in_page")
* ```
*
* This method is primarily for setting the field to an undocumented or not yet
@@ -1436,7 +1413,7 @@ private constructor(
pattern()
_type().let {
- if (it != JsonValue.from("find")) {
+ if (it != JsonValue.from("find_in_page")) {
throw OpenAIInvalidDataException("'type' is invalid, received $it")
}
}
@@ -1461,7 +1438,7 @@ private constructor(
@JvmSynthetic
internal fun validity(): Int =
(if (pattern.asKnown().isPresent) 1 else 0) +
- type.let { if (it == JsonValue.from("find")) 1 else 0 } +
+ type.let { if (it == JsonValue.from("find_in_page")) 1 else 0 } +
(if (url.asKnown().isPresent) 1 else 0)
override fun equals(other: Any?): Boolean {
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 be931fab..abe85bb0 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
@@ -3799,6 +3799,7 @@ private constructor(
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
private constructor(
private val type: JsonValue,
+ private val action: JsonField,
private val background: JsonField,
private val inputFidelity: JsonField,
private val inputImageMask: JsonField,
@@ -3815,6 +3816,7 @@ private constructor(
@JsonCreator
private constructor(
@JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(),
+ @JsonProperty("action") @ExcludeMissing action: JsonField = JsonMissing.of(),
@JsonProperty("background")
@ExcludeMissing
background: JsonField = JsonMissing.of(),
@@ -3841,6 +3843,7 @@ private constructor(
@JsonProperty("size") @ExcludeMissing size: JsonField = JsonMissing.of(),
) : this(
type,
+ action,
background,
inputFidelity,
inputImageMask,
@@ -3867,6 +3870,14 @@ private constructor(
*/
@JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type
+ /**
+ * Whether to generate a new image or edit an existing image. Default: `auto`.
+ *
+ * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun action(): Optional = action.getOptional("action")
+
/**
* Background type for the generated image. One of `transparent`, `opaque`, or `auto`.
* Default: `auto`.
@@ -3956,6 +3967,13 @@ private constructor(
*/
fun size(): Optional = size.getOptional("size")
+ /**
+ * Returns the raw JSON value of [action].
+ *
+ * Unlike [action], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action
+
/**
* Returns the raw JSON value of [background].
*
@@ -4067,6 +4085,7 @@ private constructor(
class Builder internal constructor() {
private var type: JsonValue = JsonValue.from("image_generation")
+ private var action: JsonField = JsonMissing.of()
private var background: JsonField = JsonMissing.of()
private var inputFidelity: JsonField = JsonMissing.of()
private var inputImageMask: JsonField = JsonMissing.of()
@@ -4082,6 +4101,7 @@ private constructor(
@JvmSynthetic
internal fun from(imageGeneration: ImageGeneration) = apply {
type = imageGeneration.type
+ action = imageGeneration.action
background = imageGeneration.background
inputFidelity = imageGeneration.inputFidelity
inputImageMask = imageGeneration.inputImageMask
@@ -4109,6 +4129,18 @@ private constructor(
*/
fun type(type: JsonValue) = apply { this.type = type }
+ /** Whether to generate a new image or edit an existing image. Default: `auto`. */
+ fun action(action: Action) = action(JsonField.of(action))
+
+ /**
+ * Sets [Builder.action] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.action] with a well-typed [Action] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun action(action: JsonField) = apply { this.action = action }
+
/**
* Background type for the generated image. One of `transparent`, `opaque`, or `auto`.
* Default: `auto`.
@@ -4308,6 +4340,7 @@ private constructor(
fun build(): ImageGeneration =
ImageGeneration(
type,
+ action,
background,
inputFidelity,
inputImageMask,
@@ -4334,6 +4367,7 @@ private constructor(
throw OpenAIInvalidDataException("'type' is invalid, received $it")
}
}
+ action().ifPresent { it.validate() }
background().ifPresent { it.validate() }
inputFidelity().ifPresent { it.validate() }
inputImageMask().ifPresent { it.validate() }
@@ -4364,6 +4398,7 @@ private constructor(
@JvmSynthetic
internal fun validity(): Int =
type.let { if (it == JsonValue.from("image_generation")) 1 else 0 } +
+ (action.asKnown().getOrNull()?.validity() ?: 0) +
(background.asKnown().getOrNull()?.validity() ?: 0) +
(inputFidelity.asKnown().getOrNull()?.validity() ?: 0) +
(inputImageMask.asKnown().getOrNull()?.validity() ?: 0) +
@@ -4375,6 +4410,142 @@ private constructor(
(quality.asKnown().getOrNull()?.validity() ?: 0) +
(size.asKnown().getOrNull()?.validity() ?: 0)
+ /** Whether to generate a new image or edit an existing image. Default: `auto`. */
+ class Action @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 GENERATE = of("generate")
+
+ @JvmField val EDIT = of("edit")
+
+ @JvmField val AUTO = of("auto")
+
+ @JvmStatic fun of(value: String) = Action(JsonField.of(value))
+ }
+
+ /** An enum containing [Action]'s known values. */
+ enum class Known {
+ GENERATE,
+ EDIT,
+ AUTO,
+ }
+
+ /**
+ * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [Action] 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 {
+ GENERATE,
+ EDIT,
+ AUTO,
+ /**
+ * An enum member indicating that [Action] 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) {
+ GENERATE -> Value.GENERATE
+ EDIT -> Value.EDIT
+ AUTO -> Value.AUTO
+ 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) {
+ GENERATE -> Known.GENERATE
+ EDIT -> Known.EDIT
+ AUTO -> Known.AUTO
+ else -> throw OpenAIInvalidDataException("Unknown Action: $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(): Action = 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 Action && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+ }
+
/**
* Background type for the generated image. One of `transparent`, `opaque`, or `auto`.
* Default: `auto`.
@@ -4863,6 +5034,8 @@ private constructor(
@JvmField val GPT_IMAGE_1_MINI = of("gpt-image-1-mini")
+ @JvmField val GPT_IMAGE_1_5 = of("gpt-image-1.5")
+
@JvmStatic fun of(value: String) = Model(JsonField.of(value))
}
@@ -4870,6 +5043,7 @@ private constructor(
enum class Known {
GPT_IMAGE_1,
GPT_IMAGE_1_MINI,
+ GPT_IMAGE_1_5,
}
/**
@@ -4884,6 +5058,7 @@ private constructor(
enum class Value {
GPT_IMAGE_1,
GPT_IMAGE_1_MINI,
+ GPT_IMAGE_1_5,
/**
* An enum member indicating that [Model] was instantiated with an unknown value.
*/
@@ -4901,6 +5076,7 @@ private constructor(
when (this) {
GPT_IMAGE_1 -> Value.GPT_IMAGE_1
GPT_IMAGE_1_MINI -> Value.GPT_IMAGE_1_MINI
+ GPT_IMAGE_1_5 -> Value.GPT_IMAGE_1_5
else -> Value._UNKNOWN
}
@@ -4917,6 +5093,7 @@ private constructor(
when (this) {
GPT_IMAGE_1 -> Known.GPT_IMAGE_1
GPT_IMAGE_1_MINI -> Known.GPT_IMAGE_1_MINI
+ GPT_IMAGE_1_5 -> Known.GPT_IMAGE_1_5
else -> throw OpenAIInvalidDataException("Unknown Model: $value")
}
@@ -5543,6 +5720,7 @@ private constructor(
return other is ImageGeneration &&
type == other.type &&
+ action == other.action &&
background == other.background &&
inputFidelity == other.inputFidelity &&
inputImageMask == other.inputImageMask &&
@@ -5559,6 +5737,7 @@ private constructor(
private val hashCode: Int by lazy {
Objects.hash(
type,
+ action,
background,
inputFidelity,
inputImageMask,
@@ -5576,6 +5755,6 @@ private constructor(
override fun hashCode(): Int = hashCode
override fun toString() =
- "ImageGeneration{type=$type, background=$background, inputFidelity=$inputFidelity, inputImageMask=$inputImageMask, model=$model, moderation=$moderation, outputCompression=$outputCompression, outputFormat=$outputFormat, partialImages=$partialImages, quality=$quality, size=$size, additionalProperties=$additionalProperties}"
+ "ImageGeneration{type=$type, action=$action, background=$background, inputFidelity=$inputFidelity, inputImageMask=$inputImageMask, model=$model, moderation=$moderation, outputCompression=$outputCompression, outputFormat=$outputFormat, partialImages=$partialImages, quality=$quality, size=$size, additionalProperties=$additionalProperties}"
}
}
diff --git a/openai-java-core/src/test/kotlin/com/openai/models/realtime/RealtimeServerEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/realtime/RealtimeServerEventTest.kt
index 8971f216..5f326dd0 100644
--- a/openai-java-core/src/test/kotlin/com/openai/models/realtime/RealtimeServerEventTest.kt
+++ b/openai-java-core/src/test/kotlin/com/openai/models/realtime/RealtimeServerEventTest.kt
@@ -2548,6 +2548,7 @@ internal class RealtimeServerEventTest {
.callId("call_id")
.eventId("event_id")
.itemId("item_id")
+ .name("name")
.outputIndex(0L)
.responseId("response_id")
.build()
@@ -2616,6 +2617,7 @@ internal class RealtimeServerEventTest {
.callId("call_id")
.eventId("event_id")
.itemId("item_id")
+ .name("name")
.outputIndex(0L)
.responseId("response_id")
.build()
diff --git a/openai-java-core/src/test/kotlin/com/openai/models/realtime/ResponseFunctionCallArgumentsDoneEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/realtime/ResponseFunctionCallArgumentsDoneEventTest.kt
index ef187a69..46bc8a9b 100644
--- a/openai-java-core/src/test/kotlin/com/openai/models/realtime/ResponseFunctionCallArgumentsDoneEventTest.kt
+++ b/openai-java-core/src/test/kotlin/com/openai/models/realtime/ResponseFunctionCallArgumentsDoneEventTest.kt
@@ -17,6 +17,7 @@ internal class ResponseFunctionCallArgumentsDoneEventTest {
.callId("call_id")
.eventId("event_id")
.itemId("item_id")
+ .name("name")
.outputIndex(0L)
.responseId("response_id")
.build()
@@ -25,6 +26,7 @@ internal class ResponseFunctionCallArgumentsDoneEventTest {
assertThat(responseFunctionCallArgumentsDoneEvent.callId()).isEqualTo("call_id")
assertThat(responseFunctionCallArgumentsDoneEvent.eventId()).isEqualTo("event_id")
assertThat(responseFunctionCallArgumentsDoneEvent.itemId()).isEqualTo("item_id")
+ assertThat(responseFunctionCallArgumentsDoneEvent.name()).isEqualTo("name")
assertThat(responseFunctionCallArgumentsDoneEvent.outputIndex()).isEqualTo(0L)
assertThat(responseFunctionCallArgumentsDoneEvent.responseId()).isEqualTo("response_id")
}
@@ -38,6 +40,7 @@ internal class ResponseFunctionCallArgumentsDoneEventTest {
.callId("call_id")
.eventId("event_id")
.itemId("item_id")
+ .name("name")
.outputIndex(0L)
.responseId("response_id")
.build()
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 abe6207e..b7ab999b 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
@@ -378,6 +378,7 @@ internal class ToolTest {
fun ofImageGeneration() {
val imageGeneration =
Tool.ImageGeneration.builder()
+ .action(Tool.ImageGeneration.Action.GENERATE)
.background(Tool.ImageGeneration.Background.TRANSPARENT)
.inputFidelity(Tool.ImageGeneration.InputFidelity.HIGH)
.inputImageMask(
@@ -417,6 +418,7 @@ internal class ToolTest {
val tool =
Tool.ofImageGeneration(
Tool.ImageGeneration.builder()
+ .action(Tool.ImageGeneration.Action.GENERATE)
.background(Tool.ImageGeneration.Background.TRANSPARENT)
.inputFidelity(Tool.ImageGeneration.InputFidelity.HIGH)
.inputImageMask(
diff --git a/scripts/build b/scripts/build
index 32d2e4ea..16a2b00d 100755
--- a/scripts/build
+++ b/scripts/build
@@ -5,5 +5,4 @@ set -e
cd "$(dirname "$0")/.."
echo "==> Building classes"
-
-./gradlew build testClasses -x test
\ No newline at end of file
+./gradlew build testClasses "$@" -x test