Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.29.0"
".": "0.30.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 65
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-4aa6ee65ba9efc789e05e6a5ef0883b2cadf06def8efd863dbf75e9e233067e1.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-5d30684c3118d049682ea30cdb4dbef39b97d51667da484689193dc40162af32.yml
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

## 0.30.0 (2025-02-27)

Full Changelog: [v0.29.0...v0.30.0](https://github.com/openai/openai-java/compare/v0.29.0...v0.30.0)

### Features

* **api:** add gpt-4.5-preview ([#258](https://github.com/openai/openai-java/issues/258)) ([27d1e7f](https://github.com/openai/openai-java/commit/27d1e7f6565ab00161d322bf04a8cb1e70c31694))


### Chores

* **client:** use deep identity methods for primitive array types ([#255](https://github.com/openai/openai-java/issues/255)) ([fac8678](https://github.com/openai/openai-java/commit/fac86783373355488b81a7a1452bc8ba2a74066f))
* **internal:** add async service tests ([#253](https://github.com/openai/openai-java/issues/253)) ([147872a](https://github.com/openai/openai-java/commit/147872a570403c78059fb785d9860003a5187583))
* **internal:** improve sync service tests ([147872a](https://github.com/openai/openai-java/commit/147872a570403c78059fb785d9860003a5187583))
* **internal:** refactor `ServiceParamsTest` ([#257](https://github.com/openai/openai-java/issues/257)) ([9cb1929](https://github.com/openai/openai-java/commit/9cb19297c372976fa331d5945c028017392b2d5d))


### Documentation

* readme parameter tweaks ([147872a](https://github.com/openai/openai-java/commit/147872a570403c78059fb785d9860003a5187583))

## 0.29.0 (2025-02-26)

Full Changelog: [v0.28.0...v0.29.0](https://github.com/openai/openai-java/compare/v0.28.0...v0.29.0)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<!-- x-release-please-start-version -->

[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/0.29.0)
[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/0.29.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/0.29.0)
[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/0.30.0)
[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/0.30.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/0.30.0)

<!-- x-release-please-end -->

Expand All @@ -25,7 +25,7 @@ The REST API documentation can be found on [platform.openai.com](https://platfor
### Gradle

```kotlin
implementation("com.openai:openai-java:0.29.0")
implementation("com.openai:openai-java:0.30.0")
```

### Maven
Expand All @@ -34,7 +34,7 @@ implementation("com.openai:openai-java:0.29.0")
<dependency>
<groupId>com.openai</groupId>
<artifactId>openai-java</artifactId>
<version>0.29.0</version>
<version>0.30.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repositories {

allprojects {
group = "com.openai"
version = "0.29.0" // x-release-please-version
version = "0.30.0" // x-release-please-version
}

subprojects {
Expand Down
36 changes: 36 additions & 0 deletions openai-java-core/src/main/kotlin/com/openai/core/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,42 @@ internal fun <K : Comparable<K>, V> SortedMap<K, V>.toImmutable(): SortedMap<K,
if (isEmpty()) Collections.emptySortedMap()
else Collections.unmodifiableSortedMap(toSortedMap(comparator()))

/**
* Returns whether [this] is equal to [other].
*
* This differs from [Object.equals] because it also deeply equates arrays based on their contents,
* even when there are arrays directly nested within other arrays.
*/
@JvmSynthetic
internal infix fun Any?.contentEquals(other: Any?): Boolean =
arrayOf(this).contentDeepEquals(arrayOf(other))

/**
* Returns a hash of the given sequence of [values].
*
* This differs from [java.util.Objects.hash] because it also deeply hashes arrays based on their
* contents, even when there are arrays directly nested within other arrays.
*/
@JvmSynthetic internal fun contentHash(vararg values: Any?): Int = values.contentDeepHashCode()

/**
* Returns a [String] representation of [this].
*
* This differs from [Object.toString] because it also deeply stringifies arrays based on their
* contents, even when there are arrays directly nested within other arrays.
*/
@JvmSynthetic
internal fun Any?.contentToString(): String {
var string = arrayOf(this).contentDeepToString()
if (string.startsWith('[')) {
string = string.substring(1)
}
if (string.endsWith(']')) {
string = string.substring(0, string.length - 1)
}
return string
}

@JvmSynthetic
internal fun isAzureEndpoint(baseUrl: String): Boolean {
// Azure Endpoint should be in the format of `https://<region>.openai.azure.com`.
Expand Down
43 changes: 11 additions & 32 deletions openai-java-core/src/main/kotlin/com/openai/core/Values.kt
Original file line number Diff line number Diff line change
Expand Up @@ -470,41 +470,20 @@ internal constructor(
val filename: String? = null,
) {

private var hashCode: Int = 0

override fun hashCode(): Int {
if (hashCode == 0) {
hashCode =
Objects.hash(
name,
contentType,
filename,
when (value) {
is ByteArray -> value.contentHashCode()
is String -> value
is Boolean -> value
is Long -> value
is Double -> value
else -> value?.hashCode()
},
)
}
return hashCode
}

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other == null || this.javaClass != other.javaClass) return false
private val hashCode: Int by lazy { contentHash(name, value, contentType, filename) }

other as MultipartFormValue<*>
override fun hashCode(): Int = hashCode

if (name != other.name || contentType != other.contentType || filename != other.filename)
return false

return when {
value is ByteArray && other.value is ByteArray -> value contentEquals other.value
else -> value?.equals(other.value) ?: (other.value == null)
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}

return other is MultipartFormValue<*> &&
name == other.name &&
value contentEquals other.value &&
contentType == other.contentType &&
filename == other.filename
}

override fun toString(): String =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,10 @@ private constructor(

@JvmField val GPT_4O_MINI_2024_07_18 = of("gpt-4o-mini-2024-07-18")

@JvmField val GPT_4_5_PREVIEW = of("gpt-4.5-preview")

@JvmField val GPT_4_5_PREVIEW_2025_02_27 = of("gpt-4.5-preview-2025-02-27")

@JvmField val GPT_4_TURBO = of("gpt-4-turbo")

@JvmField val GPT_4_TURBO_2024_04_09 = of("gpt-4-turbo-2024-04-09")
Expand Down Expand Up @@ -1680,6 +1684,8 @@ private constructor(
GPT_4O_2024_05_13,
GPT_4O_MINI,
GPT_4O_MINI_2024_07_18,
GPT_4_5_PREVIEW,
GPT_4_5_PREVIEW_2025_02_27,
GPT_4_TURBO,
GPT_4_TURBO_2024_04_09,
GPT_4_0125_PREVIEW,
Expand Down Expand Up @@ -1720,6 +1726,8 @@ private constructor(
GPT_4O_2024_05_13,
GPT_4O_MINI,
GPT_4O_MINI_2024_07_18,
GPT_4_5_PREVIEW,
GPT_4_5_PREVIEW_2025_02_27,
GPT_4_TURBO,
GPT_4_TURBO_2024_04_09,
GPT_4_0125_PREVIEW,
Expand Down Expand Up @@ -1761,6 +1769,8 @@ private constructor(
GPT_4O_2024_05_13 -> Value.GPT_4O_2024_05_13
GPT_4O_MINI -> Value.GPT_4O_MINI
GPT_4O_MINI_2024_07_18 -> Value.GPT_4O_MINI_2024_07_18
GPT_4_5_PREVIEW -> Value.GPT_4_5_PREVIEW
GPT_4_5_PREVIEW_2025_02_27 -> Value.GPT_4_5_PREVIEW_2025_02_27
GPT_4_TURBO -> Value.GPT_4_TURBO
GPT_4_TURBO_2024_04_09 -> Value.GPT_4_TURBO_2024_04_09
GPT_4_0125_PREVIEW -> Value.GPT_4_0125_PREVIEW
Expand Down Expand Up @@ -1803,6 +1813,8 @@ private constructor(
GPT_4O_2024_05_13 -> Known.GPT_4O_2024_05_13
GPT_4O_MINI -> Known.GPT_4O_MINI
GPT_4O_MINI_2024_07_18 -> Known.GPT_4O_MINI_2024_07_18
GPT_4_5_PREVIEW -> Known.GPT_4_5_PREVIEW
GPT_4_5_PREVIEW_2025_02_27 -> Known.GPT_4_5_PREVIEW_2025_02_27
GPT_4_TURBO -> Known.GPT_4_TURBO
GPT_4_TURBO_2024_04_09 -> Known.GPT_4_TURBO_2024_04_09
GPT_4_0125_PREVIEW -> Known.GPT_4_0125_PREVIEW
Expand Down
12 changes: 12 additions & 0 deletions openai-java-core/src/main/kotlin/com/openai/models/ChatModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class ChatModel @JsonCreator private constructor(private val value: JsonField<St

@JvmField val O1_MINI_2024_09_12 = of("o1-mini-2024-09-12")

@JvmField val GPT_4_5_PREVIEW = of("gpt-4.5-preview")

@JvmField val GPT_4_5_PREVIEW_2025_02_27 = of("gpt-4.5-preview-2025-02-27")

@JvmField val GPT_4O = of("gpt-4o")

@JvmField val GPT_4O_2024_11_20 = of("gpt-4o-2024-11-20")
Expand Down Expand Up @@ -112,6 +116,8 @@ class ChatModel @JsonCreator private constructor(private val value: JsonField<St
O1_PREVIEW_2024_09_12,
O1_MINI,
O1_MINI_2024_09_12,
GPT_4_5_PREVIEW,
GPT_4_5_PREVIEW_2025_02_27,
GPT_4O,
GPT_4O_2024_11_20,
GPT_4O_2024_08_06,
Expand Down Expand Up @@ -163,6 +169,8 @@ class ChatModel @JsonCreator private constructor(private val value: JsonField<St
O1_PREVIEW_2024_09_12,
O1_MINI,
O1_MINI_2024_09_12,
GPT_4_5_PREVIEW,
GPT_4_5_PREVIEW_2025_02_27,
GPT_4O,
GPT_4O_2024_11_20,
GPT_4O_2024_08_06,
Expand Down Expand Up @@ -215,6 +223,8 @@ class ChatModel @JsonCreator private constructor(private val value: JsonField<St
O1_PREVIEW_2024_09_12 -> Value.O1_PREVIEW_2024_09_12
O1_MINI -> Value.O1_MINI
O1_MINI_2024_09_12 -> Value.O1_MINI_2024_09_12
GPT_4_5_PREVIEW -> Value.GPT_4_5_PREVIEW
GPT_4_5_PREVIEW_2025_02_27 -> Value.GPT_4_5_PREVIEW_2025_02_27
GPT_4O -> Value.GPT_4O
GPT_4O_2024_11_20 -> Value.GPT_4O_2024_11_20
GPT_4O_2024_08_06 -> Value.GPT_4O_2024_08_06
Expand Down Expand Up @@ -267,6 +277,8 @@ class ChatModel @JsonCreator private constructor(private val value: JsonField<St
O1_PREVIEW_2024_09_12 -> Known.O1_PREVIEW_2024_09_12
O1_MINI -> Known.O1_MINI
O1_MINI_2024_09_12 -> Known.O1_MINI_2024_09_12
GPT_4_5_PREVIEW -> Known.GPT_4_5_PREVIEW
GPT_4_5_PREVIEW_2025_02_27 -> Known.GPT_4_5_PREVIEW_2025_02_27
GPT_4O -> Known.GPT_4O
GPT_4O_2024_11_20 -> Known.GPT_4O_2024_11_20
GPT_4O_2024_08_06 -> Known.GPT_4O_2024_08_06
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ private constructor(
@JsonProperty("status")
@ExcludeMissing
private val status: JsonField<Status> = JsonMissing.of(),
@JsonProperty("expires_at")
@ExcludeMissing
private val expiresAt: JsonField<Long> = JsonMissing.of(),
@JsonProperty("status_details")
@ExcludeMissing
private val statusDetails: JsonField<String> = JsonMissing.of(),
Expand Down Expand Up @@ -72,6 +75,9 @@ private constructor(
*/
@Deprecated("deprecated") fun status(): Status = status.getRequired("status")

/** The Unix timestamp (in seconds) for when the file will expire. */
fun expiresAt(): Optional<Long> = Optional.ofNullable(expiresAt.getNullable("expires_at"))

/**
* Deprecated. For details on why a fine-tuning training file failed validation, see the `error`
* field on `fine_tuning.job`.
Expand Down Expand Up @@ -107,6 +113,9 @@ private constructor(
@ExcludeMissing
fun _status(): JsonField<Status> = status

/** The Unix timestamp (in seconds) for when the file will expire. */
@JsonProperty("expires_at") @ExcludeMissing fun _expiresAt(): JsonField<Long> = expiresAt

/**
* Deprecated. For details on why a fine-tuning training file failed validation, see the `error`
* field on `fine_tuning.job`.
Expand Down Expand Up @@ -138,6 +147,7 @@ private constructor(
}
purpose()
status()
expiresAt()
statusDetails()
validated = true
}
Expand All @@ -159,6 +169,7 @@ private constructor(
private var object_: JsonValue = JsonValue.from("file")
private var purpose: JsonField<Purpose>? = null
private var status: JsonField<Status>? = null
private var expiresAt: JsonField<Long> = JsonMissing.of()
private var statusDetails: JsonField<String> = JsonMissing.of()
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()

Expand All @@ -171,6 +182,7 @@ private constructor(
object_ = fileObject.object_
purpose = fileObject.purpose
status = fileObject.status
expiresAt = fileObject.expiresAt
statusDetails = fileObject.statusDetails
additionalProperties = fileObject.additionalProperties.toMutableMap()
}
Expand Down Expand Up @@ -227,6 +239,12 @@ private constructor(
@Deprecated("deprecated")
fun status(status: JsonField<Status>) = apply { this.status = status }

/** The Unix timestamp (in seconds) for when the file will expire. */
fun expiresAt(expiresAt: Long) = expiresAt(JsonField.of(expiresAt))

/** The Unix timestamp (in seconds) for when the file will expire. */
fun expiresAt(expiresAt: JsonField<Long>) = apply { this.expiresAt = expiresAt }

/**
* Deprecated. For details on why a fine-tuning training file failed validation, see the
* `error` field on `fine_tuning.job`.
Expand Down Expand Up @@ -271,6 +289,7 @@ private constructor(
object_,
checkRequired("purpose", purpose),
checkRequired("status", status),
expiresAt,
statusDetails,
additionalProperties.toImmutable(),
)
Expand Down Expand Up @@ -522,15 +541,15 @@ private constructor(
return true
}

return /* spotless:off */ other is FileObject && id == other.id && bytes == other.bytes && createdAt == other.createdAt && filename == other.filename && object_ == other.object_ && purpose == other.purpose && status == other.status && statusDetails == other.statusDetails && additionalProperties == other.additionalProperties /* spotless:on */
return /* spotless:off */ other is FileObject && id == other.id && bytes == other.bytes && createdAt == other.createdAt && filename == other.filename && object_ == other.object_ && purpose == other.purpose && status == other.status && expiresAt == other.expiresAt && statusDetails == other.statusDetails && additionalProperties == other.additionalProperties /* spotless:on */
}

/* spotless:off */
private val hashCode: Int by lazy { Objects.hash(id, bytes, createdAt, filename, object_, purpose, status, statusDetails, additionalProperties) }
private val hashCode: Int by lazy { Objects.hash(id, bytes, createdAt, filename, object_, purpose, status, expiresAt, statusDetails, additionalProperties) }
/* spotless:on */

override fun hashCode(): Int = hashCode

override fun toString() =
"FileObject{id=$id, bytes=$bytes, createdAt=$createdAt, filename=$filename, object_=$object_, purpose=$purpose, status=$status, statusDetails=$statusDetails, additionalProperties=$additionalProperties}"
"FileObject{id=$id, bytes=$bytes, createdAt=$createdAt, filename=$filename, object_=$object_, purpose=$purpose, status=$status, expiresAt=$expiresAt, statusDetails=$statusDetails, additionalProperties=$additionalProperties}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private constructor(
/** The Unix timestamp (in seconds) for when the Upload was created. */
fun createdAt(): Long = createdAt.getRequired("created_at")

/** The Unix timestamp (in seconds) for when the Upload was created. */
/** The Unix timestamp (in seconds) for when the Upload will expire. */
fun expiresAt(): Long = expiresAt.getRequired("expires_at")

/** The name of the file to be uploaded. */
Expand Down Expand Up @@ -88,7 +88,7 @@ private constructor(
/** The Unix timestamp (in seconds) for when the Upload was created. */
@JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField<Long> = createdAt

/** The Unix timestamp (in seconds) for when the Upload was created. */
/** The Unix timestamp (in seconds) for when the Upload will expire. */
@JsonProperty("expires_at") @ExcludeMissing fun _expiresAt(): JsonField<Long> = expiresAt

/** The name of the file to be uploaded. */
Expand Down Expand Up @@ -187,10 +187,10 @@ private constructor(
/** The Unix timestamp (in seconds) for when the Upload was created. */
fun createdAt(createdAt: JsonField<Long>) = apply { this.createdAt = createdAt }

/** The Unix timestamp (in seconds) for when the Upload was created. */
/** The Unix timestamp (in seconds) for when the Upload will expire. */
fun expiresAt(expiresAt: Long) = expiresAt(JsonField.of(expiresAt))

/** The Unix timestamp (in seconds) for when the Upload was created. */
/** The Unix timestamp (in seconds) for when the Upload will expire. */
fun expiresAt(expiresAt: JsonField<Long>) = apply { this.expiresAt = expiresAt }

/** The name of the file to be uploaded. */
Expand Down
Loading
Loading