Skip to content

Commit 3a40fb2

Browse files
chore(api): event shapes more accurate
1 parent 82bb2c1 commit 3a40fb2

File tree

54 files changed

+2101
-1458
lines changed

Some content is hidden

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

54 files changed

+2101
-1458
lines changed

.github/workflows/publish-sonatype.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,37 @@ jobs:
2424
- name: Set up Gradle
2525
uses: gradle/gradle-build-action@v2
2626

27+
- name: Compile the openai-java-core project
28+
run: |
29+
./gradlew :openai-java-core:compileJava :openai-java-core:compileTestJava -x test
30+
31+
- name: Run the Prism server
32+
run: |
33+
./scripts/mock --daemon
34+
35+
- name: Setup GraalVM
36+
uses: graalvm/setup-graalvm@v1
37+
with:
38+
java-version: 21
39+
distribution: 'graalvm-community'
40+
cache: gradle
41+
42+
- name: Run tests on the openai-java-core project with the GraalVM native-image agent
43+
run: |
44+
./gradlew :openai-java-core:test -x compileJava -x compileTestJava -x compileKotlin -x compileTestKotlin -PgraalvmAgent
45+
46+
- name: Check generated GraalVM file
47+
run: |
48+
echo "Checking for GraalVM agent metadata files..."
49+
DIRECTORY=openai-java-core/src/main/resources/META-INF/native-image
50+
if [ -d "$DIRECTORY" ] && [ "$(ls -A $DIRECTORY)" ]; then
51+
echo "Files found in $DIRECTORY:"
52+
ls -l $DIRECTORY
53+
else
54+
echo "No files found in $DIRECTORY"
55+
exit 1
56+
fi
57+
2758
- name: Publish to Sonatype
2859
run: |-
2960
export -- GPG_SIGNING_KEY_ID

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 88
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-670ea0d2cc44f52a87dd3cadea45632953283e0636ba30788fdbdb22a232ccac.yml
3-
openapi_spec_hash: d8b7d38911fead545adf3e4297956410
4-
config_hash: b2a4028fdbb27a08de89831ed310e244
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-b2a451656ca64d30d174391ebfd94806b4de3ab76dc55b92843cfb7f1a54ecb6.yml
3+
openapi_spec_hash: 27d9691b400f28c17ef063a1374048b0
4+
config_hash: e822d0c9082c8b312264403949243179

