Skip to content

Commit 2e872d4

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): new o1 and GPT-4o models + preference fine-tuning (#1229)
learn more here: https://platform.openai.com/docs/changelog
1 parent d51fcfe commit 2e872d4

File tree

9 files changed

+372
-34
lines changed

9 files changed

+372
-34
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 68
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-2e0e0678be19d1118fd796af291822075e40538dba326611e177e9f3dc245a53.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-779ea2754025daf5e18eb8ceb203ec321692636bc3a999338556a479178efa6c.yml

api.md

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Types:
4141
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionContentPartInputAudio</a></code>
4242
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionContentPartRefusal</a></code>
4343
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionContentPartText</a></code>
44+
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionDeveloperMessageParam</a></code>
4445
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionFunctionCallOption</a></code>
4546
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionFunctionMessageParam</a></code>
4647
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionMessage</a></code>
@@ -49,6 +50,7 @@ Types:
4950
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionModality</a></code>
5051
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionNamedToolChoice</a></code>
5152
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionPredictionContent</a></code>
53+
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionReasoningEffort</a></code>
5254
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionRole</a></code>
5355
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionStreamOptions</a></code>
5456
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionSystemMessageParam</a></code>

src/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ import {
8080
ChatCompletionCreateParams,
8181
ChatCompletionCreateParamsNonStreaming,
8282
ChatCompletionCreateParamsStreaming,
83+
ChatCompletionDeveloperMessageParam,
8384
ChatCompletionFunctionCallOption,
8485
ChatCompletionFunctionMessageParam,
8586
ChatCompletionMessage,
@@ -88,6 +89,7 @@ import {
8889
ChatCompletionModality,
8990
ChatCompletionNamedToolChoice,
9091
ChatCompletionPredictionContent,
92+
ChatCompletionReasoningEffort,
9193
ChatCompletionRole,
9294
ChatCompletionStreamOptions,
9395
ChatCompletionSystemMessageParam,
@@ -353,6 +355,7 @@ export declare namespace OpenAI {
353355
type ChatCompletionContentPartInputAudio as ChatCompletionContentPartInputAudio,
354356
type ChatCompletionContentPartRefusal as ChatCompletionContentPartRefusal,
355357
type ChatCompletionContentPartText as ChatCompletionContentPartText,
358+
type ChatCompletionDeveloperMessageParam as ChatCompletionDeveloperMessageParam,
356359
type ChatCompletionFunctionCallOption as ChatCompletionFunctionCallOption,
357360
type ChatCompletionFunctionMessageParam as ChatCompletionFunctionMessageParam,
358361
type ChatCompletionMessage as ChatCompletionMessage,
@@ -361,6 +364,7 @@ export declare namespace OpenAI {
361364
type ChatCompletionModality as ChatCompletionModality,
362365
type ChatCompletionNamedToolChoice as ChatCompletionNamedToolChoice,
363366
type ChatCompletionPredictionContent as ChatCompletionPredictionContent,
367+
type ChatCompletionReasoningEffort as ChatCompletionReasoningEffort,
364368
type ChatCompletionRole as ChatCompletionRole,
365369
type ChatCompletionStreamOptions as ChatCompletionStreamOptions,
366370
type ChatCompletionSystemMessageParam as ChatCompletionSystemMessageParam,

src/resources/chat/chat.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
ChatCompletionCreateParams,
1717
ChatCompletionCreateParamsNonStreaming,
1818
ChatCompletionCreateParamsStreaming,
19+
ChatCompletionDeveloperMessageParam,
1920
ChatCompletionFunctionCallOption,
2021
ChatCompletionFunctionMessageParam,
2122
ChatCompletionMessage,
@@ -24,6 +25,7 @@ import {
2425
ChatCompletionModality,
2526
ChatCompletionNamedToolChoice,
2627
ChatCompletionPredictionContent,
28+
ChatCompletionReasoningEffort,
2729
ChatCompletionRole,
2830
ChatCompletionStreamOptions,
2931
ChatCompletionSystemMessageParam,
@@ -44,6 +46,8 @@ export class Chat extends APIResource {
4446
}
4547

4648
export type ChatModel =
49+
| 'o1'
50+
| 'o1-2024-12-17'
4751
| 'o1-preview'
4852
| 'o1-preview-2024-09-12'
4953
| 'o1-mini'
@@ -52,10 +56,11 @@ export type ChatModel =
5256
| 'gpt-4o-2024-11-20'
5357
| 'gpt-4o-2024-08-06'
5458
| 'gpt-4o-2024-05-13'
55-
| 'gpt-4o-realtime-preview'
56-
| 'gpt-4o-realtime-preview-2024-10-01'
5759
| 'gpt-4o-audio-preview'
5860
| 'gpt-4o-audio-preview-2024-10-01'
61+
| 'gpt-4o-audio-preview-2024-12-17'
62+
| 'gpt-4o-mini-audio-preview'
63+
| 'gpt-4o-mini-audio-preview-2024-12-17'
5964
| 'chatgpt-4o-latest'
6065
| 'gpt-4o-mini'
6166
| 'gpt-4o-mini-2024-07-18'
@@ -96,6 +101,7 @@ export declare namespace Chat {
96101
type ChatCompletionContentPartInputAudio as ChatCompletionContentPartInputAudio,
97102
type ChatCompletionContentPartRefusal as ChatCompletionContentPartRefusal,
98103
type ChatCompletionContentPartText as ChatCompletionContentPartText,
104+
type ChatCompletionDeveloperMessageParam as ChatCompletionDeveloperMessageParam,
99105
type ChatCompletionFunctionCallOption as ChatCompletionFunctionCallOption,
100106
type ChatCompletionFunctionMessageParam as ChatCompletionFunctionMessageParam,
101107
type ChatCompletionMessage as ChatCompletionMessage,
@@ -104,6 +110,7 @@ export declare namespace Chat {
104110
type ChatCompletionModality as ChatCompletionModality,
105111
type ChatCompletionNamedToolChoice as ChatCompletionNamedToolChoice,
106112
type ChatCompletionPredictionContent as ChatCompletionPredictionContent,
113+
type ChatCompletionReasoningEffort as ChatCompletionReasoningEffort,
107114
type ChatCompletionRole as ChatCompletionRole,
108115
type ChatCompletionStreamOptions as ChatCompletionStreamOptions,
109116
type ChatCompletionSystemMessageParam as ChatCompletionSystemMessageParam,

src/resources/chat/completions.ts

+80-16
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ export class Completions extends APIResource {
1515
* [text generation](https://platform.openai.com/docs/guides/text-generation),
1616
* [vision](https://platform.openai.com/docs/guides/vision), and
1717
* [audio](https://platform.openai.com/docs/guides/audio) guides.
18+
*
19+
* Parameter support can differ depending on the model used to generate the
20+
* response, particularly for newer reasoning models. Parameters that are only
21+
* supported for reasoning models are noted below. For the current state of
22+
* unsupported parameters in reasoning models,
23+
* [refer to the reasoning guide](https://platform.openai.com/docs/guides/reasoning).
1824
*/
1925
create(
2026
body: ChatCompletionCreateParamsNonStreaming,
@@ -135,6 +141,9 @@ export namespace ChatCompletion {
135141
}
136142
}
137143

144+
/**
145+
* Messages sent by the model in response to user messages.
146+
*/
138147
export interface ChatCompletionAssistantMessageParam {
139148
/**
140149
* The role of the messages author, in this case `assistant`.
@@ -530,6 +539,29 @@ export interface ChatCompletionContentPartText {
530539
type: 'text';
531540
}
532541

542+
/**
543+
* Developer-provided instructions that the model should follow, regardless of
544+
* messages sent by the user. With o1 models and newer, `developer` messages
545+
* replace the previous `system` messages.
546+
*/
547+
export interface ChatCompletionDeveloperMessageParam {
548+
/**
549+
* The contents of the developer message.
550+
*/
551+
content: string | Array<ChatCompletionContentPartText>;
552+
553+
/**
554+
* The role of the messages author, in this case `developer`.
555+
*/
556+
role: 'developer';
557+
558+
/**
559+
* An optional name for the participant. Provides the model information to
560+
* differentiate between participants of the same role.
561+
*/
562+
name?: string;
563+
}
564+
533565
/**
534566
* Specifying a particular function via `{"name": "my_function"}` forces the model
535567
* to call that function.
@@ -620,7 +652,13 @@ export namespace ChatCompletionMessage {
620652
}
621653
}
622654

655+
/**
656+
* Developer-provided instructions that the model should follow, regardless of
657+
* messages sent by the user. With o1 models and newer, `developer` messages
658+
* replace the previous `system` messages.
659+
*/
623660
export type ChatCompletionMessageParam =
661+
| ChatCompletionDeveloperMessageParam
624662
| ChatCompletionSystemMessageParam
625663
| ChatCompletionUserMessageParam
626664
| ChatCompletionAssistantMessageParam
@@ -707,6 +745,16 @@ export interface ChatCompletionPredictionContent {
707745
type: 'content';
708746
}
709747

748+
/**
749+
* **o1 models only**
750+
*
751+
* Constrains effort on reasoning for
752+
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
753+
* supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
754+
* result in faster responses and fewer tokens used on reasoning in a response.
755+
*/
756+
export type ChatCompletionReasoningEffort = 'low' | 'medium' | 'high';
757+
710758
/**
711759
* The role of the author of a message
712760
*/
@@ -725,6 +773,11 @@ export interface ChatCompletionStreamOptions {
725773
include_usage?: boolean;
726774
}
727775

776+
/**
777+
* Developer-provided instructions that the model should follow, regardless of
778+
* messages sent by the user. With o1 models and newer, use `developer` messages
779+
* for this purpose instead.
780+
*/
728781
export interface ChatCompletionSystemMessageParam {
729782
/**
730783
* The contents of the system message.
@@ -835,6 +888,10 @@ export interface ChatCompletionToolMessageParam {
835888
tool_call_id: string;
836889
}
837890

891+
/**
892+
* Messages sent by an end user, containing prompts or additional context
893+
* information.
894+
*/
838895
export interface ChatCompletionUserMessageParam {
839896
/**
840897
* The contents of the user message.
@@ -891,20 +948,22 @@ export interface ChatCompletionCreateParamsBase {
891948
* Number between -2.0 and 2.0. Positive values penalize new tokens based on their
892949
* existing frequency in the text so far, decreasing the model's likelihood to
893950
* repeat the same line verbatim.
894-
*
895-
* [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation)
896951
*/
897952
frequency_penalty?: number | null;
898953

899954
/**
900955
* Deprecated in favor of `tool_choice`.
901956
*
902-
* Controls which (if any) function is called by the model. `none` means the model
903-
* will not call a function and instead generates a message. `auto` means the model
904-
* can pick between generating a message or calling a function. Specifying a
905-
* particular function via `{"name": "my_function"}` forces the model to call that
957+
* Controls which (if any) function is called by the model.
958+
*
959+
* `none` means the model will not call a function and instead generates a message.
960+
*
961+
* `auto` means the model can pick between generating a message or calling a
906962
* function.
907963
*
964+
* Specifying a particular function via `{"name": "my_function"}` forces the model
965+
* to call that function.
966+
*
908967
* `none` is the default when no functions are present. `auto` is the default if
909968
* functions are present.
910969
*/
@@ -998,17 +1057,21 @@ export interface ChatCompletionCreateParamsBase {
9981057
* Number between -2.0 and 2.0. Positive values penalize new tokens based on
9991058
* whether they appear in the text so far, increasing the model's likelihood to
10001059
* talk about new topics.
1001-
*
1002-
* [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation)
10031060
*/
10041061
presence_penalty?: number | null;
10051062

10061063
/**
1007-
* An object specifying the format that the model must output. Compatible with
1008-
* [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
1009-
* [GPT-4o mini](https://platform.openai.com/docs/models#gpt-4o-mini),
1010-
* [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4) and
1011-
* all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
1064+
* **o1 models only**
1065+
*
1066+
* Constrains effort on reasoning for
1067+
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
1068+
* supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
1069+
* result in faster responses and fewer tokens used on reasoning in a response.
1070+
*/
1071+
reasoning_effort?: ChatCompletionReasoningEffort;
1072+
1073+
/**
1074+
* An object specifying the format that the model must output.
10121075
*
10131076
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
10141077
* Outputs which ensures the model will match your supplied JSON schema. Learn more
@@ -1088,9 +1151,8 @@ export interface ChatCompletionCreateParamsBase {
10881151
/**
10891152
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
10901153
* make the output more random, while lower values like 0.2 will make it more
1091-
* focused and deterministic.
1092-
*
1093-
* We generally recommend altering this or `top_p` but not both.
1154+
* focused and deterministic. We generally recommend altering this or `top_p` but
1155+
* not both.
10941156
*/
10951157
temperature?: number | null;
10961158

@@ -1223,6 +1285,7 @@ export declare namespace Completions {
12231285
type ChatCompletionContentPartInputAudio as ChatCompletionContentPartInputAudio,
12241286
type ChatCompletionContentPartRefusal as ChatCompletionContentPartRefusal,
12251287
type ChatCompletionContentPartText as ChatCompletionContentPartText,
1288+
type ChatCompletionDeveloperMessageParam as ChatCompletionDeveloperMessageParam,
12261289
type ChatCompletionFunctionCallOption as ChatCompletionFunctionCallOption,
12271290
type ChatCompletionFunctionMessageParam as ChatCompletionFunctionMessageParam,
12281291
type ChatCompletionMessage as ChatCompletionMessage,
@@ -1231,6 +1294,7 @@ export declare namespace Completions {
12311294
type ChatCompletionModality as ChatCompletionModality,
12321295
type ChatCompletionNamedToolChoice as ChatCompletionNamedToolChoice,
12331296
type ChatCompletionPredictionContent as ChatCompletionPredictionContent,
1297+
type ChatCompletionReasoningEffort as ChatCompletionReasoningEffort,
12341298
type ChatCompletionRole as ChatCompletionRole,
12351299
type ChatCompletionStreamOptions as ChatCompletionStreamOptions,
12361300
type ChatCompletionSystemMessageParam as ChatCompletionSystemMessageParam,

src/resources/chat/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export {
1313
type ChatCompletionContentPartInputAudio,
1414
type ChatCompletionContentPartRefusal,
1515
type ChatCompletionContentPartText,
16+
type ChatCompletionDeveloperMessageParam,
1617
type ChatCompletionFunctionCallOption,
1718
type ChatCompletionFunctionMessageParam,
1819
type ChatCompletionMessage,
@@ -21,6 +22,7 @@ export {
2122
type ChatCompletionModality,
2223
type ChatCompletionNamedToolChoice,
2324
type ChatCompletionPredictionContent,
25+
type ChatCompletionReasoningEffort,
2426
type ChatCompletionRole,
2527
type ChatCompletionStreamOptions,
2628
type ChatCompletionSystemMessageParam,

0 commit comments

Comments
 (0)