diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 059887474..091cfb127 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "0.9.1"
+ ".": "0.10.0"
}
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index eb5d3722b..7fede91ab 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,34 @@
# Changelog
+## 0.10.0 (2025-01-08)
+
+Full Changelog: [v0.9.1...v0.10.0](https://github.com/openai/openai-java/compare/v0.9.1...v0.10.0)
+
+### Features
+
+* **client:** add various convenience setters to models ([#91](https://github.com/openai/openai-java/issues/91)) ([9b3eb17](https://github.com/openai/openai-java/commit/9b3eb17270075587ac9c2701b0e41a7debf17bec))
+* **client:** allow passing null or optional for nullable fields ([#84](https://github.com/openai/openai-java/issues/84)) ([8a8f2f9](https://github.com/openai/openai-java/commit/8a8f2f9ac5f6555c372a81acc196b3ab04fd9555))
+* **client:** allow setting arbitrary JSON for top-level body params ([9b3eb17](https://github.com/openai/openai-java/commit/9b3eb17270075587ac9c2701b0e41a7debf17bec))
+* **client:** expose getters for `JsonField` of body params ([9b3eb17](https://github.com/openai/openai-java/commit/9b3eb17270075587ac9c2701b0e41a7debf17bec))
+
+
+### Bug Fixes
+
+* **client:** consistently throw on omitting required fields ([9b3eb17](https://github.com/openai/openai-java/commit/9b3eb17270075587ac9c2701b0e41a7debf17bec))
+* **client:** convert `JsonField` containing list type to mutable in builder ([9b3eb17](https://github.com/openai/openai-java/commit/9b3eb17270075587ac9c2701b0e41a7debf17bec))
+
+
+### Documentation
+
+* add params class javadocs ([#90](https://github.com/openai/openai-java/issues/90)) ([9a33c1c](https://github.com/openai/openai-java/commit/9a33c1cf22e30e1878d739acfab4258321c6a9f8))
+
+
+### Styles
+
+* **internal:** explicitly add some method return types ([9b3eb17](https://github.com/openai/openai-java/commit/9b3eb17270075587ac9c2701b0e41a7debf17bec))
+* **internal:** move headers and query params setters below others ([9b3eb17](https://github.com/openai/openai-java/commit/9b3eb17270075587ac9c2701b0e41a7debf17bec))
+* **internal:** simplify existing convenience setters on params ([9b3eb17](https://github.com/openai/openai-java/commit/9b3eb17270075587ac9c2701b0e41a7debf17bec))
+
## 0.9.1 (2025-01-06)
Full Changelog: [v0.9.0...v0.9.1](https://github.com/openai/openai-java/compare/v0.9.0...v0.9.1)
diff --git a/README.md b/README.md
index a933422cd..20818e0aa 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@
-[](https://central.sonatype.com/artifact/com.openai/openai-java/0.9.1)
+[](https://central.sonatype.com/artifact/com.openai/openai-java/0.10.0)
@@ -32,7 +32,7 @@ The REST API documentation can be foundĀ on [platform.openai.com](https://platfo
```kotlin
-implementation("com.openai:openai-java:0.9.1")
+implementation("com.openai:openai-java:0.10.0")
```
#### Maven
@@ -41,7 +41,7 @@ implementation("com.openai:openai-java:0.9.1")
com.openai
openai-java
- 0.9.1
+ 0.10.0
```
diff --git a/build.gradle.kts b/build.gradle.kts
index cef5a8638..f901fcc35 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -4,7 +4,7 @@ plugins {
allprojects {
group = "com.openai"
- version = "0.9.1" // x-release-please-version
+ version = "0.10.0" // x-release-please-version
}
diff --git a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClient.kt b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClient.kt
index 0a01dc68e..025640fd1 100644
--- a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClient.kt
+++ b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClient.kt
@@ -13,6 +13,7 @@ import com.openai.credential.Credential
import java.net.Proxy
import java.time.Clock
import java.time.Duration
+import java.util.Optional
class OpenAIOkHttpClient private constructor() {
@@ -138,9 +139,13 @@ class OpenAIOkHttpClient private constructor() {
clientOptions.azureServiceVersion(azureServiceVersion)
}
- fun organization(organization: String) = apply { clientOptions.organization(organization) }
+ fun organization(organization: String?) = apply { clientOptions.organization(organization) }
- fun project(project: String) = apply { clientOptions.project(project) }
+ fun organization(organization: Optional) = organization(organization.orElse(null))
+
+ fun project(project: String?) = apply { clientOptions.project(project) }
+
+ fun project(project: Optional) = project(project.orElse(null))
fun fromEnv() = apply { clientOptions.fromEnv() }
diff --git a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClientAsync.kt b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClientAsync.kt
index e88af6969..20753d76c 100644
--- a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClientAsync.kt
+++ b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClientAsync.kt
@@ -13,6 +13,7 @@ import com.openai.credential.Credential
import java.net.Proxy
import java.time.Clock
import java.time.Duration
+import java.util.Optional
class OpenAIOkHttpClientAsync private constructor() {
@@ -138,9 +139,13 @@ class OpenAIOkHttpClientAsync private constructor() {
clientOptions.azureServiceVersion(azureServiceVersion)
}
- fun organization(organization: String) = apply { clientOptions.organization(organization) }
+ fun organization(organization: String?) = apply { clientOptions.organization(organization) }
- fun project(project: String) = apply { clientOptions.project(project) }
+ fun organization(organization: Optional) = organization(organization.orElse(null))
+
+ fun project(project: String?) = apply { clientOptions.project(project) }
+
+ fun project(project: Optional) = project(project.orElse(null))
fun fromEnv() = apply { clientOptions.fromEnv() }
diff --git a/openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt b/openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt
index aa08c1c77..da2250553 100644
--- a/openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt
@@ -14,6 +14,7 @@ import com.openai.core.http.RetryingHttpClient
import com.openai.credential.BearerTokenCredential
import com.openai.credential.Credential
import java.time.Clock
+import java.util.Optional
import java.util.concurrent.Executor
import java.util.concurrent.Executors
import java.util.concurrent.ThreadFactory
@@ -91,6 +92,30 @@ private constructor(
fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl }
+ fun responseValidation(responseValidation: Boolean) = apply {
+ this.responseValidation = responseValidation
+ }
+
+ fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries }
+
+ fun apiKey(apiKey: String) = apply {
+ this.credential = BearerTokenCredential.create(apiKey)
+ }
+
+ fun credential(credential: Credential) = apply { this.credential = credential }
+
+ fun azureServiceVersion(azureServiceVersion: AzureOpenAIServiceVersion) = apply {
+ this.azureServiceVersion = azureServiceVersion
+ }
+
+ fun organization(organization: String?) = apply { this.organization = organization }
+
+ fun organization(organization: Optional) = organization(organization.orElse(null))
+
+ fun project(project: String?) = apply { this.project = project }
+
+ fun project(project: Optional) = project(project.orElse(null))
+
fun headers(headers: Headers) = apply {
this.headers.clear()
putAllHeaders(headers)
@@ -171,26 +196,6 @@ private constructor(
fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) }
- fun responseValidation(responseValidation: Boolean) = apply {
- this.responseValidation = responseValidation
- }
-
- fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries }
-
- fun apiKey(apiKey: String) = apply {
- this.credential = BearerTokenCredential.create(apiKey)
- }
-
- fun credential(credential: Credential) = apply { this.credential = credential }
-
- fun azureServiceVersion(azureServiceVersion: AzureOpenAIServiceVersion) = apply {
- this.azureServiceVersion = azureServiceVersion
- }
-
- fun organization(organization: String) = apply { this.organization = organization }
-
- fun project(project: String) = apply { this.project = project }
-
fun fromEnv() = apply {
val openAIKey = System.getenv("OPENAI_API_KEY")
val openAIOrgId = System.getenv("OPENAI_ORG_ID")
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/Assistant.kt b/openai-java-core/src/main/kotlin/com/openai/models/Assistant.kt
index ca2ff1431..4bd3cc004 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/Assistant.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/Assistant.kt
@@ -71,6 +71,13 @@ private constructor(
fun instructions(): Optional =
Optional.ofNullable(instructions.getNullable("instructions"))
+ /**
+ * Set of 16 key-value pairs that can be attached to an object. This can be useful for storing
+ * additional information about the object in a structured format. Keys can be a maximum of 64
+ * characters long and values can be a maximum of 512 characters long.
+ */
+ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata
+
/**
* ID of the model to use. You can use the
* [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all of
@@ -139,25 +146,20 @@ private constructor(
fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p"))
/** The identifier, which can be referenced in API endpoints. */
- @JsonProperty("id") @ExcludeMissing fun _id() = id
+ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id
/** The Unix timestamp (in seconds) for when the assistant was created. */
- @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt
+ @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField = createdAt
/** The description of the assistant. The maximum length is 512 characters. */
- @JsonProperty("description") @ExcludeMissing fun _description() = description
+ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description
/**
* The system instructions that the assistant uses. The maximum length is 256,000 characters.
*/
- @JsonProperty("instructions") @ExcludeMissing fun _instructions() = instructions
-
- /**
- * Set of 16 key-value pairs that can be attached to an object. This can be useful for storing
- * additional information about the object in a structured format. Keys can be a maximum of 64
- * characters long and values can be a maximum of 512 characters long.
- */
- @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata
+ @JsonProperty("instructions")
+ @ExcludeMissing
+ fun _instructions(): JsonField = instructions
/**
* ID of the model to use. You can use the
@@ -165,19 +167,19 @@ private constructor(
* your available models, or see our [Model overview](https://platform.openai.com/docs/models)
* for descriptions of them.
*/
- @JsonProperty("model") @ExcludeMissing fun _model() = model
+ @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model
/** The name of the assistant. The maximum length is 256 characters. */
- @JsonProperty("name") @ExcludeMissing fun _name() = name
+ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name
/** The object type, which is always `assistant`. */
- @JsonProperty("object") @ExcludeMissing fun _object_() = object_
+ @JsonProperty("object") @ExcludeMissing fun _object_(): JsonField