README.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ The REST API documentation can be found on [platform.openai.com](https://platfor
1919

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

22+
[_Try `openai-java-spring-boot-starter` if you're using Spring Boot!_](#spring-boot)
23+
2224
### Gradle
2325

2426
```kotlin
@@ -1302,6 +1304,85 @@ Or to `debug` for more verbose logging:
13021304
$ export OPENAI_LOG=debug
13031305
```
13041306

1307+
## GraalVM
1308+
1309+
Although the SDK uses reflection, it is still usable in [GraalVM](https://www.graalvm.org) because `openai-java-core` is published with [reachability metadata](https://www.graalvm.org/latest/reference-manual/native-image/metadata/).
1310+
1311+
GraalVM should automatically detect and use the published metadata, but [manual configuration](https://www.graalvm.org/jdk24/reference-manual/native-image/overview/BuildConfiguration/) is also available.
1312+
1313+
## Spring Boot
1314+
1315+
If you're using Spring Boot, then you can use the SDK's [Spring Boot starter](https://docs.spring.io/spring-boot/docs/2.7.18/reference/htmlsingle/#using.build-systems.starters) to simplify configuration and get set up quickly.
1316+
1317+
### Installation
1318+
1319+
<!-- x-release-please-start-version -->
1320+
1321+
#### Gradle
1322+
1323+
```kotlin
1324+
implementation("com.openai:openai-java-spring-boot-starter:2.17.0")
1325+
```
1326+
1327+
#### Maven
1328+
1329+
```xml
1330+
<dependency>
1331+
<groupId>com.openai</groupId>
1332+
<artifactId>openai-java-spring-boot-starter</artifactId>
1333+
<version>2.17.0</version>
1334+
</dependency>
1335+
```
1336+
1337+
<!-- x-release-please-end -->
1338+
1339+
### Configuration
1340+
1341+
The [client's environment variable options](#client-configuration) can be configured in [`application.properties` or `application.yml`](https://docs.spring.io/spring-boot/how-to/properties-and-configuration.html).
1342+
1343+
#### `application.properties`
1344+
1345+
```properties
1346+
openai.base-url=https://api.openai.com/v1
1347+
openai.api-key=My API Key
1348+
openai.org-id=My Organization
1349+
openai.project-id=My Project
1350+
openai.webhook-secret=My Webhook Secret
1351+
```
1352+
1353+
#### `application.yml`
1354+
1355+
```yaml
1356+
openai:
1357+
base-url: https://api.openai.com/v1
1358+
api-key: My API Key
1359+
org-id: My Organization
1360+
project-id: My Project
1361+
webhook-secret: My Webhook Secret
1362+
```
1363+
1364+
#### Other configuration
1365+
1366+
Configure any other client option by providing one or more instances of [`OpenAIClientCustomizer`](openai-java-core/src/main/kotlin/com/openai/springboot/OpenAIClientCustomizer.kt). For example, here's how you'd set [`maxRetries`](#retries):
1367+
1368+
```java
1369+
import com.openai.springboot.OpenAIClientCustomizer;
1370+
import org.springframework.context.annotation.Bean;
1371+
import org.springframework.context.annotation.Configuration;
1372+
1373+
@Configuration
1374+
public class OpenAIConfig {
1375+
@Bean
1376+
public OpenAIClientCustomizer customizer() {
1377+
return builder -> builder.maxRetries(3);
1378+
}
1379+
}
1380+
```
1381+
1382+
### Usage
1383+
1384+
[Inject](https://docs.spring.io/spring-framework/reference/core/beans/dependencies/factory-collaborators.html) [`OpenAIClient`](openai-java-core/src/main/kotlin/com/openai/client/OpenAIClient.kt) anywhere and start using it!
1385+
13051386
## Jackson
13061387

13071388
The SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.

openai-java-core/src/main/kotlin/com/openai/helpers/ResponseAccumulator.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ import com.openai.models.responses.ResponseOutputItemAddedEvent
4040
import com.openai.models.responses.ResponseOutputItemDoneEvent
4141
import com.openai.models.responses.ResponseOutputTextAnnotationAddedEvent
4242
import com.openai.models.responses.ResponseQueuedEvent
43-
import com.openai.models.responses.ResponseReasoningDeltaEvent
44-
import com.openai.models.responses.ResponseReasoningDoneEvent
4543
import com.openai.models.responses.ResponseReasoningSummaryDeltaEvent
4644
import com.openai.models.responses.ResponseReasoningSummaryDoneEvent
4745
import com.openai.models.responses.ResponseReasoningSummaryPartAddedEvent
@@ -306,10 +304,6 @@ class ResponseAccumulator private constructor() {
306304
outputTextAnnotationAdded: ResponseOutputTextAnnotationAddedEvent
307305
) {}
308306

309-
override fun visitReasoningDelta(reasoningDelta: ResponseReasoningDeltaEvent) {}
310-
311-
override fun visitReasoningDone(reasoningDone: ResponseReasoningDoneEvent) {}
312-
313307
override fun visitReasoningSummaryDelta(
314308
reasoningSummaryDelta: ResponseReasoningSummaryDeltaEvent
315309
) {}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private constructor(
7373
* Whether to enable strict schema adherence when generating the function call. If set to true,
7474
* the model will follow the exact schema defined in the `parameters` field. Only a subset of
7575
* JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the
76-
* [function calling guide](docs/guides/function-calling).
76+
* [function calling guide](https://platform.openai.com/docs/guides/function-calling).
7777
*
7878
* @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
7979
* server responded with an unexpected value).
@@ -207,7 +207,8 @@ private constructor(
207207
* Whether to enable strict schema adherence when generating the function call. If set to
208208
* true, the model will follow the exact schema defined in the `parameters` field. Only a
209209
* subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured
210-
* Outputs in the [function calling guide](docs/guides/function-calling).
210+
* Outputs in the
211+
* [function calling guide](https://platform.openai.com/docs/guides/function-calling).
211212
*/
212213
fun strict(strict: Boolean?) = strict(JsonField.ofNullable(strict))
213214

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -937,12 +937,6 @@ private constructor(
937937

938938
@JvmField val ECHO = of("echo")
939939

940-
@JvmField val FABLE = of("fable")
941-
942-
@JvmField val ONYX = of("onyx")
943-
944-
@JvmField val NOVA = of("nova")
945-
946940
@JvmField val SAGE = of("sage")
947941

948942
@JvmField val SHIMMER = of("shimmer")
@@ -959,9 +953,6 @@ private constructor(
959953
BALLAD,
960954
CORAL,
961955
ECHO,
962-
FABLE,
963-
ONYX,
964-
NOVA,
965956
SAGE,
966957
SHIMMER,
967958
VERSE,
@@ -982,9 +973,6 @@ private constructor(
982973
BALLAD,
983974
CORAL,
984975
ECHO,
985-
FABLE,
986-
ONYX,
987-
NOVA,
988976
SAGE,
989977
SHIMMER,
990978
VERSE,
@@ -1006,9 +994,6 @@ private constructor(
1006994
BALLAD -> Value.BALLAD
1007995
CORAL -> Value.CORAL
1008996
ECHO -> Value.ECHO
1009-
FABLE -> Value.FABLE
1010-
ONYX -> Value.ONYX
1011-
NOVA -> Value.NOVA
1012997
SAGE -> Value.SAGE
1013998
SHIMMER -> Value.SHIMMER
1014999
VERSE -> Value.VERSE
@@ -1031,9 +1016,6 @@ private constructor(
10311016
BALLAD -> Known.BALLAD
10321017
CORAL -> Known.CORAL
10331018
ECHO -> Known.ECHO
1034-
FABLE -> Known.FABLE
1035-
ONYX -> Known.ONYX
1036-
NOVA -> Known.NOVA
10371019
SAGE -> Known.SAGE
10381020
SHIMMER -> Known.SHIMMER
10391021
VERSE -> Known.VERSE

openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/RealtimeResponse.kt

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ private constructor(
214214

215215
/**
216216
* The voice the model used to respond. Current voice options are `alloy`, `ash`, `ballad`,
217-
* `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and `verse`.
217+
* `coral`, `echo`, `sage`, `shimmer`, and `verse`.
218218
*
219219
* @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
220220
* server responded with an unexpected value).
@@ -600,7 +600,7 @@ private constructor(
600600

601601
/**
602602
* The voice the model used to respond. Current voice options are `alloy`, `ash`, `ballad`,
603-
* `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and `verse`.
603+
* `coral`, `echo`, `sage`, `shimmer`, and `verse`.
604604
*/
605605
fun voice(voice: Voice) = voice(JsonField.of(voice))
606606

@@ -1535,7 +1535,7 @@ private constructor(
15351535

15361536
/**
15371537
* The voice the model used to respond. Current voice options are `alloy`, `ash`, `ballad`,
1538-
* `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and `verse`.
1538+
* `coral`, `echo`, `sage`, `shimmer`, and `verse`.
15391539
*/
15401540
class Voice @JsonCreator private constructor(private val value: JsonField<String>) : Enum {
15411541

@@ -1561,12 +1561,6 @@ private constructor(
15611561

15621562
@JvmField val ECHO = of("echo")
15631563

1564-
@JvmField val FABLE = of("fable")
1565-
1566-
@JvmField val ONYX = of("onyx")
1567-
1568-
@JvmField val NOVA = of("nova")
1569-
15701564
@JvmField val SAGE = of("sage")
15711565

15721566
@JvmField val SHIMMER = of("shimmer")
@@ -1583,9 +1577,6 @@ private constructor(
15831577
BALLAD,
15841578
CORAL,
15851579
ECHO,
1586-
FABLE,
1587-
ONYX,
1588-
NOVA,
15891580
SAGE,
15901581
SHIMMER,
15911582
VERSE,
@@ -1606,9 +1597,6 @@ private constructor(
16061597
BALLAD,
16071598
CORAL,
16081599
ECHO,
1609-
FABLE,
1610-
ONYX,
1611-
NOVA,
16121600
SAGE,
16131601
SHIMMER,
16141602
VERSE,
@@ -1630,9 +1618,6 @@ private constructor(
16301618
BALLAD -> Value.BALLAD
16311619
CORAL -> Value.CORAL
16321620
ECHO -> Value.ECHO
1633-
FABLE -> Value.FABLE
1634-
ONYX -> Value.ONYX
1635-
NOVA -> Value.NOVA
16361621
SAGE -> Value.SAGE
16371622
SHIMMER -> Value.SHIMMER
16381623
VERSE -> Value.VERSE
@@ -1655,9 +1640,6 @@ private constructor(
16551640
BALLAD -> Known.BALLAD
16561641
CORAL -> Known.CORAL
16571642
ECHO -> Known.ECHO
1658-
FABLE -> Known.FABLE
1659-
ONYX -> Known.ONYX
1660-
NOVA -> Known.NOVA
16611643
SAGE -> Known.SAGE
16621644
SHIMMER -> Known.SHIMMER
16631645
VERSE -> Known.VERSE

openai-java-core/src/main/kotlin/com/openai/models/beta/realtime/ResponseCreateEvent.kt

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ private constructor(
407407
/**
408408
* The voice the model uses to respond. Voice cannot be changed during the session once the
409409
* model has responded with audio at least once. Current voice options are `alloy`, `ash`,
410-
* `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and `verse`.
410+
* `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
411411
*
412412
* @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
413413
* server responded with an unexpected value).
@@ -802,8 +802,7 @@ private constructor(
802802
/**
803803
* The voice the model uses to respond. Voice cannot be changed during the session once
804804
* the model has responded with audio at least once. Current voice options are `alloy`,
805-
* `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and
806-
* `verse`.
805+
* `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
807806
*/
808807
fun voice(voice: Voice) = voice(JsonField.of(voice))
809808

@@ -1983,7 +1982,7 @@ private constructor(
19831982
/**
19841983
* The voice the model uses to respond. Voice cannot be changed during the session once the
19851984
* model has responded with audio at least once. Current voice options are `alloy`, `ash`,
1986-
* `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and `verse`.
1985+
* `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
19871986
*/
19881987
class Voice @JsonCreator private constructor(private val value: JsonField<String>) : Enum {
19891988

@@ -2009,12 +2008,6 @@ private constructor(
20092008

20102009
@JvmField val ECHO = of("echo")
20112010

2012-
@JvmField val FABLE = of("fable")
2013-
2014-
@JvmField val ONYX = of("onyx")
2015-
2016-
@JvmField val NOVA = of("nova")
2017-
20182011
@JvmField val SAGE = of("sage")
20192012

20202013
@JvmField val SHIMMER = of("shimmer")
@@ -2031,9 +2024,6 @@ private constructor(
20312024
BALLAD,
20322025
CORAL,
20332026
ECHO,
2034-
FABLE,
2035-
ONYX,
2036-
NOVA,
20372027
SAGE,
20382028
SHIMMER,
20392029
VERSE,
@@ -2054,9 +2044,6 @@ private constructor(
20542044
BALLAD,
20552045
CORAL,
20562046
ECHO,
2057-
FABLE,
2058-
ONYX,
2059-
NOVA,
20602047
SAGE,
20612048
SHIMMER,
20622049
VERSE,
@@ -2080,9 +2067,6 @@ private constructor(
20802067
BALLAD -> Value.BALLAD
20812068
CORAL -> Value.CORAL
20822069
ECHO -> Value.ECHO
2083-
FABLE -> Value.FABLE
2084-
ONYX -> Value.ONYX
2085-
NOVA -> Value.NOVA
20862070
SAGE -> Value.SAGE
20872071
SHIMMER -> Value.SHIMMER
20882072
VERSE -> Value.VERSE
@@ -2105,9 +2089,6 @@ private constructor(
21052089
BALLAD -> Known.BALLAD
21062090
CORAL -> Known.CORAL
21072091
ECHO -> Known.ECHO
2108-
FABLE -> Known.FABLE
2109-
ONYX -> Known.ONYX
2110-
NOVA -> Known.NOVA
21112092
SAGE -> Known.SAGE
21122093
SHIMMER -> Known.SHIMMER
21132094
VERSE -> Known.VERSE

0 commit comments

Comments
 (0)