Skip to content

Commit 560093c

Browse files
release: 0.43.0 (#390)
* chore(internal): codegen related update (#389) * feat(api): manual updates * feat(client): expose request body setter and getter (#392) * release: 0.43.0 --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
1 parent faad046 commit 560093c

File tree

55 files changed

+565
-78
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+565
-78
lines changed

.release-please-manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.42.0"
2+
".": "0.43.0"
33
}

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 80
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-4bce8217a697c729ac98046d4caf2c9e826b54c427fb0ab4f98e549a2e0ce31c.yml
33
openapi_spec_hash: 7996d2c34cc44fe2ce9ffe93c0ab774e
4-
config_hash: 178ba1bfb1237bf6b94abb3408072aa7
4+
config_hash: 578c5bff4208d560c0c280f13324409f

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
## 0.43.0 (2025-04-02)
4+
5+
Full Changelog: [v0.42.0...v0.43.0](https://github.com/openai/openai-java/compare/v0.42.0...v0.43.0)
6+
7+
### Features
8+
9+
* **api:** manual updates ([9679525](https://github.com/openai/openai-java/commit/967952553d5fd2e7f47cd7c82fac45cc9dcef43e))
10+
* **client:** expose request body setter and getter ([#392](https://github.com/openai/openai-java/issues/392)) ([eaa0bc9](https://github.com/openai/openai-java/commit/eaa0bc96ba8898e064709a571e97d6b99f478597))
11+
12+
13+
### Chores
14+
15+
* **internal:** codegen related update ([#389](https://github.com/openai/openai-java/issues/389)) ([b0e9d31](https://github.com/openai/openai-java/commit/b0e9d316bde7866f0d6c9381a5bec5a6667f46f6))
16+
317
## 0.42.0 (2025-04-02)
418

519
Full Changelog: [v0.41.1...v0.42.0](https://github.com/openai/openai-java/compare/v0.41.1...v0.42.0)

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
1010
<!-- x-release-please-start-version -->
1111

12-
[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/0.42.0)
13-
[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/0.42.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/0.42.0)
12+
[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/0.43.0)
13+
[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/0.43.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/0.43.0)
1414

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

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

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

21-
The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are also available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/0.42.0).
21+
The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are also available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/0.43.0).
2222

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

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

3131
```kotlin
32-
implementation("com.openai:openai-java:0.42.0")
32+
implementation("com.openai:openai-java:0.43.0")
3333
```
3434

3535
### Maven
@@ -38,7 +38,7 @@ implementation("com.openai:openai-java:0.42.0")
3838
<dependency>
3939
<groupId>com.openai</groupId>
4040
<artifactId>openai-java</artifactId>
41-
<version>0.42.0</version>
41+
<version>0.43.0</version>
4242
</dependency>
4343
```
4444

build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repositories {
88

99
allprojects {
1010
group = "com.openai"
11-
version = "0.42.0" // x-release-please-version
11+
version = "0.43.0" // x-release-please-version
1212
}
1313

1414
subprojects {

openai-java-core/src/main/kotlin/com/openai/core/ObjectMappers.kt

+62-2
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,40 @@ package com.openai.core
44

55
import com.fasterxml.jackson.annotation.JsonInclude
66
import com.fasterxml.jackson.core.JsonGenerator
7+
import com.fasterxml.jackson.core.JsonParseException
8+
import com.fasterxml.jackson.core.JsonParser
9+
import com.fasterxml.jackson.databind.DeserializationContext
710
import com.fasterxml.jackson.databind.DeserializationFeature
811
import com.fasterxml.jackson.databind.MapperFeature
912
import com.fasterxml.jackson.databind.SerializationFeature
1013
import com.fasterxml.jackson.databind.SerializerProvider
1114
import com.fasterxml.jackson.databind.cfg.CoercionAction
1215
import com.fasterxml.jackson.databind.cfg.CoercionInputShape
16+
import com.fasterxml.jackson.databind.deser.std.StdDeserializer
1317
import com.fasterxml.jackson.databind.json.JsonMapper
1418
import com.fasterxml.jackson.databind.module.SimpleModule
1519
import com.fasterxml.jackson.databind.type.LogicalType
1620
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module
1721
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
1822
import com.fasterxml.jackson.module.kotlin.kotlinModule
1923
import java.io.InputStream
24+
import java.time.DateTimeException
25+
import java.time.LocalDate
26+
import java.time.LocalDateTime
27+
import java.time.ZonedDateTime
28+
import java.time.format.DateTimeFormatter
29+
import java.time.temporal.ChronoField
2030

2131
fun jsonMapper(): JsonMapper =
2232
JsonMapper.builder()
2333
.addModule(kotlinModule())
2434
.addModule(Jdk8Module())
2535
.addModule(JavaTimeModule())
26-
.addModule(SimpleModule().addSerializer(InputStreamJsonSerializer))
36+
.addModule(
37+
SimpleModule()
38+
.addSerializer(InputStreamSerializer)
39+
.addDeserializer(LocalDateTime::class.java, LenientLocalDateTimeDeserializer())
40+
)
2741
.withCoercionConfig(LogicalType.Boolean) {
2842
it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail)
2943
.setCoercion(CoercionInputShape.Float, CoercionAction.Fail)
@@ -91,7 +105,10 @@ fun jsonMapper(): JsonMapper =
91105
.disable(MapperFeature.AUTO_DETECT_SETTERS)
92106
.build()
93107

94-
private object InputStreamJsonSerializer : BaseSerializer<InputStream>(InputStream::class) {
108+
/** A serializer that serializes [InputStream] to bytes. */
109+
private object InputStreamSerializer : BaseSerializer<InputStream>(InputStream::class) {
110+
111+
private fun readResolve(): Any = InputStreamSerializer
95112

96113
override fun serialize(
97114
value: InputStream?,
@@ -105,3 +122,46 @@ private object InputStreamJsonSerializer : BaseSerializer<InputStream>(InputStre
105122
}
106123
}
107124
}
125+
126+
/**
127+
* A deserializer that can deserialize [LocalDateTime] from datetimes, dates, and zoned datetimes.
128+
*/
129+
private class LenientLocalDateTimeDeserializer :
130+
StdDeserializer<LocalDateTime>(LocalDateTime::class.java) {
131+
132+
companion object {
133+
134+
private val DATE_TIME_FORMATTERS =
135+
listOf(
136+
DateTimeFormatter.ISO_LOCAL_DATE_TIME,
137+
DateTimeFormatter.ISO_LOCAL_DATE,
138+
DateTimeFormatter.ISO_ZONED_DATE_TIME,
139+
)
140+
}
141+
142+
override fun logicalType(): LogicalType = LogicalType.DateTime
143+
144+
override fun deserialize(p: JsonParser, context: DeserializationContext?): LocalDateTime {
145+
val exceptions = mutableListOf<Exception>()
146+
147+
for (formatter in DATE_TIME_FORMATTERS) {
148+
try {
149+
val temporal = formatter.parse(p.text)
150+
151+
return when {
152+
!temporal.isSupported(ChronoField.HOUR_OF_DAY) ->
153+
LocalDate.from(temporal).atStartOfDay()
154+
!temporal.isSupported(ChronoField.OFFSET_SECONDS) ->
155+
LocalDateTime.from(temporal)
156+
else -> ZonedDateTime.from(temporal).toLocalDateTime()
157+
}
158+
} catch (e: DateTimeException) {
159+
exceptions.add(e)
160+
}
161+
}
162+
163+
throw JsonParseException(p, "Cannot parse `LocalDateTime` from value: ${p.text}").apply {
164+
exceptions.forEach { addSuppressed(it) }
165+
}
166+
}
167+
}

openai-java-core/src/main/kotlin/com/openai/models/audio/speech/SpeechCreateParams.kt

+15-1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,20 @@ private constructor(
161161
additionalQueryParams = speechCreateParams.additionalQueryParams.toBuilder()
162162
}
163163

164+
/**
165+
* Sets the entire request body.
166+
*
167+
* This is generally only useful if you are already constructing the body separately.
168+
* Otherwise, it's more convenient to use the top-level setters instead:
169+
* - [input]
170+
* - [model]
171+
* - [voice]
172+
* - [instructions]
173+
* - [responseFormat]
174+
* - etc.
175+
*/
176+
fun body(body: Body) = apply { this.body = body.toBuilder() }
177+
164178
/** The text to generate audio for. The maximum length is 4096 characters. */
165179
fun input(input: String) = apply { body.input(input) }
166180

@@ -408,7 +422,7 @@ private constructor(
408422
)
409423
}
410424

411-
@JvmSynthetic internal fun _body(): Body = body
425+
fun _body(): Body = body
412426

413427
override fun _headers(): Headers = additionalHeaders
414428

openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionCreateParams.kt

+15-2
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,20 @@ private constructor(
208208
additionalQueryParams = transcriptionCreateParams.additionalQueryParams.toBuilder()
209209
}
210210

211+
/**
212+
* Sets the entire request body.
213+
*
214+
* This is generally only useful if you are already constructing the body separately.
215+
* Otherwise, it's more convenient to use the top-level setters instead:
216+
* - [file]
217+
* - [model]
218+
* - [include]
219+
* - [language]
220+
* - [prompt]
221+
* - etc.
222+
*/
223+
fun body(body: Body) = apply { this.body = body.toBuilder() }
224+
211225
/**
212226
* The audio file object (not file name) to transcribe, in one of these formats: flac, mp3,
213227
* mp4, mpeg, mpga, m4a, ogg, wav, or webm.
@@ -503,8 +517,7 @@ private constructor(
503517
)
504518
}
505519

506-
@JvmSynthetic
507-
internal fun _body(): Map<String, MultipartField<*>> =
520+
fun _body(): Map<String, MultipartField<*>> =
508521
mapOf(
509522
"file" to _file(),
510523
"model" to _model(),

openai-java-core/src/main/kotlin/com/openai/models/audio/translations/TranslationCreateParams.kt

+15-2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,20 @@ private constructor(
149149
additionalQueryParams = translationCreateParams.additionalQueryParams.toBuilder()
150150
}
151151

152+
/**
153+
* Sets the entire request body.
154+
*
155+
* This is generally only useful if you are already constructing the body separately.
156+
* Otherwise, it's more convenient to use the top-level setters instead:
157+
* - [file]
158+
* - [model]
159+
* - [prompt]
160+
* - [responseFormat]
161+
* - [temperature]
162+
* - etc.
163+
*/
164+
fun body(body: Body) = apply { this.body = body.toBuilder() }
165+
152166
/**
153167
* The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4,
154168
* mpeg, mpga, m4a, ogg, wav, or webm.
@@ -372,8 +386,7 @@ private constructor(
372386
)
373387
}
374388

375-
@JvmSynthetic
376-
internal fun _body(): Map<String, MultipartField<*>> =
389+
fun _body(): Map<String, MultipartField<*>> =
377390
mapOf(
378391
"file" to _file(),
379392
"model" to _model(),

openai-java-core/src/main/kotlin/com/openai/models/batches/BatchCancelParams.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ private constructor(
206206
)
207207
}
208208

209-
@JvmSynthetic
210-
internal fun _body(): Optional<Map<String, JsonValue>> =
209+
fun _body(): Optional<Map<String, JsonValue>> =
211210
Optional.ofNullable(additionalBodyProperties.ifEmpty { null })
212211

213212
fun _pathParam(index: Int): String =

openai-java-core/src/main/kotlin/com/openai/models/batches/BatchCreateParams.kt

+13-1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,18 @@ private constructor(
144144
additionalQueryParams = batchCreateParams.additionalQueryParams.toBuilder()
145145
}
146146

147+
/**
148+
* Sets the entire request body.
149+
*
150+
* This is generally only useful if you are already constructing the body separately.
151+
* Otherwise, it's more convenient to use the top-level setters instead:
152+
* - [completionWindow]
153+
* - [endpoint]
154+
* - [inputFileId]
155+
* - [metadata]
156+
*/
157+
fun body(body: Body) = apply { this.body = body.toBuilder() }
158+
147159
/**
148160
* The time frame within which the batch should be processed. Currently only `24h` is
149161
* supported.
@@ -363,7 +375,7 @@ private constructor(
363375
)
364376
}
365377

366-
@JvmSynthetic internal fun _body(): Body = body
378+
fun _body(): Body = body
367379

368380
override fun _headers(): Headers = additionalHeaders
369381

openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantCreateParams.kt

+15-1
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,20 @@ private constructor(
285285
additionalQueryParams = assistantCreateParams.additionalQueryParams.toBuilder()
286286
}
287287

288+
/**
289+
* Sets the entire request body.
290+
*
291+
* This is generally only useful if you are already constructing the body separately.
292+
* Otherwise, it's more convenient to use the top-level setters instead:
293+
* - [model]
294+
* - [description]
295+
* - [instructions]
296+
* - [metadata]
297+
* - [name]
298+
* - etc.
299+
*/
300+
fun body(body: Body) = apply { this.body = body.toBuilder() }
301+
288302
/**
289303
* ID of the model to use. You can use the
290304
* [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all
@@ -728,7 +742,7 @@ private constructor(
728742
)
729743
}
730744

731-
@JvmSynthetic internal fun _body(): Body = body
745+
fun _body(): Body = body
732746

733747
override fun _headers(): Headers = additionalHeaders
734748

openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantDeleteParams.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ private constructor(
202202
)
203203
}
204204

205-
@JvmSynthetic
206-
internal fun _body(): Optional<Map<String, JsonValue>> =
205+
fun _body(): Optional<Map<String, JsonValue>> =
207206
Optional.ofNullable(additionalBodyProperties.ifEmpty { null })
208207

209208
fun _pathParam(index: Int): String =

openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantUpdateParams.kt

+15-1
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,20 @@ private constructor(
282282

283283
fun assistantId(assistantId: String) = apply { this.assistantId = assistantId }
284284

285+
/**
286+
* Sets the entire request body.
287+
*
288+
* This is generally only useful if you are already constructing the body separately.
289+
* Otherwise, it's more convenient to use the top-level setters instead:
290+
* - [description]
291+
* - [instructions]
292+
* - [metadata]
293+
* - [model]
294+
* - [name]
295+
* - etc.
296+
*/
297+
fun body(body: Body) = apply { this.body = body.toBuilder() }
298+
285299
/** The description of the assistant. The maximum length is 512 characters. */
286300
fun description(description: String?) = apply { body.description(description) }
287301

@@ -726,7 +740,7 @@ private constructor(
726740
)
727741
}
728742

729-
@JvmSynthetic internal fun _body(): Body = body
743+
fun _body(): Body = body
730744

731745
fun _pathParam(index: Int): String =
732746
when (index) {

0 commit comments

Comments
 (0)