Skip to content

Commit 4ed02cc

Browse files
feat(api): gpt 5.1
1 parent 81770c0 commit 4ed02cc

File tree

98 files changed

+12691
-374
lines changed

Some content is hidden

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

98 files changed

+12691
-374
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 135
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-eeba8addf3a5f412e5ce8d22031e60c61650cee3f5d9e587a2533f6818a249ea.yml
3-
openapi_spec_hash: 0a4d8ad2469823ce24a3fd94f23f1c2b
4-
config_hash: 630eea84bb3067d25640419af058ed56
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-ca24bc4d8125b5153514ce643c4e3220f25971b7d67ca384d56d493c72c0d977.yml
3+
openapi_spec_hash: c6f048c7b3d29f4de48fde0e845ba33f
4+
config_hash: b876221dfb213df9f0a999e75d38a65e

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ OpenAIClient client = OpenAIOkHttpClient.fromEnv();
8282

8383
ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
8484
.addUserMessage("Say this is a test")
85-
.model(ChatModel.GPT_5)
85+
.model(ChatModel.GPT_5_1)
8686
.build();
8787
ChatCompletion chatCompletion = client.chat().completions().create(params);
8888
```
@@ -188,7 +188,7 @@ OpenAIClient client = OpenAIOkHttpClient.fromEnv();
188188

189189
ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
190190
.addUserMessage("Say this is a test")
191-
.model(ChatModel.GPT_5)
191+
.model(ChatModel.GPT_5_1)
192192
.build();
193193
CompletableFuture<ChatCompletion> chatCompletion = client.async().chat().completions().create(params);
194194
```
@@ -209,7 +209,7 @@ OpenAIClientAsync client = OpenAIOkHttpClientAsync.fromEnv();
209209

210210
ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
211211
.addUserMessage("Say this is a test")
212-
.model(ChatModel.GPT_5)
212+
.model(ChatModel.GPT_5_1)
213213
.build();
214214
CompletableFuture<ChatCompletion> chatCompletion = client.chat().completions().create(params);
215215
```
@@ -1143,7 +1143,7 @@ import com.openai.models.chat.completions.ChatCompletionCreateParams;
11431143

11441144
ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
11451145
.addUserMessage("Say this is a test")
1146-
.model(ChatModel.GPT_5)
1146+
.model(ChatModel.GPT_5_1)
11471147
.build();
11481148
HttpResponseFor<ChatCompletion> chatCompletion = client.chat().completions().withRawResponse().create(params);
11491149

@@ -1616,7 +1616,7 @@ import com.openai.models.chat.completions.ChatCompletionCreateParams;
16161616

16171617
ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
16181618
.messages(JsonValue.from(42))
1619-
.model(ChatModel.GPT_5)
1619+
.model(ChatModel.GPT_5_1)
16201620
.build();
16211621
```
16221622

@@ -1669,7 +1669,7 @@ import com.openai.models.ChatModel;
16691669
import com.openai.models.chat.completions.ChatCompletionCreateParams;
16701670

