@effect/ai-openai 4.0.0-beta.7 → 4.0.0-beta.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Generated.d.ts +66734 -37723
- package/dist/Generated.d.ts.map +1 -1
- package/dist/Generated.js +1 -1
- package/dist/Generated.js.map +1 -1
- package/dist/OpenAiClient.d.ts +81 -25
- package/dist/OpenAiClient.d.ts.map +1 -1
- package/dist/OpenAiClient.js +220 -39
- package/dist/OpenAiClient.js.map +1 -1
- package/dist/OpenAiClientGenerated.d.ts +91 -0
- package/dist/OpenAiClientGenerated.d.ts.map +1 -0
- package/dist/OpenAiClientGenerated.js +84 -0
- package/dist/OpenAiClientGenerated.js.map +1 -0
- package/dist/OpenAiConfig.d.ts +45 -10
- package/dist/OpenAiConfig.d.ts.map +1 -1
- package/dist/OpenAiConfig.js +31 -7
- package/dist/OpenAiConfig.js.map +1 -1
- package/dist/OpenAiEmbeddingModel.d.ts +89 -0
- package/dist/OpenAiEmbeddingModel.d.ts.map +1 -0
- package/dist/OpenAiEmbeddingModel.js +121 -0
- package/dist/OpenAiEmbeddingModel.js.map +1 -0
- package/dist/OpenAiError.d.ts +168 -35
- package/dist/OpenAiError.d.ts.map +1 -1
- package/dist/OpenAiError.js +1 -1
- package/dist/OpenAiLanguageModel.d.ts +250 -57
- package/dist/OpenAiLanguageModel.d.ts.map +1 -1
- package/dist/OpenAiLanguageModel.js +311 -160
- package/dist/OpenAiLanguageModel.js.map +1 -1
- package/dist/OpenAiSchema.d.ts +2029 -0
- package/dist/OpenAiSchema.d.ts.map +1 -0
- package/dist/OpenAiSchema.js +591 -0
- package/dist/OpenAiSchema.js.map +1 -0
- package/dist/OpenAiTelemetry.d.ts +31 -18
- package/dist/OpenAiTelemetry.d.ts.map +1 -1
- package/dist/OpenAiTelemetry.js +6 -4
- package/dist/OpenAiTelemetry.js.map +1 -1
- package/dist/OpenAiTool.d.ts +56 -67
- package/dist/OpenAiTool.d.ts.map +1 -1
- package/dist/OpenAiTool.js +33 -44
- package/dist/OpenAiTool.js.map +1 -1
- package/dist/index.d.ts +42 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -8
- package/dist/index.js.map +1 -1
- package/dist/internal/errors.js +4 -4
- package/dist/internal/errors.js.map +1 -1
- package/package.json +3 -3
- package/src/Generated.ts +9858 -5044
- package/src/OpenAiClient.ts +396 -90
- package/src/OpenAiClientGenerated.ts +202 -0
- package/src/OpenAiConfig.ts +46 -11
- package/src/OpenAiEmbeddingModel.ts +207 -0
- package/src/OpenAiError.ts +170 -35
- package/src/OpenAiLanguageModel.ts +633 -157
- package/src/OpenAiSchema.ts +984 -0
- package/src/OpenAiTelemetry.ts +32 -19
- package/src/OpenAiTool.ts +34 -45
- package/src/index.ts +45 -8
- package/src/internal/errors.ts +6 -4
|
@@ -0,0 +1,984 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal local OpenAI schemas used by the handwritten Responses client path.
|
|
3
|
+
*
|
|
4
|
+
* @since 4.0.0
|
|
5
|
+
*/
|
|
6
|
+
import * as Predicate from "effect/Predicate"
|
|
7
|
+
import * as Schema from "effect/Schema"
|
|
8
|
+
|
|
9
|
+
const UnknownRecord = Schema.Record(Schema.String, Schema.Unknown)
|
|
10
|
+
|
|
11
|
+
const JsonObject = Schema.Record(Schema.String, Schema.Unknown)
|
|
12
|
+
|
|
13
|
+
const MessageRole = Schema.Literals(["system", "developer", "user", "assistant"])
|
|
14
|
+
|
|
15
|
+
const ImageDetail = Schema.Literals(["low", "high", "auto"])
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Schema for optional `include` values on OpenAI Responses requests.
|
|
19
|
+
*
|
|
20
|
+
* **Details**
|
|
21
|
+
*
|
|
22
|
+
* These values request additional response fields such as image URLs, encrypted reasoning content, output logprobs, code interpreter outputs, or web search sources.
|
|
23
|
+
*
|
|
24
|
+
* @category schemas
|
|
25
|
+
* @since 4.0.0
|
|
26
|
+
*/
|
|
27
|
+
export const IncludeEnum = Schema.Literals([
|
|
28
|
+
"message.input_image.image_url",
|
|
29
|
+
"reasoning.encrypted_content",
|
|
30
|
+
"message.output_text.logprobs",
|
|
31
|
+
"code_interpreter_call.outputs",
|
|
32
|
+
"web_search_call.action.sources"
|
|
33
|
+
])
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Type of optional `include` values accepted by OpenAI Responses requests.
|
|
37
|
+
*
|
|
38
|
+
* @category models
|
|
39
|
+
* @since 4.0.0
|
|
40
|
+
*/
|
|
41
|
+
export type IncludeEnum = typeof IncludeEnum.Type
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Schema for lifecycle statuses shared by messages, reasoning items, and tool calls.
|
|
45
|
+
*
|
|
46
|
+
* @category schemas
|
|
47
|
+
* @since 4.0.0
|
|
48
|
+
*/
|
|
49
|
+
export const MessageStatus = Schema.Literals(["in_progress", "completed", "incomplete"])
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Lifecycle status shared by messages, reasoning items, and tool calls.
|
|
53
|
+
*
|
|
54
|
+
* @category models
|
|
55
|
+
* @since 4.0.0
|
|
56
|
+
*/
|
|
57
|
+
export type MessageStatus = typeof MessageStatus.Type
|
|
58
|
+
|
|
59
|
+
const InputTextContent = Schema.Struct({
|
|
60
|
+
type: Schema.Literal("input_text"),
|
|
61
|
+
text: Schema.String
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const InputImageContent = Schema.Struct({
|
|
65
|
+
type: Schema.Literal("input_image"),
|
|
66
|
+
image_url: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
67
|
+
file_id: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
68
|
+
detail: Schema.optionalKey(Schema.NullOr(ImageDetail))
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
const InputFileContent = Schema.Struct({
|
|
72
|
+
type: Schema.Literal("input_file"),
|
|
73
|
+
file_id: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
74
|
+
filename: Schema.optionalKey(Schema.String),
|
|
75
|
+
file_url: Schema.optionalKey(Schema.String),
|
|
76
|
+
file_data: Schema.optionalKey(Schema.String)
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Schema for content blocks accepted in OpenAI Responses input messages.
|
|
81
|
+
*
|
|
82
|
+
* @category schemas
|
|
83
|
+
* @since 4.0.0
|
|
84
|
+
*/
|
|
85
|
+
export const InputContent = Schema.Union([
|
|
86
|
+
InputTextContent,
|
|
87
|
+
InputImageContent,
|
|
88
|
+
InputFileContent
|
|
89
|
+
])
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Content block accepted in OpenAI Responses input messages.
|
|
93
|
+
*
|
|
94
|
+
* @category models
|
|
95
|
+
* @since 4.0.0
|
|
96
|
+
*/
|
|
97
|
+
export type InputContent = typeof InputContent.Type
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Schema for a text block containing a model-provided reasoning summary.
|
|
101
|
+
*
|
|
102
|
+
* @category schemas
|
|
103
|
+
* @since 4.0.0
|
|
104
|
+
*/
|
|
105
|
+
export const SummaryTextContent = Schema.Struct({
|
|
106
|
+
type: Schema.Literal("summary_text"),
|
|
107
|
+
text: Schema.String
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Text content block used for model-provided reasoning summaries.
|
|
112
|
+
*
|
|
113
|
+
* @category models
|
|
114
|
+
* @since 4.0.0
|
|
115
|
+
*/
|
|
116
|
+
export type SummaryTextContent = typeof SummaryTextContent.Type
|
|
117
|
+
|
|
118
|
+
const ReasoningTextContent = Schema.Struct({
|
|
119
|
+
type: Schema.Literal("reasoning_text"),
|
|
120
|
+
text: Schema.String
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
const RefusalContent = Schema.Struct({
|
|
124
|
+
type: Schema.Literal("refusal"),
|
|
125
|
+
refusal: Schema.String
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
const TextContent = Schema.Struct({
|
|
129
|
+
type: Schema.Literal("text"),
|
|
130
|
+
text: Schema.String
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
const ComputerScreenshotContent = Schema.Struct({
|
|
134
|
+
type: Schema.Literal("computer_screenshot"),
|
|
135
|
+
image_url: Schema.NullOr(Schema.String),
|
|
136
|
+
file_id: Schema.NullOr(Schema.String)
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
const FileCitationAnnotation = Schema.Struct({
|
|
140
|
+
type: Schema.Literal("file_citation"),
|
|
141
|
+
file_id: Schema.String,
|
|
142
|
+
index: Schema.Number,
|
|
143
|
+
filename: Schema.String
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
const UrlCitationAnnotation = Schema.Struct({
|
|
147
|
+
type: Schema.Literal("url_citation"),
|
|
148
|
+
url: Schema.String,
|
|
149
|
+
start_index: Schema.Number,
|
|
150
|
+
end_index: Schema.Number,
|
|
151
|
+
title: Schema.String
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
const ContainerFileCitationAnnotation = Schema.Struct({
|
|
155
|
+
type: Schema.Literal("container_file_citation"),
|
|
156
|
+
container_id: Schema.String,
|
|
157
|
+
file_id: Schema.String,
|
|
158
|
+
start_index: Schema.Number,
|
|
159
|
+
end_index: Schema.Number,
|
|
160
|
+
filename: Schema.String
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
const FilePathAnnotation = Schema.Struct({
|
|
164
|
+
type: Schema.Literal("file_path"),
|
|
165
|
+
file_id: Schema.String,
|
|
166
|
+
index: Schema.Number
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Schema for citation and file-path annotations attached to output text content.
|
|
171
|
+
*
|
|
172
|
+
* @category schemas
|
|
173
|
+
* @since 4.0.0
|
|
174
|
+
*/
|
|
175
|
+
export const Annotation = Schema.Union([
|
|
176
|
+
FileCitationAnnotation,
|
|
177
|
+
UrlCitationAnnotation,
|
|
178
|
+
ContainerFileCitationAnnotation,
|
|
179
|
+
FilePathAnnotation
|
|
180
|
+
])
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Citation or file-path annotation attached to output text content.
|
|
184
|
+
*
|
|
185
|
+
* @category models
|
|
186
|
+
* @since 4.0.0
|
|
187
|
+
*/
|
|
188
|
+
export type Annotation = typeof Annotation.Type
|
|
189
|
+
|
|
190
|
+
const OutputTextContent = Schema.Struct({
|
|
191
|
+
type: Schema.Literal("output_text"),
|
|
192
|
+
text: Schema.String,
|
|
193
|
+
annotations: Schema.Array(Annotation),
|
|
194
|
+
logprobs: Schema.optionalKey(Schema.Array(Schema.Unknown))
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
const OutputMessageContent = Schema.Union([
|
|
198
|
+
InputTextContent,
|
|
199
|
+
OutputTextContent,
|
|
200
|
+
TextContent,
|
|
201
|
+
SummaryTextContent,
|
|
202
|
+
ReasoningTextContent,
|
|
203
|
+
RefusalContent,
|
|
204
|
+
InputImageContent,
|
|
205
|
+
ComputerScreenshotContent,
|
|
206
|
+
InputFileContent
|
|
207
|
+
])
|
|
208
|
+
|
|
209
|
+
const OutputMessage = Schema.Struct({
|
|
210
|
+
id: Schema.String,
|
|
211
|
+
type: Schema.Literal("message"),
|
|
212
|
+
role: Schema.Literal("assistant"),
|
|
213
|
+
content: Schema.Array(OutputMessageContent),
|
|
214
|
+
status: MessageStatus
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Schema for a reasoning output item containing encrypted content, summaries, and optional reasoning text.
|
|
219
|
+
*
|
|
220
|
+
* @category schemas
|
|
221
|
+
* @since 4.0.0
|
|
222
|
+
*/
|
|
223
|
+
export const ReasoningItem = Schema.Struct({
|
|
224
|
+
type: Schema.Literal("reasoning"),
|
|
225
|
+
id: Schema.String,
|
|
226
|
+
encrypted_content: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
227
|
+
summary: Schema.Array(SummaryTextContent),
|
|
228
|
+
content: Schema.optionalKey(Schema.Array(ReasoningTextContent)),
|
|
229
|
+
status: Schema.optionalKey(MessageStatus)
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Reasoning output item containing encrypted content, summaries, and optional reasoning text.
|
|
234
|
+
*
|
|
235
|
+
* @category models
|
|
236
|
+
* @since 4.0.0
|
|
237
|
+
*/
|
|
238
|
+
export type ReasoningItem = typeof ReasoningItem.Type
|
|
239
|
+
|
|
240
|
+
const FunctionCall = Schema.Struct({
|
|
241
|
+
id: Schema.optionalKey(Schema.String),
|
|
242
|
+
type: Schema.Literal("function_call"),
|
|
243
|
+
call_id: Schema.String,
|
|
244
|
+
name: Schema.String,
|
|
245
|
+
arguments: Schema.String,
|
|
246
|
+
status: Schema.optionalKey(MessageStatus)
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
const FunctionCallOutput = Schema.Struct({
|
|
250
|
+
id: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
251
|
+
type: Schema.Literal("function_call_output"),
|
|
252
|
+
call_id: Schema.String,
|
|
253
|
+
output: Schema.Union([
|
|
254
|
+
Schema.String,
|
|
255
|
+
Schema.Array(InputContent)
|
|
256
|
+
]),
|
|
257
|
+
status: Schema.optionalKey(Schema.NullOr(MessageStatus))
|
|
258
|
+
})
|
|
259
|
+
|
|
260
|
+
const ItemReference = Schema.Struct({
|
|
261
|
+
type: Schema.Literal("item_reference"),
|
|
262
|
+
id: Schema.String
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
const LocalShellCall = Schema.Struct({
|
|
266
|
+
id: Schema.optionalKey(Schema.String),
|
|
267
|
+
type: Schema.Literal("local_shell_call"),
|
|
268
|
+
call_id: Schema.String,
|
|
269
|
+
action: Schema.Unknown,
|
|
270
|
+
status: Schema.optionalKey(MessageStatus)
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
const LocalShellCallOutput = Schema.Struct({
|
|
274
|
+
id: Schema.optionalKey(Schema.String),
|
|
275
|
+
type: Schema.Literal("local_shell_call_output"),
|
|
276
|
+
call_id: Schema.String,
|
|
277
|
+
output: Schema.Unknown,
|
|
278
|
+
status: Schema.optionalKey(MessageStatus)
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
const ShellCall = Schema.Struct({
|
|
282
|
+
id: Schema.optionalKey(Schema.String),
|
|
283
|
+
type: Schema.Literal("shell_call"),
|
|
284
|
+
call_id: Schema.String,
|
|
285
|
+
action: Schema.Unknown,
|
|
286
|
+
status: Schema.optionalKey(MessageStatus)
|
|
287
|
+
})
|
|
288
|
+
|
|
289
|
+
const ShellCallOutput = Schema.Struct({
|
|
290
|
+
id: Schema.optionalKey(Schema.String),
|
|
291
|
+
type: Schema.Literal("shell_call_output"),
|
|
292
|
+
call_id: Schema.String,
|
|
293
|
+
output: Schema.Unknown,
|
|
294
|
+
status: Schema.optionalKey(MessageStatus)
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
const ApplyPatchCallOutput = Schema.Struct({
|
|
298
|
+
id: Schema.optionalKey(Schema.String),
|
|
299
|
+
type: Schema.Literal("apply_patch_call_output"),
|
|
300
|
+
call_id: Schema.String,
|
|
301
|
+
status: Schema.optionalKey(MessageStatus),
|
|
302
|
+
output: Schema.optionalKey(Schema.Unknown)
|
|
303
|
+
})
|
|
304
|
+
|
|
305
|
+
const McpApprovalResponse = Schema.Struct({
|
|
306
|
+
type: Schema.Literal("mcp_approval_response"),
|
|
307
|
+
approval_request_id: Schema.String,
|
|
308
|
+
approve: Schema.Boolean
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
const RequestMessageItem = Schema.Struct({
|
|
312
|
+
type: Schema.optionalKey(Schema.Literal("message")),
|
|
313
|
+
role: MessageRole,
|
|
314
|
+
status: Schema.optionalKey(MessageStatus),
|
|
315
|
+
content: Schema.Union([
|
|
316
|
+
Schema.String,
|
|
317
|
+
Schema.Array(InputContent)
|
|
318
|
+
])
|
|
319
|
+
})
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Schema for item shapes accepted by an OpenAI Responses request `input` field.
|
|
323
|
+
*
|
|
324
|
+
* @category schemas
|
|
325
|
+
* @since 4.0.0
|
|
326
|
+
*/
|
|
327
|
+
export const InputItem = Schema.Union([
|
|
328
|
+
RequestMessageItem,
|
|
329
|
+
OutputMessage,
|
|
330
|
+
FunctionCall,
|
|
331
|
+
FunctionCallOutput,
|
|
332
|
+
ReasoningItem,
|
|
333
|
+
ItemReference,
|
|
334
|
+
LocalShellCall,
|
|
335
|
+
LocalShellCallOutput,
|
|
336
|
+
ShellCall,
|
|
337
|
+
ShellCallOutput,
|
|
338
|
+
ApplyPatchCallOutput,
|
|
339
|
+
McpApprovalResponse
|
|
340
|
+
])
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Item shape accepted by an OpenAI Responses request `input` field.
|
|
344
|
+
*
|
|
345
|
+
* @category models
|
|
346
|
+
* @since 4.0.0
|
|
347
|
+
*/
|
|
348
|
+
export type InputItem = typeof InputItem.Type
|
|
349
|
+
|
|
350
|
+
const FunctionTool = Schema.Struct({
|
|
351
|
+
type: Schema.Literal("function"),
|
|
352
|
+
name: Schema.String,
|
|
353
|
+
description: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
354
|
+
parameters: Schema.optionalKey(Schema.NullOr(JsonObject)),
|
|
355
|
+
strict: Schema.optionalKey(Schema.NullOr(Schema.Boolean))
|
|
356
|
+
})
|
|
357
|
+
|
|
358
|
+
const CustomTool = Schema.Struct({
|
|
359
|
+
type: Schema.Literal("custom"),
|
|
360
|
+
name: Schema.String,
|
|
361
|
+
description: Schema.optionalKey(Schema.String),
|
|
362
|
+
format: Schema.optionalKey(Schema.Unknown)
|
|
363
|
+
})
|
|
364
|
+
|
|
365
|
+
const ProviderDefinedTool = Schema.StructWithRest(
|
|
366
|
+
Schema.Struct({
|
|
367
|
+
type: Schema.Literals([
|
|
368
|
+
"apply_patch",
|
|
369
|
+
"code_interpreter",
|
|
370
|
+
"file_search",
|
|
371
|
+
"image_generation",
|
|
372
|
+
"local_shell",
|
|
373
|
+
"mcp",
|
|
374
|
+
"shell",
|
|
375
|
+
"web_search",
|
|
376
|
+
"web_search_preview"
|
|
377
|
+
])
|
|
378
|
+
}),
|
|
379
|
+
[UnknownRecord]
|
|
380
|
+
)
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Schema for tool definitions that can be supplied to an OpenAI Responses request.
|
|
384
|
+
*
|
|
385
|
+
* @category schemas
|
|
386
|
+
* @since 4.0.0
|
|
387
|
+
*/
|
|
388
|
+
export const Tool = Schema.Union([
|
|
389
|
+
FunctionTool,
|
|
390
|
+
CustomTool,
|
|
391
|
+
ProviderDefinedTool
|
|
392
|
+
])
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Tool definition that can be supplied to an OpenAI Responses request.
|
|
396
|
+
*
|
|
397
|
+
* @category models
|
|
398
|
+
* @since 4.0.0
|
|
399
|
+
*/
|
|
400
|
+
export type Tool = typeof Tool.Type
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Schema for selecting whether and which tools the model may call in a Responses request.
|
|
404
|
+
*
|
|
405
|
+
* @category schemas
|
|
406
|
+
* @since 4.0.0
|
|
407
|
+
*/
|
|
408
|
+
export const ToolChoice = Schema.Union([
|
|
409
|
+
Schema.Literals(["none", "auto", "required"]),
|
|
410
|
+
Schema.Struct({
|
|
411
|
+
type: Schema.Literal("allowed_tools"),
|
|
412
|
+
mode: Schema.Literals(["auto", "required"]),
|
|
413
|
+
tools: Schema.Array(JsonObject)
|
|
414
|
+
}),
|
|
415
|
+
Schema.Struct({
|
|
416
|
+
type: Schema.Literal("function"),
|
|
417
|
+
name: Schema.String
|
|
418
|
+
}),
|
|
419
|
+
Schema.Struct({
|
|
420
|
+
type: Schema.Literal("custom"),
|
|
421
|
+
name: Schema.String
|
|
422
|
+
}),
|
|
423
|
+
Schema.StructWithRest(
|
|
424
|
+
Schema.Struct({
|
|
425
|
+
type: Schema.Literals([
|
|
426
|
+
"apply_patch",
|
|
427
|
+
"code_interpreter",
|
|
428
|
+
"file_search",
|
|
429
|
+
"image_generation",
|
|
430
|
+
"local_shell",
|
|
431
|
+
"mcp",
|
|
432
|
+
"shell",
|
|
433
|
+
"web_search",
|
|
434
|
+
"web_search_preview"
|
|
435
|
+
])
|
|
436
|
+
}),
|
|
437
|
+
[UnknownRecord]
|
|
438
|
+
)
|
|
439
|
+
])
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Tool selection mode or named tool choice for a Responses request.
|
|
443
|
+
*
|
|
444
|
+
* @category models
|
|
445
|
+
* @since 4.0.0
|
|
446
|
+
*/
|
|
447
|
+
export type ToolChoice = typeof ToolChoice.Type
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Schema for text output format configuration, including plain text, JSON object, and JSON Schema responses.
|
|
451
|
+
*
|
|
452
|
+
* @category schemas
|
|
453
|
+
* @since 4.0.0
|
|
454
|
+
*/
|
|
455
|
+
export const TextResponseFormatConfiguration = Schema.Union([
|
|
456
|
+
Schema.Struct({ type: Schema.Literal("text") }),
|
|
457
|
+
Schema.Struct({
|
|
458
|
+
type: Schema.Literal("json_schema"),
|
|
459
|
+
description: Schema.optionalKey(Schema.String),
|
|
460
|
+
name: Schema.String,
|
|
461
|
+
schema: JsonObject,
|
|
462
|
+
strict: Schema.optionalKey(Schema.NullOr(Schema.Boolean))
|
|
463
|
+
}),
|
|
464
|
+
Schema.Struct({ type: Schema.Literal("json_object") })
|
|
465
|
+
])
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Text output format configuration for plain text, JSON object, or JSON Schema responses.
|
|
469
|
+
*
|
|
470
|
+
* @category models
|
|
471
|
+
* @since 4.0.0
|
|
472
|
+
*/
|
|
473
|
+
export type TextResponseFormatConfiguration = typeof TextResponseFormatConfiguration.Type
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Schema for request options used to create an OpenAI Responses API response.
|
|
477
|
+
*
|
|
478
|
+
* @category schemas
|
|
479
|
+
* @since 4.0.0
|
|
480
|
+
*/
|
|
481
|
+
export const CreateResponse = Schema.Struct({
|
|
482
|
+
metadata: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
|
483
|
+
top_logprobs: Schema.optional(Schema.Number),
|
|
484
|
+
temperature: Schema.optional(Schema.Number),
|
|
485
|
+
top_p: Schema.optional(Schema.Number),
|
|
486
|
+
user: Schema.optional(Schema.String),
|
|
487
|
+
service_tier: Schema.optional(Schema.String),
|
|
488
|
+
previous_response_id: Schema.optional(Schema.String),
|
|
489
|
+
model: Schema.optional(Schema.String),
|
|
490
|
+
reasoning: Schema.optional(Schema.Struct({
|
|
491
|
+
effort: Schema.optional(Schema.Literals(["none", "minimal", "low", "medium", "high", "xhigh"])),
|
|
492
|
+
|
|
493
|
+
summary: Schema.optional(Schema.Literals(["auto", "concise", "detailed"])),
|
|
494
|
+
generate_summary: Schema.optional(Schema.Literals(["auto", "concise", "detailed"]))
|
|
495
|
+
})),
|
|
496
|
+
background: Schema.optional(Schema.Boolean),
|
|
497
|
+
max_output_tokens: Schema.optional(Schema.Number),
|
|
498
|
+
max_tool_calls: Schema.optional(Schema.Number),
|
|
499
|
+
text: Schema.optional(
|
|
500
|
+
Schema.Struct({
|
|
501
|
+
format: Schema.optional(TextResponseFormatConfiguration),
|
|
502
|
+
verbosity: Schema.optional(Schema.Literals(["low", "medium", "high"]))
|
|
503
|
+
})
|
|
504
|
+
),
|
|
505
|
+
tools: Schema.optional(Schema.Array(Tool)),
|
|
506
|
+
tool_choice: Schema.optional(ToolChoice),
|
|
507
|
+
truncation: Schema.optional(Schema.Literals(["auto", "disabled"])),
|
|
508
|
+
input: Schema.optional(
|
|
509
|
+
Schema.Union([
|
|
510
|
+
Schema.String,
|
|
511
|
+
Schema.Array(InputItem)
|
|
512
|
+
])
|
|
513
|
+
),
|
|
514
|
+
include: Schema.optional(Schema.Array(IncludeEnum)),
|
|
515
|
+
store: Schema.optional(Schema.Boolean),
|
|
516
|
+
instructions: Schema.optional(Schema.String),
|
|
517
|
+
stream: Schema.optional(Schema.Boolean),
|
|
518
|
+
conversation: Schema.optional(Schema.String),
|
|
519
|
+
modalities: Schema.optional(Schema.Array(Schema.Literals(["text", "audio"]))),
|
|
520
|
+
seed: Schema.optional(Schema.Number)
|
|
521
|
+
})
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Request options used to create an OpenAI Responses API response.
|
|
525
|
+
*
|
|
526
|
+
* @category models
|
|
527
|
+
* @since 4.0.0
|
|
528
|
+
*/
|
|
529
|
+
export type CreateResponse = typeof CreateResponse.Type
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Schema for token accounting reported on OpenAI Responses API response objects.
|
|
533
|
+
*
|
|
534
|
+
* @category schemas
|
|
535
|
+
* @since 4.0.0
|
|
536
|
+
*/
|
|
537
|
+
export const ResponseUsage = Schema.StructWithRest(
|
|
538
|
+
Schema.Struct({
|
|
539
|
+
input_tokens: Schema.Number,
|
|
540
|
+
output_tokens: Schema.Number,
|
|
541
|
+
total_tokens: Schema.Number,
|
|
542
|
+
input_tokens_details: Schema.optionalKey(Schema.Unknown),
|
|
543
|
+
output_tokens_details: Schema.optionalKey(Schema.Unknown)
|
|
544
|
+
}),
|
|
545
|
+
[UnknownRecord]
|
|
546
|
+
)
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Token accounting reported on OpenAI Responses API response objects.
|
|
550
|
+
*
|
|
551
|
+
* @category models
|
|
552
|
+
* @since 4.0.0
|
|
553
|
+
*/
|
|
554
|
+
export type ResponseUsage = typeof ResponseUsage.Type
|
|
555
|
+
|
|
556
|
+
const ApplyPatchOperation = Schema.Struct({
|
|
557
|
+
type: Schema.String,
|
|
558
|
+
path: Schema.String,
|
|
559
|
+
diff: Schema.optionalKey(Schema.String)
|
|
560
|
+
})
|
|
561
|
+
|
|
562
|
+
const ApplyPatchCall = Schema.Struct({
|
|
563
|
+
id: Schema.String,
|
|
564
|
+
type: Schema.Literal("apply_patch_call"),
|
|
565
|
+
call_id: Schema.String,
|
|
566
|
+
operation: ApplyPatchOperation,
|
|
567
|
+
status: Schema.optionalKey(MessageStatus)
|
|
568
|
+
})
|
|
569
|
+
|
|
570
|
+
const CodeInterpreterCall = Schema.Struct({
|
|
571
|
+
id: Schema.String,
|
|
572
|
+
type: Schema.Literal("code_interpreter_call"),
|
|
573
|
+
code: Schema.optionalKey(Schema.String),
|
|
574
|
+
container_id: Schema.String,
|
|
575
|
+
outputs: Schema.optionalKey(Schema.Array(Schema.Unknown)),
|
|
576
|
+
status: Schema.optionalKey(MessageStatus)
|
|
577
|
+
})
|
|
578
|
+
|
|
579
|
+
const ComputerCall = Schema.Struct({
|
|
580
|
+
id: Schema.String,
|
|
581
|
+
type: Schema.Literal("computer_call"),
|
|
582
|
+
status: Schema.optionalKey(MessageStatus)
|
|
583
|
+
})
|
|
584
|
+
|
|
585
|
+
const FileSearchCall = Schema.Struct({
|
|
586
|
+
id: Schema.String,
|
|
587
|
+
type: Schema.Literal("file_search_call"),
|
|
588
|
+
status: Schema.optionalKey(Schema.String),
|
|
589
|
+
queries: Schema.optionalKey(Schema.Array(Schema.String)),
|
|
590
|
+
results: Schema.optionalKey(Schema.NullOr(Schema.Unknown))
|
|
591
|
+
})
|
|
592
|
+
|
|
593
|
+
const ImageGenerationCall = Schema.Struct({
|
|
594
|
+
id: Schema.String,
|
|
595
|
+
type: Schema.Literal("image_generation_call"),
|
|
596
|
+
result: Schema.optionalKey(Schema.String),
|
|
597
|
+
status: Schema.optionalKey(MessageStatus)
|
|
598
|
+
})
|
|
599
|
+
|
|
600
|
+
const McpCall = Schema.Struct({
|
|
601
|
+
id: Schema.String,
|
|
602
|
+
type: Schema.Literal("mcp_call"),
|
|
603
|
+
approval_request_id: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
604
|
+
name: Schema.String,
|
|
605
|
+
arguments: Schema.Unknown,
|
|
606
|
+
output: Schema.optionalKey(Schema.Unknown),
|
|
607
|
+
error: Schema.optionalKey(Schema.Unknown),
|
|
608
|
+
server_label: Schema.optionalKey(Schema.NullOr(Schema.String))
|
|
609
|
+
})
|
|
610
|
+
|
|
611
|
+
const McpListTools = Schema.Struct({
|
|
612
|
+
id: Schema.String,
|
|
613
|
+
type: Schema.Literal("mcp_list_tools")
|
|
614
|
+
})
|
|
615
|
+
|
|
616
|
+
const McpApprovalRequest = Schema.Struct({
|
|
617
|
+
id: Schema.String,
|
|
618
|
+
type: Schema.Literal("mcp_approval_request"),
|
|
619
|
+
approval_request_id: Schema.optionalKey(Schema.String),
|
|
620
|
+
name: Schema.String,
|
|
621
|
+
arguments: Schema.Unknown
|
|
622
|
+
})
|
|
623
|
+
|
|
624
|
+
const WebSearchCall = Schema.Struct({
|
|
625
|
+
id: Schema.String,
|
|
626
|
+
type: Schema.Literal("web_search_call"),
|
|
627
|
+
action: Schema.optionalKey(Schema.Unknown),
|
|
628
|
+
status: Schema.optionalKey(Schema.String)
|
|
629
|
+
})
|
|
630
|
+
|
|
631
|
+
const OutputItem = Schema.Union([
|
|
632
|
+
ApplyPatchCall,
|
|
633
|
+
CodeInterpreterCall,
|
|
634
|
+
ComputerCall,
|
|
635
|
+
FileSearchCall,
|
|
636
|
+
FunctionCall,
|
|
637
|
+
ImageGenerationCall,
|
|
638
|
+
LocalShellCall,
|
|
639
|
+
McpCall,
|
|
640
|
+
McpListTools,
|
|
641
|
+
McpApprovalRequest,
|
|
642
|
+
OutputMessage,
|
|
643
|
+
ReasoningItem,
|
|
644
|
+
ShellCall,
|
|
645
|
+
WebSearchCall
|
|
646
|
+
])
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Schema for an OpenAI Responses API response object.
|
|
650
|
+
*
|
|
651
|
+
* @category schemas
|
|
652
|
+
* @since 4.0.0
|
|
653
|
+
*/
|
|
654
|
+
export const Response = Schema.Struct({
|
|
655
|
+
id: Schema.String,
|
|
656
|
+
object: Schema.optionalKey(Schema.Literal("response")),
|
|
657
|
+
model: Schema.String,
|
|
658
|
+
created_at: Schema.Number,
|
|
659
|
+
output: Schema.Array(OutputItem),
|
|
660
|
+
usage: Schema.optionalKey(Schema.NullOr(ResponseUsage)),
|
|
661
|
+
incomplete_details: Schema.optionalKey(
|
|
662
|
+
Schema.NullOr(
|
|
663
|
+
Schema.Struct({
|
|
664
|
+
reason: Schema.optionalKey(Schema.Literals(["max_output_tokens", "content_filter"]))
|
|
665
|
+
})
|
|
666
|
+
)
|
|
667
|
+
),
|
|
668
|
+
service_tier: Schema.optionalKey(Schema.String)
|
|
669
|
+
})
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* OpenAI Responses API response object.
|
|
673
|
+
*
|
|
674
|
+
* @category models
|
|
675
|
+
* @since 4.0.0
|
|
676
|
+
*/
|
|
677
|
+
export type Response = typeof Response.Type
|
|
678
|
+
|
|
679
|
+
const ResponseCreatedEvent = Schema.Struct({
|
|
680
|
+
type: Schema.Literal("response.created"),
|
|
681
|
+
response: Response,
|
|
682
|
+
sequence_number: Schema.Number
|
|
683
|
+
})
|
|
684
|
+
|
|
685
|
+
const ResponseCompletedEvent = Schema.Struct({
|
|
686
|
+
type: Schema.Literal("response.completed"),
|
|
687
|
+
response: Response,
|
|
688
|
+
sequence_number: Schema.Number
|
|
689
|
+
})
|
|
690
|
+
|
|
691
|
+
const ResponseIncompleteEvent = Schema.Struct({
|
|
692
|
+
type: Schema.Literal("response.incomplete"),
|
|
693
|
+
response: Response,
|
|
694
|
+
sequence_number: Schema.Number
|
|
695
|
+
})
|
|
696
|
+
|
|
697
|
+
const ResponseFailedEvent = Schema.Struct({
|
|
698
|
+
type: Schema.Literal("response.failed"),
|
|
699
|
+
response: Response,
|
|
700
|
+
sequence_number: Schema.Number
|
|
701
|
+
})
|
|
702
|
+
|
|
703
|
+
const ResponseOutputItemAddedEvent = Schema.Struct({
|
|
704
|
+
type: Schema.Literal("response.output_item.added"),
|
|
705
|
+
output_index: Schema.Number,
|
|
706
|
+
sequence_number: Schema.Number,
|
|
707
|
+
item: OutputItem
|
|
708
|
+
})
|
|
709
|
+
|
|
710
|
+
const ResponseOutputItemDoneEvent = Schema.Struct({
|
|
711
|
+
type: Schema.Literal("response.output_item.done"),
|
|
712
|
+
output_index: Schema.Number,
|
|
713
|
+
sequence_number: Schema.Number,
|
|
714
|
+
item: OutputItem
|
|
715
|
+
})
|
|
716
|
+
|
|
717
|
+
const ResponseOutputTextDeltaEvent = Schema.Struct({
|
|
718
|
+
type: Schema.Literal("response.output_text.delta"),
|
|
719
|
+
item_id: Schema.String,
|
|
720
|
+
output_index: Schema.Number,
|
|
721
|
+
content_index: Schema.Number,
|
|
722
|
+
delta: Schema.String,
|
|
723
|
+
sequence_number: Schema.Number,
|
|
724
|
+
logprobs: Schema.optionalKey(Schema.Array(Schema.Unknown))
|
|
725
|
+
})
|
|
726
|
+
|
|
727
|
+
const ResponseOutputTextAnnotationAddedEvent = Schema.Struct({
|
|
728
|
+
type: Schema.Literal("response.output_text.annotation.added"),
|
|
729
|
+
item_id: Schema.String,
|
|
730
|
+
output_index: Schema.Number,
|
|
731
|
+
content_index: Schema.Number,
|
|
732
|
+
annotation_index: Schema.Number,
|
|
733
|
+
sequence_number: Schema.Number,
|
|
734
|
+
annotation: Annotation
|
|
735
|
+
})
|
|
736
|
+
|
|
737
|
+
const ResponseReasoningSummaryPartAddedEvent = Schema.Struct({
|
|
738
|
+
type: Schema.Literal("response.reasoning_summary_part.added"),
|
|
739
|
+
item_id: Schema.String,
|
|
740
|
+
output_index: Schema.Number,
|
|
741
|
+
summary_index: Schema.Number,
|
|
742
|
+
sequence_number: Schema.Number,
|
|
743
|
+
part: SummaryTextContent
|
|
744
|
+
})
|
|
745
|
+
|
|
746
|
+
const ResponseReasoningSummaryPartDoneEvent = Schema.Struct({
|
|
747
|
+
type: Schema.Literal("response.reasoning_summary_part.done"),
|
|
748
|
+
item_id: Schema.String,
|
|
749
|
+
output_index: Schema.Number,
|
|
750
|
+
summary_index: Schema.Number,
|
|
751
|
+
sequence_number: Schema.Number,
|
|
752
|
+
part: SummaryTextContent
|
|
753
|
+
})
|
|
754
|
+
|
|
755
|
+
const ResponseReasoningSummaryTextDeltaEvent = Schema.Struct({
|
|
756
|
+
type: Schema.Literal("response.reasoning_summary_text.delta"),
|
|
757
|
+
item_id: Schema.String,
|
|
758
|
+
output_index: Schema.Number,
|
|
759
|
+
summary_index: Schema.Number,
|
|
760
|
+
delta: Schema.String,
|
|
761
|
+
sequence_number: Schema.Number
|
|
762
|
+
})
|
|
763
|
+
|
|
764
|
+
const ResponseFunctionCallArgumentsDeltaEvent = Schema.Struct({
|
|
765
|
+
type: Schema.Literal("response.function_call_arguments.delta"),
|
|
766
|
+
item_id: Schema.String,
|
|
767
|
+
output_index: Schema.Number,
|
|
768
|
+
sequence_number: Schema.Number,
|
|
769
|
+
delta: Schema.String
|
|
770
|
+
})
|
|
771
|
+
|
|
772
|
+
const ResponseFunctionCallArgumentsDoneEvent = Schema.Struct({
|
|
773
|
+
type: Schema.Literal("response.function_call_arguments.done"),
|
|
774
|
+
item_id: Schema.String,
|
|
775
|
+
output_index: Schema.Number,
|
|
776
|
+
sequence_number: Schema.Number,
|
|
777
|
+
arguments: Schema.String
|
|
778
|
+
})
|
|
779
|
+
|
|
780
|
+
const ResponseCodeInterpreterCallCodeDeltaEvent = Schema.Struct({
|
|
781
|
+
type: Schema.Literal("response.code_interpreter_call_code.delta"),
|
|
782
|
+
item_id: Schema.String,
|
|
783
|
+
output_index: Schema.Number,
|
|
784
|
+
sequence_number: Schema.Number,
|
|
785
|
+
delta: Schema.String
|
|
786
|
+
})
|
|
787
|
+
|
|
788
|
+
const ResponseCodeInterpreterCallCodeDoneEvent = Schema.Struct({
|
|
789
|
+
type: Schema.Literal("response.code_interpreter_call_code.done"),
|
|
790
|
+
item_id: Schema.String,
|
|
791
|
+
output_index: Schema.Number,
|
|
792
|
+
sequence_number: Schema.Number,
|
|
793
|
+
code: Schema.String
|
|
794
|
+
})
|
|
795
|
+
|
|
796
|
+
const ResponseApplyPatchCallOperationDiffDeltaEvent = Schema.Struct({
|
|
797
|
+
type: Schema.Literal("response.apply_patch_call_operation_diff.delta"),
|
|
798
|
+
item_id: Schema.String,
|
|
799
|
+
output_index: Schema.Number,
|
|
800
|
+
sequence_number: Schema.Number,
|
|
801
|
+
delta: Schema.String
|
|
802
|
+
})
|
|
803
|
+
|
|
804
|
+
const ResponseApplyPatchCallOperationDiffDoneEvent = Schema.Struct({
|
|
805
|
+
type: Schema.Literal("response.apply_patch_call_operation_diff.done"),
|
|
806
|
+
item_id: Schema.String,
|
|
807
|
+
output_index: Schema.Number,
|
|
808
|
+
sequence_number: Schema.Number,
|
|
809
|
+
delta: Schema.optionalKey(Schema.String)
|
|
810
|
+
})
|
|
811
|
+
|
|
812
|
+
const ResponseImageGenerationCallPartialImageEvent = Schema.Struct({
|
|
813
|
+
type: Schema.Literal("response.image_generation_call.partial_image"),
|
|
814
|
+
item_id: Schema.String,
|
|
815
|
+
output_index: Schema.Number,
|
|
816
|
+
sequence_number: Schema.Number,
|
|
817
|
+
partial_image_b64: Schema.String
|
|
818
|
+
})
|
|
819
|
+
|
|
820
|
+
const ResponseErrorEvent = Schema.Struct({
|
|
821
|
+
type: Schema.Literal("error"),
|
|
822
|
+
code: Schema.NullOr(Schema.String),
|
|
823
|
+
message: Schema.String,
|
|
824
|
+
param: Schema.NullOr(Schema.String),
|
|
825
|
+
sequence_number: Schema.Number,
|
|
826
|
+
status: Schema.optionalKey(Schema.Number)
|
|
827
|
+
})
|
|
828
|
+
|
|
829
|
+
const knownResponseStreamEventTypes = new Set([
|
|
830
|
+
"response.created",
|
|
831
|
+
"response.completed",
|
|
832
|
+
"response.incomplete",
|
|
833
|
+
"response.failed",
|
|
834
|
+
"response.output_item.added",
|
|
835
|
+
"response.output_item.done",
|
|
836
|
+
"response.output_text.delta",
|
|
837
|
+
"response.output_text.annotation.added",
|
|
838
|
+
"response.reasoning_summary_part.added",
|
|
839
|
+
"response.reasoning_summary_part.done",
|
|
840
|
+
"response.reasoning_summary_text.delta",
|
|
841
|
+
"response.function_call_arguments.delta",
|
|
842
|
+
"response.function_call_arguments.done",
|
|
843
|
+
"response.code_interpreter_call_code.delta",
|
|
844
|
+
"response.code_interpreter_call_code.done",
|
|
845
|
+
"response.apply_patch_call_operation_diff.delta",
|
|
846
|
+
"response.apply_patch_call_operation_diff.done",
|
|
847
|
+
"response.image_generation_call.partial_image",
|
|
848
|
+
"error"
|
|
849
|
+
])
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* Fallback event shape for future or provider-specific response stream events.
|
|
853
|
+
*
|
|
854
|
+
* @category models
|
|
855
|
+
* @since 4.0.0
|
|
856
|
+
*/
|
|
857
|
+
export type UnknownResponseStreamEvent = {
|
|
858
|
+
readonly type: string
|
|
859
|
+
readonly [key: string]: unknown
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
const UnknownResponseStreamEvent = Schema.declare<UnknownResponseStreamEvent>(
|
|
863
|
+
(value): value is UnknownResponseStreamEvent =>
|
|
864
|
+
Predicate.hasProperty(value, "type") &&
|
|
865
|
+
typeof value.type === "string" &&
|
|
866
|
+
!knownResponseStreamEventTypes.has(value.type),
|
|
867
|
+
{
|
|
868
|
+
identifier: "UnknownResponseStreamEvent",
|
|
869
|
+
description: "Fallback for unknown future stream events"
|
|
870
|
+
}
|
|
871
|
+
)
|
|
872
|
+
|
|
873
|
+
/**
|
|
874
|
+
* Schema for server-sent event shapes emitted by OpenAI Responses API streams.
|
|
875
|
+
*
|
|
876
|
+
* @category schemas
|
|
877
|
+
* @since 4.0.0
|
|
878
|
+
*/
|
|
879
|
+
export const ResponseStreamEvent = Schema.Union([
|
|
880
|
+
ResponseCreatedEvent,
|
|
881
|
+
ResponseCompletedEvent,
|
|
882
|
+
ResponseIncompleteEvent,
|
|
883
|
+
ResponseFailedEvent,
|
|
884
|
+
ResponseOutputItemAddedEvent,
|
|
885
|
+
ResponseOutputItemDoneEvent,
|
|
886
|
+
ResponseOutputTextDeltaEvent,
|
|
887
|
+
ResponseOutputTextAnnotationAddedEvent,
|
|
888
|
+
ResponseReasoningSummaryPartAddedEvent,
|
|
889
|
+
ResponseReasoningSummaryPartDoneEvent,
|
|
890
|
+
ResponseReasoningSummaryTextDeltaEvent,
|
|
891
|
+
ResponseFunctionCallArgumentsDeltaEvent,
|
|
892
|
+
ResponseFunctionCallArgumentsDoneEvent,
|
|
893
|
+
ResponseCodeInterpreterCallCodeDeltaEvent,
|
|
894
|
+
ResponseCodeInterpreterCallCodeDoneEvent,
|
|
895
|
+
ResponseApplyPatchCallOperationDiffDeltaEvent,
|
|
896
|
+
ResponseApplyPatchCallOperationDiffDoneEvent,
|
|
897
|
+
ResponseImageGenerationCallPartialImageEvent,
|
|
898
|
+
ResponseErrorEvent,
|
|
899
|
+
UnknownResponseStreamEvent
|
|
900
|
+
])
|
|
901
|
+
|
|
902
|
+
/**
|
|
903
|
+
* Server-sent event shape emitted by OpenAI Responses API streams.
|
|
904
|
+
*
|
|
905
|
+
* @category models
|
|
906
|
+
* @since 4.0.0
|
|
907
|
+
*/
|
|
908
|
+
export type ResponseStreamEvent = typeof ResponseStreamEvent.Type
|
|
909
|
+
|
|
910
|
+
/**
|
|
911
|
+
* Schema for one embedding item returned by the OpenAI embeddings API.
|
|
912
|
+
*
|
|
913
|
+
* @category schemas
|
|
914
|
+
* @since 4.0.0
|
|
915
|
+
*/
|
|
916
|
+
export const Embedding = Schema.Struct({
|
|
917
|
+
embedding: Schema.Union([
|
|
918
|
+
Schema.Array(Schema.Number),
|
|
919
|
+
Schema.String
|
|
920
|
+
]),
|
|
921
|
+
index: Schema.Number,
|
|
922
|
+
object: Schema.optionalKey(Schema.String)
|
|
923
|
+
})
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* One embedding item returned by the OpenAI embeddings API.
|
|
927
|
+
*
|
|
928
|
+
* @category models
|
|
929
|
+
* @since 4.0.0
|
|
930
|
+
*/
|
|
931
|
+
export type Embedding = typeof Embedding.Type
|
|
932
|
+
|
|
933
|
+
/**
|
|
934
|
+
* Schema for the request payload sent to the OpenAI embeddings endpoint.
|
|
935
|
+
*
|
|
936
|
+
* @category schemas
|
|
937
|
+
* @since 4.0.0
|
|
938
|
+
*/
|
|
939
|
+
export const CreateEmbeddingRequest = Schema.Struct({
|
|
940
|
+
input: Schema.Union([
|
|
941
|
+
Schema.String,
|
|
942
|
+
Schema.Array(Schema.String),
|
|
943
|
+
Schema.Array(Schema.Number),
|
|
944
|
+
Schema.Array(Schema.Array(Schema.Number))
|
|
945
|
+
]),
|
|
946
|
+
model: Schema.String,
|
|
947
|
+
encoding_format: Schema.optionalKey(Schema.Literals(["float", "base64"])),
|
|
948
|
+
dimensions: Schema.optionalKey(Schema.Number),
|
|
949
|
+
user: Schema.optionalKey(Schema.String)
|
|
950
|
+
})
|
|
951
|
+
|
|
952
|
+
/**
|
|
953
|
+
* Request payload sent to the OpenAI embeddings endpoint.
|
|
954
|
+
*
|
|
955
|
+
* @category models
|
|
956
|
+
* @since 4.0.0
|
|
957
|
+
*/
|
|
958
|
+
export type CreateEmbeddingRequest = typeof CreateEmbeddingRequest.Type
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
* Schema for a successful response payload returned by the OpenAI embeddings endpoint.
|
|
962
|
+
*
|
|
963
|
+
* @category schemas
|
|
964
|
+
* @since 4.0.0
|
|
965
|
+
*/
|
|
966
|
+
export const CreateEmbeddingResponse = Schema.Struct({
|
|
967
|
+
data: Schema.Array(Embedding),
|
|
968
|
+
model: Schema.String,
|
|
969
|
+
object: Schema.optionalKey(Schema.Literal("list")),
|
|
970
|
+
usage: Schema.optionalKey(
|
|
971
|
+
Schema.Struct({
|
|
972
|
+
prompt_tokens: Schema.Number,
|
|
973
|
+
total_tokens: Schema.Number
|
|
974
|
+
})
|
|
975
|
+
)
|
|
976
|
+
})
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* Successful response payload returned by the OpenAI embeddings endpoint.
|
|
980
|
+
*
|
|
981
|
+
* @category models
|
|
982
|
+
* @since 4.0.0
|
|
983
|
+
*/
|
|
984
|
+
export type CreateEmbeddingResponse = typeof CreateEmbeddingResponse.Type
|