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 @@
{
".": "4.7.0"
".": "4.7.1"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 135
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-3c5d1593d7c6f2b38a7d78d7906041465ee9d6e9022f0651e1da194654488108.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-eeba8addf3a5f412e5ce8d22031e60c61650cee3f5d9e587a2533f6818a249ea.yml
openapi_spec_hash: 0a4d8ad2469823ce24a3fd94f23f1c2b
config_hash: 032995825500a503a76da119f5354905
config_hash: 0bb1941a78ece0b610a2fbba7d74a84c
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 4.7.1 (2025-11-04)

Full Changelog: [v4.7.0...v4.7.1](https://github.com/openai/openai-java/compare/v4.7.0...v4.7.1)

### Bug Fixes

* **api:** fix nullability of logprobs ([f1733f8](https://github.com/openai/openai-java/commit/f1733f8e81580b4e6c1a29ea6913af5e98d41607))

## 4.7.0 (2025-11-04)

Full Changelog: [v4.6.1...v4.7.0](https://github.com/openai/openai-java/compare/v4.6.1...v4.7.0)
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

<!-- 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/4.7.0)
[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/4.7.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/4.7.0)
[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/4.7.1)
[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/4.7.1/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/4.7.1)

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

The OpenAI Java SDK provides convenient access to the [OpenAI REST API](https://platform.openai.com/docs) from applications written in Java.

<!-- x-release-please-start-version -->

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.7.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.7.1).

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

Expand All @@ -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.7.0")
implementation("com.openai:openai-java:4.7.1")
```

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

Expand Down Expand Up @@ -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.7.0")
implementation("com.openai:openai-java-spring-boot-starter:4.7.1")
```

#### Maven
Expand All @@ -1351,7 +1351,7 @@ implementation("com.openai:openai-java-spring-boot-starter:4.7.0")
<dependency>
<groupId>com.openai</groupId>
<artifactId>openai-java-spring-boot-starter</artifactId>
<version>4.7.0</version>
<version>4.7.1</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 = "4.7.0" // x-release-please-version
version = "4.7.1" // x-release-please-version
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class ResponseOutputText
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
private constructor(
private val annotations: JsonField<List<Annotation>>,
private val logprobs: JsonField<List<Logprob>>,
private val text: JsonField<String>,
private val type: JsonValue,
private val logprobs: JsonField<List<Logprob>>,
private val additionalProperties: MutableMap<String, JsonValue>,
) {

Expand All @@ -45,12 +45,12 @@ private constructor(
@JsonProperty("annotations")
@ExcludeMissing
annotations: JsonField<List<Annotation>> = JsonMissing.of(),
@JsonProperty("text") @ExcludeMissing text: JsonField<String> = JsonMissing.of(),
@JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(),
@JsonProperty("logprobs")
@ExcludeMissing
logprobs: JsonField<List<Logprob>> = JsonMissing.of(),
@JsonProperty("text") @ExcludeMissing text: JsonField<String> = JsonMissing.of(),
@JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(),
) : this(annotations, logprobs, text, type, mutableMapOf())
) : this(annotations, text, type, logprobs, mutableMapOf())

/**
* The annotations of the text output.
Expand All @@ -60,12 +60,6 @@ private constructor(
*/
fun annotations(): List<Annotation> = annotations.getRequired("annotations")

/**
* @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 logprobs(): List<Logprob> = logprobs.getRequired("logprobs")

/**
* The text output from the model.
*
Expand All @@ -87,6 +81,12 @@ private constructor(
*/
@JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type

/**
* @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun logprobs(): Optional<List<Logprob>> = logprobs.getOptional("logprobs")

/**
* Returns the raw JSON value of [annotations].
*
Expand All @@ -97,18 +97,18 @@ private constructor(
fun _annotations(): JsonField<List<Annotation>> = annotations

/**
* Returns the raw JSON value of [logprobs].
* Returns the raw JSON value of [text].
*
* Unlike [logprobs], this method doesn't throw if the JSON field has an unexpected type.
* Unlike [text], this method doesn't throw if the JSON field has an unexpected type.
*/
@JsonProperty("logprobs") @ExcludeMissing fun _logprobs(): JsonField<List<Logprob>> = logprobs
@JsonProperty("text") @ExcludeMissing fun _text(): JsonField<String> = text

/**
* Returns the raw JSON value of [text].
* Returns the raw JSON value of [logprobs].
*
* Unlike [text], this method doesn't throw if the JSON field has an unexpected type.
* Unlike [logprobs], this method doesn't throw if the JSON field has an unexpected type.
*/
@JsonProperty("text") @ExcludeMissing fun _text(): JsonField<String> = text
@JsonProperty("logprobs") @ExcludeMissing fun _logprobs(): JsonField<List<Logprob>> = logprobs

@JsonAnySetter
private fun putAdditionalProperty(key: String, value: JsonValue) {
Expand All @@ -130,7 +130,6 @@ private constructor(
* The following fields are required:
* ```java
* .annotations()
* .logprobs()
* .text()
* ```
*/
Expand All @@ -141,17 +140,17 @@ private constructor(
class Builder internal constructor() {

private var annotations: JsonField<MutableList<Annotation>>? = null
private var logprobs: JsonField<MutableList<Logprob>>? = null
private var text: JsonField<String>? = null
private var type: JsonValue = JsonValue.from("output_text")
private var logprobs: JsonField<MutableList<Logprob>>? = null
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()

@JvmSynthetic
internal fun from(responseOutputText: ResponseOutputText) = apply {
annotations = responseOutputText.annotations.map { it.toMutableList() }
logprobs = responseOutputText.logprobs.map { it.toMutableList() }
text = responseOutputText.text
type = responseOutputText.type
logprobs = responseOutputText.logprobs.map { it.toMutableList() }
additionalProperties = responseOutputText.additionalProperties.toMutableMap()
}

Expand Down Expand Up @@ -200,31 +199,6 @@ private constructor(
fun addAnnotation(filePath: Annotation.FilePath) =
addAnnotation(Annotation.ofFilePath(filePath))

fun logprobs(logprobs: List<Logprob>) = logprobs(JsonField.of(logprobs))

/**
* Sets [Builder.logprobs] to an arbitrary JSON value.
*
* You should usually call [Builder.logprobs] with a well-typed `List<Logprob>` value
* instead. This method is primarily for setting the field to an undocumented or not yet
* supported value.
*/
fun logprobs(logprobs: JsonField<List<Logprob>>) = apply {
this.logprobs = logprobs.map { it.toMutableList() }
}

/**
* Adds a single [Logprob] to [logprobs].
*
* @throws IllegalStateException if the field was previously set to a non-list.
*/
fun addLogprob(logprob: Logprob) = apply {
logprobs =
(logprobs ?: JsonField.of(mutableListOf())).also {
checkKnown("logprobs", it).add(logprob)
}
}

/** The text output from the model. */
fun text(text: String) = text(JsonField.of(text))

Expand All @@ -250,6 +224,31 @@ private constructor(
*/
fun type(type: JsonValue) = apply { this.type = type }

fun logprobs(logprobs: List<Logprob>) = logprobs(JsonField.of(logprobs))

/**
* Sets [Builder.logprobs] to an arbitrary JSON value.
*
* You should usually call [Builder.logprobs] with a well-typed `List<Logprob>` value
* instead. This method is primarily for setting the field to an undocumented or not yet
* supported value.
*/
fun logprobs(logprobs: JsonField<List<Logprob>>) = apply {
this.logprobs = logprobs.map { it.toMutableList() }
}

/**
* Adds a single [Logprob] to [logprobs].
*
* @throws IllegalStateException if the field was previously set to a non-list.
*/
fun addLogprob(logprob: Logprob) = apply {
logprobs =
(logprobs ?: JsonField.of(mutableListOf())).also {
checkKnown("logprobs", it).add(logprob)
}
}

fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
Expand Down Expand Up @@ -277,7 +276,6 @@ private constructor(
* The following fields are required:
* ```java
* .annotations()
* .logprobs()
* .text()
* ```
*
Expand All @@ -286,9 +284,9 @@ private constructor(
fun build(): ResponseOutputText =
ResponseOutputText(
checkRequired("annotations", annotations).map { it.toImmutable() },
checkRequired("logprobs", logprobs).map { it.toImmutable() },
checkRequired("text", text),
type,
(logprobs ?: JsonMissing.of()).map { it.toImmutable() },
additionalProperties.toMutableMap(),
)
}
Expand All @@ -301,13 +299,13 @@ private constructor(
}

annotations().forEach { it.validate() }
logprobs().forEach { it.validate() }
text()
_type().let {
if (it != JsonValue.from("output_text")) {
throw OpenAIInvalidDataException("'type' is invalid, received $it")
}
}
logprobs().ifPresent { it.forEach { it.validate() } }
validated = true
}

Expand All @@ -327,9 +325,9 @@ private constructor(
@JvmSynthetic
internal fun validity(): Int =
(annotations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
(logprobs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
(if (text.asKnown().isPresent) 1 else 0) +
type.let { if (it == JsonValue.from("output_text")) 1 else 0 }
type.let { if (it == JsonValue.from("output_text")) 1 else 0 } +
(logprobs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0)

/** A citation to a file. */
@JsonDeserialize(using = Annotation.Deserializer::class)
Expand Down Expand Up @@ -2394,18 +2392,18 @@ private constructor(

return other is ResponseOutputText &&
annotations == other.annotations &&
logprobs == other.logprobs &&
text == other.text &&
type == other.type &&
logprobs == other.logprobs &&
additionalProperties == other.additionalProperties
}

private val hashCode: Int by lazy {
Objects.hash(annotations, logprobs, text, type, additionalProperties)
Objects.hash(annotations, text, type, logprobs, additionalProperties)
}

override fun hashCode(): Int = hashCode

override fun toString() =
"ResponseOutputText{annotations=$annotations, logprobs=$logprobs, text=$text, type=$type, additionalProperties=$additionalProperties}"
"ResponseOutputText{annotations=$annotations, text=$text, type=$type, logprobs=$logprobs, additionalProperties=$additionalProperties}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ internal class ResponseCompletedEventTest {
.index(0L)
.build()
)
.text("text")
.addLogprob(
ResponseOutputText.Logprob.builder()
.token("token")
Expand All @@ -66,7 +67,6 @@ internal class ResponseCompletedEventTest {
)
.build()
)
.text("text")
.build()
)
.status(ResponseOutputMessage.Status.IN_PROGRESS)
Expand Down Expand Up @@ -181,6 +181,7 @@ internal class ResponseCompletedEventTest {
.index(0L)
.build()
)
.text("text")
.addLogprob(
ResponseOutputText.Logprob.builder()
.token("token")
Expand All @@ -195,7 +196,6 @@ internal class ResponseCompletedEventTest {
)
.build()
)
.text("text")
.build()
)
.status(ResponseOutputMessage.Status.IN_PROGRESS)
Expand Down Expand Up @@ -312,6 +312,7 @@ internal class ResponseCompletedEventTest {
.index(0L)
.build()
)
.text("text")
.addLogprob(
ResponseOutputText.Logprob.builder()
.token("token")
Expand All @@ -326,7 +327,6 @@ internal class ResponseCompletedEventTest {
)
.build()
)
.text("text")
.build()
)
.status(ResponseOutputMessage.Status.IN_PROGRESS)
Expand Down
Loading
Loading