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.11.9"
".": "0.11.10"
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.11.10 (2025-01-21)

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

### Bug Fixes

* **client:** add missing default headers ([#145](https://github.com/openai/openai-java/issues/145)) ([18d5270](https://github.com/openai/openai-java/commit/18d5270326561ca8e5f10b5a671da1d30ced5993))

## 0.11.9 (2025-01-21)

Full Changelog: [v0.11.8...v0.11.9](https://github.com/openai/openai-java/compare/v0.11.8...v0.11.9)
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.11.9)
[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/0.11.9/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/0.11.8)
[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/0.11.10)
[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/0.11.10/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/0.11.10)

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

Expand All @@ -31,7 +31,7 @@ The REST API documentation can be found on [platform.openai.com](https://platfo
<!-- x-release-please-start-version -->

```kotlin
implementation("com.openai:openai-java:0.11.9")
implementation("com.openai:openai-java:0.11.10")
```

#### Maven
Expand All @@ -40,7 +40,7 @@ implementation("com.openai:openai-java:0.11.9")
<dependency>
<groupId>com.openai</groupId>
<artifactId>openai-java</artifactId>
<version>0.11.9</version>
<version>0.11.10</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.11.9" // x-release-please-version
version = "0.11.10" // x-release-please-version
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package com.openai.services.async

import com.openai.core.ClientOptions
import com.openai.core.http.Headers
import com.openai.services.async.beta.AssistantServiceAsync
import com.openai.services.async.beta.AssistantServiceAsyncImpl
import com.openai.services.async.beta.ThreadServiceAsync
Expand All @@ -15,6 +16,11 @@ internal constructor(
private val clientOptions: ClientOptions,
) : BetaServiceAsync {

companion object {

private val DEFAULT_HEADERS = Headers.builder().put("OpenAI-Beta", "assistants=v2").build()
}

private val vectorStores: VectorStoreServiceAsync by lazy {
VectorStoreServiceAsyncImpl(clientOptions)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.openai.core.RequestOptions
import com.openai.core.handlers.errorHandler
import com.openai.core.handlers.jsonHandler
import com.openai.core.handlers.withErrorHandler
import com.openai.core.http.Headers
import com.openai.core.http.HttpMethod
import com.openai.core.http.HttpRequest
import com.openai.core.http.HttpResponse.Handler
Expand All @@ -27,6 +28,11 @@ internal constructor(
private val clientOptions: ClientOptions,
) : AssistantServiceAsync {

companion object {

private val DEFAULT_HEADERS = Headers.builder().put("OpenAI-Beta", "assistants=v2").build()
}

private val errorHandler: Handler<OpenAIError> = errorHandler(clientOptions.jsonMapper)

private val createHandler: Handler<Assistant> =
Expand All @@ -44,6 +50,7 @@ internal constructor(
.putAllQueryParams(clientOptions.queryParams)
.replaceAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.replaceAllHeaders(DEFAULT_HEADERS)
.replaceAllHeaders(params.getHeaders())
.body(json(clientOptions.jsonMapper, params.getBody()))
.build()
Expand Down Expand Up @@ -74,6 +81,7 @@ internal constructor(
.putAllQueryParams(clientOptions.queryParams)
.replaceAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.replaceAllHeaders(DEFAULT_HEADERS)
.replaceAllHeaders(params.getHeaders())
.build()
return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response
Expand Down Expand Up @@ -103,6 +111,7 @@ internal constructor(
.putAllQueryParams(clientOptions.queryParams)
.replaceAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.replaceAllHeaders(DEFAULT_HEADERS)
.replaceAllHeaders(params.getHeaders())
.body(json(clientOptions.jsonMapper, params.getBody()))
.build()
Expand Down Expand Up @@ -134,6 +143,7 @@ internal constructor(
.putAllQueryParams(clientOptions.queryParams)
.replaceAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.replaceAllHeaders(DEFAULT_HEADERS)
.replaceAllHeaders(params.getHeaders())
.build()
return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response
Expand Down Expand Up @@ -164,6 +174,7 @@ internal constructor(
.putAllQueryParams(clientOptions.queryParams)
.replaceAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.replaceAllHeaders(DEFAULT_HEADERS)
.replaceAllHeaders(params.getHeaders())
.apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } }
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.openai.core.handlers.mapJson
import com.openai.core.handlers.sseHandler
import com.openai.core.handlers.withErrorHandler
import com.openai.core.http.AsyncStreamResponse
import com.openai.core.http.Headers
import com.openai.core.http.HttpMethod
import com.openai.core.http.HttpRequest
import com.openai.core.http.HttpResponse.Handler
Expand Down Expand Up @@ -39,6 +40,11 @@ internal constructor(
private val clientOptions: ClientOptions,
) : ThreadServiceAsync {

companion object {

private val DEFAULT_HEADERS = Headers.builder().put("OpenAI-Beta", "assistants=v2").build()
}

private val errorHandler: Handler<OpenAIError> = errorHandler(clientOptions.jsonMapper)

private val runs: RunServiceAsync by lazy { RunServiceAsyncImpl(clientOptions) }
Expand All @@ -64,6 +70,7 @@ internal constructor(
.putAllQueryParams(clientOptions.queryParams)
.replaceAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.replaceAllHeaders(DEFAULT_HEADERS)
.replaceAllHeaders(params.getHeaders())
.body(json(clientOptions.jsonMapper, params.getBody()))
.build()
Expand Down Expand Up @@ -94,6 +101,7 @@ internal constructor(
.putAllQueryParams(clientOptions.queryParams)
.replaceAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.replaceAllHeaders(DEFAULT_HEADERS)
.replaceAllHeaders(params.getHeaders())
.build()
return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response
Expand Down Expand Up @@ -123,6 +131,7 @@ internal constructor(
.putAllQueryParams(clientOptions.queryParams)
.replaceAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.replaceAllHeaders(DEFAULT_HEADERS)
.replaceAllHeaders(params.getHeaders())
.body(json(clientOptions.jsonMapper, params.getBody()))
.build()
Expand Down Expand Up @@ -153,6 +162,7 @@ internal constructor(
.putAllQueryParams(clientOptions.queryParams)
.replaceAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.replaceAllHeaders(DEFAULT_HEADERS)
.replaceAllHeaders(params.getHeaders())
.apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } }
.build()
Expand Down Expand Up @@ -183,6 +193,7 @@ internal constructor(
.putAllQueryParams(clientOptions.queryParams)
.replaceAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.replaceAllHeaders(DEFAULT_HEADERS)
.replaceAllHeaders(params.getHeaders())
.body(json(clientOptions.jsonMapper, params.getBody()))
.build()
Expand Down Expand Up @@ -215,6 +226,7 @@ internal constructor(
.putAllQueryParams(clientOptions.queryParams)
.replaceAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.replaceAllHeaders(DEFAULT_HEADERS)
.replaceAllHeaders(params.getHeaders())
.body(
json(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.openai.core.RequestOptions
import com.openai.core.handlers.errorHandler
import com.openai.core.handlers.jsonHandler
import com.openai.core.handlers.withErrorHandler
import com.openai.core.http.Headers
import com.openai.core.http.HttpMethod
import com.openai.core.http.HttpRequest
import com.openai.core.http.HttpResponse.Handler
Expand All @@ -31,6 +32,11 @@ internal constructor(
private val clientOptions: ClientOptions,
) : VectorStoreServiceAsync {

companion object {

private val DEFAULT_HEADERS = Headers.builder().put("OpenAI-Beta", "assistants=v2").build()
}

private val errorHandler: Handler<OpenAIError> = errorHandler(clientOptions.jsonMapper)

private val files: FileServiceAsync by lazy { FileServiceAsyncImpl(clientOptions) }
Expand Down Expand Up @@ -58,6 +64,7 @@ internal constructor(
.putAllQueryParams(clientOptions.queryParams)
.replaceAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.replaceAllHeaders(DEFAULT_HEADERS)
.replaceAllHeaders(params.getHeaders())
.body(json(clientOptions.jsonMapper, params.getBody()))
.build()
Expand Down Expand Up @@ -88,6 +95,7 @@ internal constructor(
.putAllQueryParams(clientOptions.queryParams)
.replaceAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.replaceAllHeaders(DEFAULT_HEADERS)
.replaceAllHeaders(params.getHeaders())
.build()
return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response
Expand Down Expand Up @@ -117,6 +125,7 @@ internal constructor(
.putAllQueryParams(clientOptions.queryParams)
.replaceAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.replaceAllHeaders(DEFAULT_HEADERS)
.replaceAllHeaders(params.getHeaders())
.body(json(clientOptions.jsonMapper, params.getBody()))
.build()
Expand Down Expand Up @@ -148,6 +157,7 @@ internal constructor(
.putAllQueryParams(clientOptions.queryParams)
.replaceAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.replaceAllHeaders(DEFAULT_HEADERS)
.replaceAllHeaders(params.getHeaders())
.build()
return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response
Expand Down Expand Up @@ -178,6 +188,7 @@ internal constructor(
.putAllQueryParams(clientOptions.queryParams)
.replaceAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.replaceAllHeaders(DEFAULT_HEADERS)
.replaceAllHeaders(params.getHeaders())
.apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } }
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.openai.core.RequestOptions
import com.openai.core.handlers.errorHandler
import com.openai.core.handlers.jsonHandler
import com.openai.core.handlers.withErrorHandler
import com.openai.core.http.Headers
import com.openai.core.http.HttpMethod
import com.openai.core.http.HttpRequest
import com.openai.core.http.HttpResponse.Handler
Expand All @@ -27,6 +28,11 @@ internal constructor(
private val clientOptions: ClientOptions,
) : MessageServiceAsync {

companion object {

private val DEFAULT_HEADERS = Headers.builder().put("OpenAI-Beta", "assistants=v2").build()
}

private val errorHandler: Handler<OpenAIError> = errorHandler(clientOptions.jsonMapper)

private val createHandler: Handler<Message> =
Expand All @@ -44,6 +50,7 @@ internal constructor(
.putAllQueryParams(clientOptions.queryParams)
.replaceAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.replaceAllHeaders(DEFAULT_HEADERS)
.replaceAllHeaders(params.getHeaders())
.body(json(clientOptions.jsonMapper, params.getBody()))
.build()
Expand Down Expand Up @@ -79,6 +86,7 @@ internal constructor(
.putAllQueryParams(clientOptions.queryParams)
.replaceAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.replaceAllHeaders(DEFAULT_HEADERS)
.replaceAllHeaders(params.getHeaders())
.build()
return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response
Expand Down Expand Up @@ -113,6 +121,7 @@ internal constructor(
.putAllQueryParams(clientOptions.queryParams)
.replaceAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.replaceAllHeaders(DEFAULT_HEADERS)
.replaceAllHeaders(params.getHeaders())
.body(json(clientOptions.jsonMapper, params.getBody()))
.build()
Expand Down Expand Up @@ -144,6 +153,7 @@ internal constructor(
.putAllQueryParams(clientOptions.queryParams)
.replaceAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.replaceAllHeaders(DEFAULT_HEADERS)
.replaceAllHeaders(params.getHeaders())
.build()
return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response
Expand Down Expand Up @@ -179,6 +189,7 @@ internal constructor(
.putAllQueryParams(clientOptions.queryParams)
.replaceAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.replaceAllHeaders(DEFAULT_HEADERS)
.replaceAllHeaders(params.getHeaders())
.apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } }
.build()
Expand Down
Loading
Loading