16711671
ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
1672-
.model(ChatModel.GPT_5)
1672+
.model(ChatModel.GPT_5_1)
16731673
.messages(JsonMissing.of())
16741674
.build();
16751675
```

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ class ChatModel @JsonCreator private constructor(private val value: JsonField<St
2020

2121
companion object {
2222

23+
@JvmField val GPT_5_1 = of("gpt-5.1")
24+
25+
@JvmField val GPT_5_1_2025_11_13 = of("gpt-5.1-2025-11-13")
26+
27+
@JvmField val GPT_5_1_CODEX = of("gpt-5.1-codex")
28+
29+
@JvmField val GPT_5_1_MINI = of("gpt-5.1-mini")
30+
31+
@JvmField val GPT_5_1_CHAT_LATEST = of("gpt-5.1-chat-latest")
32+
2333
@JvmField val GPT_5 = of("gpt-5")
2434

2535
@JvmField val GPT_5_MINI = of("gpt-5-mini")
@@ -151,6 +161,11 @@ class ChatModel @JsonCreator private constructor(private val value: JsonField<St
151161

152162
/** An enum containing [ChatModel]'s known values. */
153163
enum class Known {
164+
GPT_5_1,
165+
GPT_5_1_2025_11_13,
166+
GPT_5_1_CODEX,
167+
GPT_5_1_MINI,
168+
GPT_5_1_CHAT_LATEST,
154169
GPT_5,
155170
GPT_5_MINI,
156171
GPT_5_NANO,
@@ -225,6 +240,11 @@ class ChatModel @JsonCreator private constructor(private val value: JsonField<St
225240
* - It was constructed with an arbitrary value using the [of] method.
226241
*/
227242
enum class Value {
243+
GPT_5_1,
244+
GPT_5_1_2025_11_13,
245+
GPT_5_1_CODEX,
246+
GPT_5_1_MINI,
247+
GPT_5_1_CHAT_LATEST,
228248
GPT_5,
229249
GPT_5_MINI,
230250
GPT_5_NANO,
@@ -300,6 +320,11 @@ class ChatModel @JsonCreator private constructor(private val value: JsonField<St
300320
*/
301321
fun value(): Value =
302322
when (this) {
323+
GPT_5_1 -> Value.GPT_5_1
324+
GPT_5_1_2025_11_13 -> Value.GPT_5_1_2025_11_13
325+
GPT_5_1_CODEX -> Value.GPT_5_1_CODEX
326+
GPT_5_1_MINI -> Value.GPT_5_1_MINI
327+
GPT_5_1_CHAT_LATEST -> Value.GPT_5_1_CHAT_LATEST
303328
GPT_5 -> Value.GPT_5
304329
GPT_5_MINI -> Value.GPT_5_MINI
305330
GPT_5_NANO -> Value.GPT_5_NANO
@@ -375,6 +400,11 @@ class ChatModel @JsonCreator private constructor(private val value: JsonField<St
375400
*/
376401
fun known(): Known =
377402
when (this) {
403+
GPT_5_1 -> Known.GPT_5_1
404+
GPT_5_1_2025_11_13 -> Known.GPT_5_1_2025_11_13
405+
GPT_5_1_CODEX -> Known.GPT_5_1_CODEX
406+
GPT_5_1_MINI -> Known.GPT_5_1_MINI
407+
GPT_5_1_CHAT_LATEST -> Known.GPT_5_1_CHAT_LATEST
378408
GPT_5 -> Known.GPT_5
379409
GPT_5_MINI -> Known.GPT_5_MINI
380410
GPT_5_NANO -> Known.GPT_5_NANO

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,14 @@ private constructor(
4545
/**
4646
* Constrains effort on reasoning for
4747
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported
48-
* values are `minimal`, `low`, `medium`, and `high`. Reducing reasoning effort can result in
49-
* faster responses and fewer tokens used on reasoning in a response.
50-
*
51-
* Note: The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
48+
* values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing reasoning effort can
49+
* result in faster responses and fewer tokens used on reasoning in a response.
50+
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning
51+
* values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported for
52+
* all reasoning values in gpt-5.1.
53+
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support
54+
* `none`.
55+
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
5256
*
5357
* @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
5458
* server responded with an unexpected value).
@@ -140,10 +144,14 @@ private constructor(
140144
/**
141145
* Constrains effort on reasoning for
142146
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
143-
* supported values are `minimal`, `low`, `medium`, and `high`. Reducing reasoning effort
144-
* can result in faster responses and fewer tokens used on reasoning in a response.
145-
*
146-
* Note: The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
147+
* supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing reasoning
148+
* effort can result in faster responses and fewer tokens used on reasoning in a response.
149+
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning
150+
* values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported
151+
* for all reasoning values in gpt-5.1.
152+
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support
153+
* `none`.
154+
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
147155
*/
148156
fun effort(effort: ReasoningEffort?) = effort(JsonField.ofNullable(effort))
149157

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ import com.openai.errors.OpenAIInvalidDataException
1010
/**
1111
* Constrains effort on reasoning for
1212
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported values
13-
* are `minimal`, `low`, `medium`, and `high`. Reducing reasoning effort can result in faster
14-
* responses and fewer tokens used on reasoning in a response.
15-
*
16-
* Note: The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
13+
* are `none`, `minimal`, `low`, `medium`, and `high`. Reducing reasoning effort can result in
14+
* faster responses and fewer tokens used on reasoning in a response.
15+
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning values
16+
* for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported for all
17+
* reasoning values in gpt-5.1.
18+
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support `none`.
19+
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
1720
*/
1821
class ReasoningEffort @JsonCreator private constructor(private val value: JsonField<String>) :
1922
Enum {
@@ -29,6 +32,8 @@ class ReasoningEffort @JsonCreator private constructor(private val value: JsonFi
2932

3033
companion object {
3134

35+
@JvmField val NONE = of("none")
36+
3237
@JvmField val MINIMAL = of("minimal")
3338

3439
@JvmField val LOW = of("low")
@@ -42,6 +47,7 @@ class ReasoningEffort @JsonCreator private constructor(private val value: JsonFi
4247

4348
/** An enum containing [ReasoningEffort]'s known values. */
4449
enum class Known {
50+
NONE,
4551
MINIMAL,
4652
LOW,
4753
MEDIUM,
@@ -58,6 +64,7 @@ class ReasoningEffort @JsonCreator private constructor(private val value: JsonFi
5864
* - It was constructed with an arbitrary value using the [of] method.
5965
*/
6066
enum class Value {
67+
NONE,
6168
MINIMAL,
6269
LOW,
6370
MEDIUM,
@@ -77,6 +84,7 @@ class ReasoningEffort @JsonCreator private constructor(private val value: JsonFi
7784
*/
7885
fun value(): Value =
7986
when (this) {
87+
NONE -> Value.NONE
8088
MINIMAL -> Value.MINIMAL
8189
LOW -> Value.LOW
8290
MEDIUM -> Value.MEDIUM
@@ -94,6 +102,7 @@ class ReasoningEffort @JsonCreator private constructor(private val value: JsonFi
94102
*/
95103
fun known(): Known =
96104
when (this) {
105+
NONE -> Known.NONE
97106
MINIMAL -> Known.MINIMAL
98107
LOW -> Known.LOW
99108
MEDIUM -> Known.MEDIUM

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

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ private constructor(
4040

4141
/**
4242
* The endpoint to be used for all requests in the batch. Currently `/v1/responses`,
43-
* `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. Note that
44-
* `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs across
45-
* all requests in the batch.
43+
* `/v1/chat/completions`, `/v1/embeddings`, `/v1/completions`, and `/v1/moderations` are
44+
* supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000
45+
* embedding inputs across all requests in the batch.
4646
*
4747
* @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
4848
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
@@ -197,9 +197,9 @@ private constructor(
197197

198198
/**
199199
* The endpoint to be used for all requests in the batch. Currently `/v1/responses`,
200-
* `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. Note that
201-
* `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs
202-
* across all requests in the batch.
200+
* `/v1/chat/completions`, `/v1/embeddings`, `/v1/completions`, and `/v1/moderations` are
201+
* supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000
202+
* embedding inputs across all requests in the batch.
203203
*/
204204
fun endpoint(endpoint: Endpoint) = apply { body.endpoint(endpoint) }
205205

@@ -467,9 +467,9 @@ private constructor(
467467

468468
/**
469469
* The endpoint to be used for all requests in the batch. Currently `/v1/responses`,
470-
* `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. Note that
471-
* `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs
472-
* across all requests in the batch.
470+
* `/v1/chat/completions`, `/v1/embeddings`, `/v1/completions`, and `/v1/moderations` are
471+
* supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000
472+
* embedding inputs across all requests in the batch.
473473
*
474474
* @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
475475
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
@@ -624,9 +624,9 @@ private constructor(
624624

625625
/**
626626
* The endpoint to be used for all requests in the batch. Currently `/v1/responses`,
627-
* `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. Note
628-
* that `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding
629-
* inputs across all requests in the batch.
627+
* `/v1/chat/completions`, `/v1/embeddings`, `/v1/completions`, and `/v1/moderations`
628+
* are supported. Note that `/v1/embeddings` batches are also restricted to a maximum of
629+
* 50,000 embedding inputs across all requests in the batch.
630630
*/
631631
fun endpoint(endpoint: Endpoint) = endpoint(JsonField.of(endpoint))
632632

@@ -943,9 +943,9 @@ private constructor(
943943

944944
/**
945945
* The endpoint to be used for all requests in the batch. Currently `/v1/responses`,
946-
* `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. Note that
947-
* `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs across
948-
* all requests in the batch.
946+
* `/v1/chat/completions`, `/v1/embeddings`, `/v1/completions`, and `/v1/moderations` are
947+
* supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000
948+
* embedding inputs across all requests in the batch.
949949
*/
950950
class Endpoint @JsonCreator private constructor(private val value: JsonField<String>) : Enum {
951951

@@ -969,6 +969,8 @@ private constructor(
969969

970970
@JvmField val V1_COMPLETIONS = of("/v1/completions")
971971

972+
@JvmField val V1_MODERATIONS = of("/v1/moderations")
973+
972974
@JvmStatic fun of(value: String) = Endpoint(JsonField.of(value))
973975
}
974976

@@ -978,6 +980,7 @@ private constructor(
978980
V1_CHAT_COMPLETIONS,
979981
V1_EMBEDDINGS,
980982
V1_COMPLETIONS,
983+
V1_MODERATIONS,
981984
}
982985

983986
/**
@@ -994,6 +997,7 @@ private constructor(
994997
V1_CHAT_COMPLETIONS,
995998
V1_EMBEDDINGS,
996999
V1_COMPLETIONS,
1000+
V1_MODERATIONS,
9971001
/** An enum member indicating that [Endpoint] was instantiated with an unknown value. */
9981002
_UNKNOWN,
9991003
}
@@ -1011,6 +1015,7 @@ private constructor(
10111015
V1_CHAT_COMPLETIONS -> Value.V1_CHAT_COMPLETIONS
10121016
V1_EMBEDDINGS -> Value.V1_EMBEDDINGS
10131017
V1_COMPLETIONS -> Value.V1_COMPLETIONS
1018+
V1_MODERATIONS -> Value.V1_MODERATIONS
10141019
else -> Value._UNKNOWN
10151020
}
10161021

@@ -1029,6 +1034,7 @@ private constructor(
10291034
V1_CHAT_COMPLETIONS -> Known.V1_CHAT_COMPLETIONS
10301035
V1_EMBEDDINGS -> Known.V1_EMBEDDINGS
10311036
V1_COMPLETIONS -> Known.V1_COMPLETIONS
1037+
V1_MODERATIONS -> Known.V1_MODERATIONS
10321038
else -> throw OpenAIInvalidDataException("Unknown Endpoint: $value")
10331039
}
10341040

0 commit comments

Comments
 (0)