@@ -49,7 +49,7 @@ export interface ChatCompletionInput {
49
49
* [UNUSED] ID of the model to use. See the model endpoint compatibility table for details
50
50
* on which models work with the Chat API.
51
51
*/
52
- model : string ;
52
+ model ? : string ;
53
53
/**
54
54
* UNUSED
55
55
* How many chat completion choices to generate for each input message. Note that you will
@@ -63,12 +63,14 @@ export interface ChatCompletionInput {
63
63
* increasing the model's likelihood to talk about new topics
64
64
*/
65
65
presence_penalty ?: number ;
66
+ response_format ?: ChatCompletionInputGrammarType ;
66
67
seed ?: number ;
67
68
/**
68
69
* Up to 4 sequences where the API will stop generating further tokens.
69
70
*/
70
71
stop ?: string [ ] ;
71
72
stream ?: boolean ;
73
+ stream_options ?: ChatCompletionInputStreamOptions ;
72
74
/**
73
75
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the
74
76
* output more random, while
@@ -77,7 +79,7 @@ export interface ChatCompletionInput {
77
79
* We generally recommend altering this or `top_p` but not both.
78
80
*/
79
81
temperature ?: number ;
80
- tool_choice ?: ChatCompletionInputToolType ;
82
+ tool_choice ?: ChatCompletionInputTool ;
81
83
/**
82
84
* A prompt to be appended before the tools
83
85
*/
@@ -87,7 +89,7 @@ export interface ChatCompletionInput {
87
89
* Use this to provide a list of
88
90
* functions the model may generate JSON inputs for.
89
91
*/
90
- tools ?: ChatCompletionInputTool [ ] ;
92
+ tools ?: ToolElement [ ] ;
91
93
/**
92
94
* An integer between 0 and 5 specifying the number of most likely tokens to return at each
93
95
* token position, each with
@@ -105,40 +107,78 @@ export interface ChatCompletionInput {
105
107
}
106
108
107
109
export interface ChatCompletionInputMessage {
108
- content ?: string ;
110
+ content : ChatCompletionInputMessageContent ;
109
111
name ?: string ;
110
112
role : string ;
111
- tool_calls ?: ChatCompletionInputToolCall [ ] ;
112
113
[ property : string ] : unknown ;
113
114
}
114
115
115
- export interface ChatCompletionInputToolCall {
116
- function : ChatCompletionInputFunctionDefinition ;
117
- id : number ;
118
- type : string ;
116
+ export type ChatCompletionInputMessageContent = ChatCompletionInputMessageChunk [ ] | string ;
117
+
118
+ export interface ChatCompletionInputMessageChunk {
119
+ image_url ?: ChatCompletionInputURL ;
120
+ text ?: string ;
121
+ type : ChatCompletionInputMessageChunkType ;
119
122
[ property : string ] : unknown ;
120
123
}
121
124
122
- export interface ChatCompletionInputFunctionDefinition {
123
- arguments : unknown ;
124
- description ?: string ;
125
- name : string ;
125
+ export interface ChatCompletionInputURL {
126
+ url : string ;
126
127
[ property : string ] : unknown ;
127
128
}
128
129
129
- export type ChatCompletionInputToolType = "OneOf " | ChatCompletionInputToolTypeObject ;
130
+ export type ChatCompletionInputMessageChunkType = "text " | "image_url" ;
130
131
131
- export interface ChatCompletionInputToolTypeObject {
132
- FunctionName : string ;
132
+ export interface ChatCompletionInputGrammarType {
133
+ type : ChatCompletionInputGrammarTypeType ;
134
+ /**
135
+ * A string that represents a [JSON Schema](https://json-schema.org/).
136
+ *
137
+ * JSON Schema is a declarative language that allows to annotate JSON documents
138
+ * with types and descriptions.
139
+ */
140
+ value : unknown ;
141
+ [ property : string ] : unknown ;
142
+ }
143
+
144
+ export type ChatCompletionInputGrammarTypeType = "json" | "regex" ;
145
+
146
+ export interface ChatCompletionInputStreamOptions {
147
+ /**
148
+ * If set, an additional chunk will be streamed before the data: [DONE] message. The usage
149
+ * field on this chunk shows the token usage statistics for the entire request, and the
150
+ * choices field will always be an empty array. All other chunks will also include a usage
151
+ * field, but with a null value.
152
+ */
153
+ include_usage : boolean ;
133
154
[ property : string ] : unknown ;
134
155
}
135
156
136
- export interface ChatCompletionInputTool {
157
+ export type ChatCompletionInputTool = ChatCompletionInputToolType | string ;
158
+
159
+ export interface ChatCompletionInputToolType {
160
+ function ?: ChatCompletionInputFunctionName ;
161
+ [ property : string ] : unknown ;
162
+ }
163
+
164
+ export interface ChatCompletionInputFunctionName {
165
+ name : string ;
166
+ [ property : string ] : unknown ;
167
+ }
168
+
169
+ export interface ToolElement {
137
170
function : ChatCompletionInputFunctionDefinition ;
138
171
type : string ;
139
172
[ property : string ] : unknown ;
140
173
}
141
174
175
+ export interface ChatCompletionInputFunctionDefinition {
176
+ arguments : unknown ;
177
+ description ?: string ;
178
+ name : string ;
179
+ [ property : string ] : unknown ;
180
+ }
181
+
142
182
/**
143
183
* Chat Completion Output.
144
184
*
@@ -151,7 +191,6 @@ export interface ChatCompletionOutput {
151
191
created : number ;
152
192
id : string ;
153
193
model : string ;
154
- object : string ;
155
194
system_fingerprint : string ;
156
195
usage : ChatCompletionOutputUsage ;
157
196
[ property : string ] : unknown ;
@@ -185,15 +224,14 @@ export interface ChatCompletionOutputTopLogprob {
185
224
186
225
export interface ChatCompletionOutputMessage {
187
226
content ?: string ;
188
- name ?: string ;
189
227
role : string ;
190
228
tool_calls ?: ChatCompletionOutputToolCall [ ] ;
191
229
[ property : string ] : unknown ;
192
230
}
193
231
194
232
export interface ChatCompletionOutputToolCall {
195
233
function : ChatCompletionOutputFunctionDefinition ;
196
- id : number ;
234
+ id : string ;
197
235
type : string ;
198
236
[ property : string ] : unknown ;
199
237
}
@@ -224,8 +262,8 @@ export interface ChatCompletionStreamOutput {
224
262
created : number ;
225
263
id : string ;
226
264
model : string ;
227
- object : string ;
228
265
system_fingerprint : string ;
266
+ usage ?: ChatCompletionStreamOutputUsage ;
229
267
[ property : string ] : unknown ;
230
268
}
231
269
@@ -275,3 +313,10 @@ export interface ChatCompletionStreamOutputTopLogprob {
275
313
token : string ;
276
314
[ property : string ] : unknown ;
277
315
}
316
+
317
+ export interface ChatCompletionStreamOutputUsage {
318
+ completion_tokens : number ;
319
+ prompt_tokens : number ;
320
+ total_tokens : number ;
321
+ [ property : string ] : unknown ;
322
+ }
0 commit comments