@effect/ai-openai 0.1.0

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.
Files changed (51) hide show
  1. package/Generated/package.json +6 -0
  2. package/LICENSE +21 -0
  3. package/OpenAiClient/package.json +6 -0
  4. package/OpenAiCompletions/package.json +6 -0
  5. package/OpenAiConfig/package.json +6 -0
  6. package/OpenAiTokenizer/package.json +6 -0
  7. package/README.md +1 -0
  8. package/dist/cjs/Generated.js +2702 -0
  9. package/dist/cjs/Generated.js.map +1 -0
  10. package/dist/cjs/OpenAiClient.js +153 -0
  11. package/dist/cjs/OpenAiClient.js.map +1 -0
  12. package/dist/cjs/OpenAiCompletions.js +208 -0
  13. package/dist/cjs/OpenAiCompletions.js.map +1 -0
  14. package/dist/cjs/OpenAiConfig.js +26 -0
  15. package/dist/cjs/OpenAiConfig.js.map +1 -0
  16. package/dist/cjs/OpenAiTokenizer.js +50 -0
  17. package/dist/cjs/OpenAiTokenizer.js.map +1 -0
  18. package/dist/cjs/index.js +19 -0
  19. package/dist/cjs/index.js.map +1 -0
  20. package/dist/dts/Generated.d.ts +5759 -0
  21. package/dist/dts/Generated.d.ts.map +1 -0
  22. package/dist/dts/OpenAiClient.d.ts +113 -0
  23. package/dist/dts/OpenAiClient.d.ts.map +1 -0
  24. package/dist/dts/OpenAiCompletions.d.ts +19 -0
  25. package/dist/dts/OpenAiCompletions.d.ts.map +1 -0
  26. package/dist/dts/OpenAiConfig.d.ts +55 -0
  27. package/dist/dts/OpenAiConfig.d.ts.map +1 -0
  28. package/dist/dts/OpenAiTokenizer.d.ts +10 -0
  29. package/dist/dts/OpenAiTokenizer.d.ts.map +1 -0
  30. package/dist/dts/index.d.ts +21 -0
  31. package/dist/dts/index.d.ts.map +1 -0
  32. package/dist/esm/Generated.js +2493 -0
  33. package/dist/esm/Generated.js.map +1 -0
  34. package/dist/esm/OpenAiClient.js +139 -0
  35. package/dist/esm/OpenAiClient.js.map +1 -0
  36. package/dist/esm/OpenAiCompletions.js +197 -0
  37. package/dist/esm/OpenAiCompletions.js.map +1 -0
  38. package/dist/esm/OpenAiConfig.js +16 -0
  39. package/dist/esm/OpenAiConfig.js.map +1 -0
  40. package/dist/esm/OpenAiTokenizer.js +40 -0
  41. package/dist/esm/OpenAiTokenizer.js.map +1 -0
  42. package/dist/esm/index.js +21 -0
  43. package/dist/esm/index.js.map +1 -0
  44. package/dist/esm/package.json +4 -0
  45. package/package.json +80 -0
  46. package/src/Generated.ts +3936 -0
  47. package/src/OpenAiClient.ts +291 -0
  48. package/src/OpenAiCompletions.ts +260 -0
  49. package/src/OpenAiConfig.ts +31 -0
  50. package/src/OpenAiTokenizer.ts +59 -0
  51. package/src/index.ts +24 -0
@@ -0,0 +1,3936 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import type * as HttpClient from "@effect/platform/HttpClient"
5
+ import * as HttpClientError from "@effect/platform/HttpClientError"
6
+ import * as HttpClientRequest from "@effect/platform/HttpClientRequest"
7
+ import * as HttpClientResponse from "@effect/platform/HttpClientResponse"
8
+ import type { ParseError } from "@effect/schema/ParseResult"
9
+ import * as S from "@effect/schema/Schema"
10
+ import * as Effect from "effect/Effect"
11
+
12
+ export class ChatCompletionRequestMessageContentPartText extends S.Struct({
13
+ "type": S.Literal("text"),
14
+ "text": S.String
15
+ }) {}
16
+
17
+ export class ChatCompletionRequestSystemMessageContentPart extends ChatCompletionRequestMessageContentPartText {}
18
+
19
+ export class ChatCompletionRequestSystemMessage extends S.Struct({
20
+ "content": S.Union(S.String, S.NonEmptyArray(ChatCompletionRequestSystemMessageContentPart)),
21
+ "role": S.Literal("system"),
22
+ "name": S.optional(S.String)
23
+ }) {}
24
+
25
+ export class ChatCompletionRequestMessageContentPartImage extends S.Struct({
26
+ "type": S.Literal("image_url"),
27
+ "image_url": S.Struct({
28
+ "url": S.String,
29
+ "detail": S.optionalWith(S.Literal("auto", "low", "high"), { default: () => "auto" as const })
30
+ })
31
+ }) {}
32
+
33
+ export class ChatCompletionRequestUserMessageContentPart
34
+ extends S.Union(ChatCompletionRequestMessageContentPartText, ChatCompletionRequestMessageContentPartImage)
35
+ {}
36
+
37
+ export class ChatCompletionRequestUserMessage extends S.Struct({
38
+ "content": S.Union(S.String, S.NonEmptyArray(ChatCompletionRequestUserMessageContentPart)),
39
+ "role": S.Literal("user"),
40
+ "name": S.optional(S.String)
41
+ }) {}
42
+
43
+ export class ChatCompletionRequestMessageContentPartRefusal extends S.Struct({
44
+ "type": S.Literal("refusal"),
45
+ "refusal": S.String
46
+ }) {}
47
+
48
+ export class ChatCompletionRequestAssistantMessageContentPart
49
+ extends S.Union(ChatCompletionRequestMessageContentPartText, ChatCompletionRequestMessageContentPartRefusal)
50
+ {}
51
+
52
+ export class ChatCompletionMessageToolCall extends S.Struct({
53
+ "id": S.String,
54
+ "type": S.Literal("function"),
55
+ "function": S.Struct({
56
+ "name": S.String,
57
+ "arguments": S.String
58
+ })
59
+ }) {}
60
+
61
+ export class ChatCompletionMessageToolCalls extends S.Array(ChatCompletionMessageToolCall) {}
62
+
63
+ export class ChatCompletionRequestAssistantMessage extends S.Struct({
64
+ "content": S.optionalWith(S.Union(S.String, S.NonEmptyArray(ChatCompletionRequestAssistantMessageContentPart)), {
65
+ nullable: true
66
+ }),
67
+ "refusal": S.optionalWith(S.String, { nullable: true }),
68
+ "role": S.Literal("assistant"),
69
+ "name": S.optional(S.String),
70
+ "tool_calls": S.optional(ChatCompletionMessageToolCalls),
71
+ "function_call": S.optionalWith(
72
+ S.Struct({
73
+ "arguments": S.String,
74
+ "name": S.String
75
+ }),
76
+ { nullable: true }
77
+ )
78
+ }) {}
79
+
80
+ export class ChatCompletionRequestToolMessageContentPart extends ChatCompletionRequestMessageContentPartText {}
81
+
82
+ export class ChatCompletionRequestToolMessage extends S.Struct({
83
+ "role": S.Literal("tool"),
84
+ "content": S.Union(S.String, S.NonEmptyArray(ChatCompletionRequestToolMessageContentPart)),
85
+ "tool_call_id": S.String
86
+ }) {}
87
+
88
+ export class ChatCompletionRequestFunctionMessage extends S.Struct({
89
+ "role": S.Literal("function"),
90
+ "content": S.NullOr(S.String),
91
+ "name": S.String
92
+ }) {}
93
+
94
+ export class ChatCompletionRequestMessage extends S.Union(
95
+ ChatCompletionRequestSystemMessage,
96
+ ChatCompletionRequestUserMessage,
97
+ ChatCompletionRequestAssistantMessage,
98
+ ChatCompletionRequestToolMessage,
99
+ ChatCompletionRequestFunctionMessage
100
+ ) {}
101
+
102
+ export class ResponseFormatText extends S.Struct({
103
+ "type": S.Literal("text")
104
+ }) {}
105
+
106
+ export class ResponseFormatJsonObject extends S.Struct({
107
+ "type": S.Literal("json_object")
108
+ }) {}
109
+
110
+ export class ResponseFormatJsonSchemaSchema extends S.Record({ key: S.String, value: S.Unknown }) {}
111
+
112
+ export class ResponseFormatJsonSchema extends S.Struct({
113
+ "type": S.Literal("json_schema"),
114
+ "json_schema": S.Struct({
115
+ "description": S.optional(S.String),
116
+ "name": S.String,
117
+ "schema": S.optional(ResponseFormatJsonSchemaSchema),
118
+ "strict": S.optionalWith(S.Boolean, { nullable: true, default: () => false as const })
119
+ })
120
+ }) {}
121
+
122
+ export class ChatCompletionStreamOptions extends S.Struct({
123
+ "include_usage": S.optional(S.Boolean)
124
+ }) {}
125
+
126
+ export class FunctionParameters extends S.Record({ key: S.String, value: S.Unknown }) {}
127
+
128
+ export class FunctionObject extends S.Struct({
129
+ "description": S.optional(S.String),
130
+ "name": S.String,
131
+ "parameters": S.optional(FunctionParameters),
132
+ "strict": S.optionalWith(S.Boolean, { nullable: true, default: () => false as const })
133
+ }) {}
134
+
135
+ export class ChatCompletionTool extends S.Struct({
136
+ "type": S.Literal("function"),
137
+ "function": FunctionObject
138
+ }) {}
139
+
140
+ export class ChatCompletionNamedToolChoice extends S.Struct({
141
+ "type": S.Literal("function"),
142
+ "function": S.Struct({
143
+ "name": S.String
144
+ })
145
+ }) {}
146
+
147
+ export class ChatCompletionToolChoiceOption
148
+ extends S.Union(S.Literal("none", "auto", "required"), ChatCompletionNamedToolChoice)
149
+ {}
150
+
151
+ export class ParallelToolCalls extends S.Boolean {}
152
+
153
+ export class ChatCompletionFunctionCallOption extends S.Struct({
154
+ "name": S.String
155
+ }) {}
156
+
157
+ export class ChatCompletionFunctions extends S.Struct({
158
+ "description": S.optional(S.String),
159
+ "name": S.String,
160
+ "parameters": S.optional(FunctionParameters)
161
+ }) {}
162
+
163
+ export class CreateChatCompletionRequest extends S.Class<CreateChatCompletionRequest>("CreateChatCompletionRequest")({
164
+ "messages": S.NonEmptyArray(ChatCompletionRequestMessage),
165
+ "model": S.Union(
166
+ S.String,
167
+ S.Literal(
168
+ "o1-preview",
169
+ "o1-preview-2024-09-12",
170
+ "o1-mini",
171
+ "o1-mini-2024-09-12",
172
+ "gpt-4o",
173
+ "gpt-4o-2024-08-06",
174
+ "gpt-4o-2024-05-13",
175
+ "gpt-4o-2024-08-06",
176
+ "chatgpt-4o-latest",
177
+ "gpt-4o-mini",
178
+ "gpt-4o-mini-2024-07-18",
179
+ "gpt-4-turbo",
180
+ "gpt-4-turbo-2024-04-09",
181
+ "gpt-4-0125-preview",
182
+ "gpt-4-turbo-preview",
183
+ "gpt-4-1106-preview",
184
+ "gpt-4-vision-preview",
185
+ "gpt-4",
186
+ "gpt-4-0314",
187
+ "gpt-4-0613",
188
+ "gpt-4-32k",
189
+ "gpt-4-32k-0314",
190
+ "gpt-4-32k-0613",
191
+ "gpt-3.5-turbo",
192
+ "gpt-3.5-turbo-16k",
193
+ "gpt-3.5-turbo-0301",
194
+ "gpt-3.5-turbo-0613",
195
+ "gpt-3.5-turbo-1106",
196
+ "gpt-3.5-turbo-0125",
197
+ "gpt-3.5-turbo-16k-0613"
198
+ )
199
+ ),
200
+ "frequency_penalty": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(-2), S.lessThanOrEqualTo(2)), {
201
+ nullable: true,
202
+ default: () => 0 as const
203
+ }),
204
+ "logit_bias": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true }),
205
+ "logprobs": S.optionalWith(S.Boolean, { nullable: true, default: () => false as const }),
206
+ "top_logprobs": S.optionalWith(S.Int.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(20)), { nullable: true }),
207
+ "max_tokens": S.optionalWith(S.Int, { nullable: true }),
208
+ "max_completion_tokens": S.optionalWith(S.Int, { nullable: true }),
209
+ "n": S.optionalWith(S.Int.pipe(S.greaterThanOrEqualTo(1), S.lessThanOrEqualTo(128)), {
210
+ nullable: true,
211
+ default: () => 1 as const
212
+ }),
213
+ "presence_penalty": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(-2), S.lessThanOrEqualTo(2)), {
214
+ nullable: true,
215
+ default: () => 0 as const
216
+ }),
217
+ "response_format": S.optional(S.Union(ResponseFormatText, ResponseFormatJsonObject, ResponseFormatJsonSchema)),
218
+ "seed": S.optionalWith(
219
+ S.Int.pipe(S.greaterThanOrEqualTo(-9223372036854776000), S.lessThanOrEqualTo(9223372036854776000)),
220
+ { nullable: true }
221
+ ),
222
+ "service_tier": S.optionalWith(S.Literal("auto", "default"), { nullable: true }),
223
+ "stop": S.optional(S.Union(S.String, S.Array(S.String).pipe(S.minItems(1), S.maxItems(4)))),
224
+ "stream": S.optionalWith(S.Boolean, { nullable: true, default: () => false as const }),
225
+ "stream_options": S.optionalWith(ChatCompletionStreamOptions, { nullable: true }),
226
+ "temperature": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(2)), {
227
+ nullable: true,
228
+ default: () => 1 as const
229
+ }),
230
+ "top_p": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(1)), {
231
+ nullable: true,
232
+ default: () => 1 as const
233
+ }),
234
+ "tools": S.optional(S.Array(ChatCompletionTool)),
235
+ "tool_choice": S.optional(ChatCompletionToolChoiceOption),
236
+ "parallel_tool_calls": S.optionalWith(ParallelToolCalls, { default: () => true as const }),
237
+ "user": S.optional(S.String),
238
+ "function_call": S.optional(S.Union(S.Literal("none", "auto"), ChatCompletionFunctionCallOption)),
239
+ "functions": S.optional(S.Array(ChatCompletionFunctions).pipe(S.minItems(1), S.maxItems(128)))
240
+ }) {}
241
+
242
+ export class ChatCompletionResponseMessage extends S.Struct({
243
+ "content": S.NullOr(S.String),
244
+ "refusal": S.NullOr(S.String),
245
+ "tool_calls": S.optional(ChatCompletionMessageToolCalls),
246
+ "role": S.Literal("assistant"),
247
+ "function_call": S.optional(S.Struct({
248
+ "arguments": S.String,
249
+ "name": S.String
250
+ }))
251
+ }) {}
252
+
253
+ export class ChatCompletionTokenLogprob extends S.Struct({
254
+ "token": S.String,
255
+ "logprob": S.Number,
256
+ "bytes": S.NullOr(S.Array(S.Int)),
257
+ "top_logprobs": S.Array(S.Struct({
258
+ "token": S.String,
259
+ "logprob": S.Number,
260
+ "bytes": S.NullOr(S.Array(S.Int))
261
+ }))
262
+ }) {}
263
+
264
+ export class CompletionUsage extends S.Struct({
265
+ "completion_tokens": S.Int,
266
+ "prompt_tokens": S.Int,
267
+ "total_tokens": S.Int,
268
+ "completion_tokens_details": S.optional(S.Struct({
269
+ "reasoning_tokens": S.optional(S.Int)
270
+ }))
271
+ }) {}
272
+
273
+ export class CreateChatCompletionResponse
274
+ extends S.Class<CreateChatCompletionResponse>("CreateChatCompletionResponse")({
275
+ "id": S.String,
276
+ "choices": S.Array(S.Struct({
277
+ "finish_reason": S.Literal("stop", "length", "tool_calls", "content_filter", "function_call"),
278
+ "index": S.Int,
279
+ "message": ChatCompletionResponseMessage,
280
+ "logprobs": S.NullOr(S.Struct({
281
+ "content": S.NullOr(S.Array(ChatCompletionTokenLogprob)),
282
+ "refusal": S.NullOr(S.Array(ChatCompletionTokenLogprob))
283
+ }))
284
+ })),
285
+ "created": S.Int,
286
+ "model": S.String,
287
+ "service_tier": S.optionalWith(S.Literal("scale", "default"), { nullable: true }),
288
+ "system_fingerprint": S.optional(S.String),
289
+ "object": S.Literal("chat.completion"),
290
+ "usage": S.optional(CompletionUsage)
291
+ })
292
+ {}
293
+
294
+ export class CreateCompletionRequest extends S.Class<CreateCompletionRequest>("CreateCompletionRequest")({
295
+ "model": S.Union(S.String, S.Literal("gpt-3.5-turbo-instruct", "davinci-002", "babbage-002")),
296
+ "prompt": S.NullOr(
297
+ S.Union(S.String, S.Array(S.String), S.NonEmptyArray(S.Int), S.NonEmptyArray(S.NonEmptyArray(S.Int)))
298
+ ).pipe(S.propertySignature, S.withConstructorDefault(() => "<|endoftext|>" as const)),
299
+ "best_of": S.optionalWith(S.Int.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(20)), {
300
+ nullable: true,
301
+ default: () => 1 as const
302
+ }),
303
+ "echo": S.optionalWith(S.Boolean, { nullable: true, default: () => false as const }),
304
+ "frequency_penalty": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(-2), S.lessThanOrEqualTo(2)), {
305
+ nullable: true,
306
+ default: () => 0 as const
307
+ }),
308
+ "logit_bias": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true }),
309
+ "logprobs": S.optionalWith(S.Int.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(5)), { nullable: true }),
310
+ "max_tokens": S.optionalWith(S.Int.pipe(S.greaterThanOrEqualTo(0)), { nullable: true, default: () => 16 as const }),
311
+ "n": S.optionalWith(S.Int.pipe(S.greaterThanOrEqualTo(1), S.lessThanOrEqualTo(128)), {
312
+ nullable: true,
313
+ default: () => 1 as const
314
+ }),
315
+ "presence_penalty": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(-2), S.lessThanOrEqualTo(2)), {
316
+ nullable: true,
317
+ default: () => 0 as const
318
+ }),
319
+ "seed": S.optionalWith(
320
+ S.Int.pipe(S.greaterThanOrEqualTo(-9223372036854776000), S.lessThanOrEqualTo(9223372036854776000)),
321
+ { nullable: true }
322
+ ),
323
+ "stop": S.optionalWith(S.Union(S.String, S.Array(S.String).pipe(S.minItems(1), S.maxItems(4))), { nullable: true }),
324
+ "stream": S.optionalWith(S.Boolean, { nullable: true, default: () => false as const }),
325
+ "stream_options": S.optionalWith(ChatCompletionStreamOptions, { nullable: true }),
326
+ "suffix": S.optionalWith(S.String, { nullable: true }),
327
+ "temperature": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(2)), {
328
+ nullable: true,
329
+ default: () => 1 as const
330
+ }),
331
+ "top_p": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(1)), {
332
+ nullable: true,
333
+ default: () => 1 as const
334
+ }),
335
+ "user": S.optional(S.String)
336
+ }) {}
337
+
338
+ export class CreateCompletionResponse extends S.Class<CreateCompletionResponse>("CreateCompletionResponse")({
339
+ "id": S.String,
340
+ "choices": S.Array(S.Struct({
341
+ "finish_reason": S.Literal("stop", "length", "content_filter"),
342
+ "index": S.Int,
343
+ "logprobs": S.NullOr(S.Struct({
344
+ "text_offset": S.optional(S.Array(S.Int)),
345
+ "token_logprobs": S.optional(S.Array(S.Number)),
346
+ "tokens": S.optional(S.Array(S.String)),
347
+ "top_logprobs": S.optional(S.Array(S.Record({ key: S.String, value: S.Unknown })))
348
+ })),
349
+ "text": S.String
350
+ })),
351
+ "created": S.Int,
352
+ "model": S.String,
353
+ "system_fingerprint": S.optional(S.String),
354
+ "object": S.Literal("text_completion"),
355
+ "usage": S.optional(CompletionUsage)
356
+ }) {}
357
+
358
+ export class CreateImageRequest extends S.Class<CreateImageRequest>("CreateImageRequest")({
359
+ "prompt": S.String,
360
+ "model": S.optionalWith(S.Union(S.String, S.Literal("dall-e-2", "dall-e-3")), {
361
+ nullable: true,
362
+ default: () => "dall-e-2" as const
363
+ }),
364
+ "n": S.optionalWith(S.Int.pipe(S.greaterThanOrEqualTo(1), S.lessThanOrEqualTo(10)), {
365
+ nullable: true,
366
+ default: () => 1 as const
367
+ }),
368
+ "quality": S.optionalWith(S.Literal("standard", "hd"), { default: () => "standard" as const }),
369
+ "response_format": S.optionalWith(S.Literal("url", "b64_json"), { nullable: true, default: () => "url" as const }),
370
+ "size": S.optionalWith(S.Literal("256x256", "512x512", "1024x1024", "1792x1024", "1024x1792"), {
371
+ nullable: true,
372
+ default: () => "1024x1024" as const
373
+ }),
374
+ "style": S.optionalWith(S.Literal("vivid", "natural"), { nullable: true, default: () => "vivid" as const }),
375
+ "user": S.optional(S.String)
376
+ }) {}
377
+
378
+ export class Image extends S.Struct({
379
+ "b64_json": S.optional(S.String),
380
+ "url": S.optional(S.String),
381
+ "revised_prompt": S.optional(S.String)
382
+ }) {}
383
+
384
+ export class ImagesResponse extends S.Class<ImagesResponse>("ImagesResponse")({
385
+ "created": S.Int,
386
+ "data": S.Array(Image)
387
+ }) {}
388
+
389
+ export class CreateEmbeddingRequest extends S.Class<CreateEmbeddingRequest>("CreateEmbeddingRequest")({
390
+ "input": S.Union(
391
+ S.String,
392
+ S.Array(S.String).pipe(S.minItems(1), S.maxItems(2048)),
393
+ S.Array(S.Int).pipe(S.minItems(1), S.maxItems(2048)),
394
+ S.Array(S.NonEmptyArray(S.Int)).pipe(S.minItems(1), S.maxItems(2048))
395
+ ),
396
+ "model": S.Union(S.String, S.Literal("text-embedding-ada-002", "text-embedding-3-small", "text-embedding-3-large")),
397
+ "encoding_format": S.optionalWith(S.Literal("float", "base64"), { default: () => "float" as const }),
398
+ "dimensions": S.optional(S.Int.pipe(S.greaterThanOrEqualTo(1))),
399
+ "user": S.optional(S.String)
400
+ }) {}
401
+
402
+ export class Embedding extends S.Struct({
403
+ "index": S.Int,
404
+ "embedding": S.Array(S.Number),
405
+ "object": S.Literal("embedding")
406
+ }) {}
407
+
408
+ export class CreateEmbeddingResponse extends S.Class<CreateEmbeddingResponse>("CreateEmbeddingResponse")({
409
+ "data": S.Array(Embedding),
410
+ "model": S.String,
411
+ "object": S.Literal("list"),
412
+ "usage": S.Struct({
413
+ "prompt_tokens": S.Int,
414
+ "total_tokens": S.Int
415
+ })
416
+ }) {}
417
+
418
+ export class CreateSpeechRequest extends S.Class<CreateSpeechRequest>("CreateSpeechRequest")({
419
+ "model": S.Union(S.String, S.Literal("tts-1", "tts-1-hd")),
420
+ "input": S.String.pipe(S.maxLength(4096)),
421
+ "voice": S.Literal("alloy", "echo", "fable", "onyx", "nova", "shimmer"),
422
+ "response_format": S.optionalWith(S.Literal("mp3", "opus", "aac", "flac", "wav", "pcm"), {
423
+ default: () => "mp3" as const
424
+ }),
425
+ "speed": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(0.25), S.lessThanOrEqualTo(4)), {
426
+ default: () => 1 as const
427
+ })
428
+ }) {}
429
+
430
+ export class CreateTranscriptionResponseJson extends S.Struct({
431
+ "text": S.String
432
+ }) {}
433
+
434
+ export class TranscriptionWord extends S.Struct({
435
+ "word": S.String,
436
+ "start": S.Number,
437
+ "end": S.Number
438
+ }) {}
439
+
440
+ export class TranscriptionSegment extends S.Struct({
441
+ "id": S.Int,
442
+ "seek": S.Int,
443
+ "start": S.Number,
444
+ "end": S.Number,
445
+ "text": S.String,
446
+ "tokens": S.Array(S.Int),
447
+ "temperature": S.Number,
448
+ "avg_logprob": S.Number,
449
+ "compression_ratio": S.Number,
450
+ "no_speech_prob": S.Number
451
+ }) {}
452
+
453
+ export class CreateTranscriptionResponseVerboseJson extends S.Struct({
454
+ "language": S.String,
455
+ "duration": S.String,
456
+ "text": S.String,
457
+ "words": S.optional(S.Array(TranscriptionWord)),
458
+ "segments": S.optional(S.Array(TranscriptionSegment))
459
+ }) {}
460
+
461
+ export class CreateTranscription200
462
+ extends S.Union(CreateTranscriptionResponseJson, CreateTranscriptionResponseVerboseJson)
463
+ {}
464
+
465
+ export class CreateTranslationResponseJson extends S.Struct({
466
+ "text": S.String
467
+ }) {}
468
+
469
+ export class CreateTranslationResponseVerboseJson extends S.Struct({
470
+ "language": S.String,
471
+ "duration": S.String,
472
+ "text": S.String,
473
+ "segments": S.optional(S.Array(TranscriptionSegment))
474
+ }) {}
475
+
476
+ export class CreateTranslation200
477
+ extends S.Union(CreateTranslationResponseJson, CreateTranslationResponseVerboseJson)
478
+ {}
479
+
480
+ export class ListFilesParams extends S.Struct({
481
+ "purpose": S.optional(S.String)
482
+ }) {}
483
+
484
+ export class OpenAIFile extends S.Struct({
485
+ "id": S.String,
486
+ "bytes": S.Int,
487
+ "created_at": S.Int,
488
+ "filename": S.String,
489
+ "object": S.Literal("file"),
490
+ "purpose": S.Literal(
491
+ "assistants",
492
+ "assistants_output",
493
+ "batch",
494
+ "batch_output",
495
+ "fine-tune",
496
+ "fine-tune-results",
497
+ "vision"
498
+ ),
499
+ "status": S.Literal("uploaded", "processed", "error"),
500
+ "status_details": S.optional(S.String)
501
+ }) {}
502
+
503
+ export class ListFilesResponse extends S.Class<ListFilesResponse>("ListFilesResponse")({
504
+ "data": S.Array(OpenAIFile),
505
+ "object": S.Literal("list")
506
+ }) {}
507
+
508
+ export class DeleteFileResponse extends S.Class<DeleteFileResponse>("DeleteFileResponse")({
509
+ "id": S.String,
510
+ "object": S.Literal("file"),
511
+ "deleted": S.Boolean
512
+ }) {}
513
+
514
+ export class DownloadFile200 extends S.String {}
515
+
516
+ export class CreateUploadRequest extends S.Class<CreateUploadRequest>("CreateUploadRequest")({
517
+ "filename": S.String,
518
+ "purpose": S.Literal("assistants", "batch", "fine-tune", "vision"),
519
+ "bytes": S.Int,
520
+ "mime_type": S.String
521
+ }) {}
522
+
523
+ export class Upload extends S.Class<Upload>("Upload")({
524
+ "id": S.String,
525
+ "created_at": S.Int,
526
+ "filename": S.String,
527
+ "bytes": S.Int,
528
+ "purpose": S.String,
529
+ "status": S.Literal("pending", "completed", "cancelled", "expired"),
530
+ "expires_at": S.Int,
531
+ "object": S.optional(S.Literal("upload")),
532
+ "file": S.optional(OpenAIFile)
533
+ }) {}
534
+
535
+ export class UploadPart extends S.Class<UploadPart>("UploadPart")({
536
+ "id": S.String,
537
+ "created_at": S.Int,
538
+ "upload_id": S.String,
539
+ "object": S.Literal("upload.part")
540
+ }) {}
541
+
542
+ export class CompleteUploadRequest extends S.Class<CompleteUploadRequest>("CompleteUploadRequest")({
543
+ "part_ids": S.Array(S.String),
544
+ "md5": S.optional(S.String)
545
+ }) {}
546
+
547
+ export class ListPaginatedFineTuningJobsParams extends S.Struct({
548
+ "after": S.optional(S.String),
549
+ "limit": S.optionalWith(S.Int, { default: () => 20 as const })
550
+ }) {}
551
+
552
+ export class FineTuningIntegration extends S.Struct({
553
+ "type": S.Literal("wandb"),
554
+ "wandb": S.Struct({
555
+ "project": S.String,
556
+ "name": S.optionalWith(S.String, { nullable: true }),
557
+ "entity": S.optionalWith(S.String, { nullable: true }),
558
+ "tags": S.optional(S.Array(S.String))
559
+ })
560
+ }) {}
561
+
562
+ export class FineTuningJob extends S.Struct({
563
+ "id": S.String,
564
+ "created_at": S.Int,
565
+ "error": S.NullOr(S.Struct({
566
+ "code": S.String,
567
+ "message": S.String,
568
+ "param": S.NullOr(S.String)
569
+ })),
570
+ "fine_tuned_model": S.NullOr(S.String),
571
+ "finished_at": S.NullOr(S.Int),
572
+ "hyperparameters": S.Struct({
573
+ "n_epochs": S.Union(S.Literal("auto"), S.Int.pipe(S.greaterThanOrEqualTo(1), S.lessThanOrEqualTo(50))).pipe(
574
+ S.propertySignature,
575
+ S.withConstructorDefault(() => "auto" as const)
576
+ )
577
+ }),
578
+ "model": S.String,
579
+ "object": S.Literal("fine_tuning.job"),
580
+ "organization_id": S.String,
581
+ "result_files": S.Array(S.String),
582
+ "status": S.Literal("validating_files", "queued", "running", "succeeded", "failed", "cancelled"),
583
+ "trained_tokens": S.NullOr(S.Int),
584
+ "training_file": S.String,
585
+ "validation_file": S.NullOr(S.String),
586
+ "integrations": S.optionalWith(S.Array(FineTuningIntegration).pipe(S.maxItems(5)), { nullable: true }),
587
+ "seed": S.Int,
588
+ "estimated_finish": S.optionalWith(S.Int, { nullable: true })
589
+ }) {}
590
+
591
+ export class ListPaginatedFineTuningJobsResponse
592
+ extends S.Class<ListPaginatedFineTuningJobsResponse>("ListPaginatedFineTuningJobsResponse")({
593
+ "data": S.Array(FineTuningJob),
594
+ "has_more": S.Boolean,
595
+ "object": S.Literal("list")
596
+ })
597
+ {}
598
+
599
+ export class CreateFineTuningJobRequest extends S.Class<CreateFineTuningJobRequest>("CreateFineTuningJobRequest")({
600
+ "model": S.Union(S.String, S.Literal("babbage-002", "davinci-002", "gpt-3.5-turbo", "gpt-4o-mini")),
601
+ "training_file": S.String,
602
+ "hyperparameters": S.optional(S.Struct({
603
+ "batch_size": S.optionalWith(
604
+ S.Union(S.Literal("auto"), S.Int.pipe(S.greaterThanOrEqualTo(1), S.lessThanOrEqualTo(256))),
605
+ { default: () => "auto" as const }
606
+ ),
607
+ "learning_rate_multiplier": S.optionalWith(S.Union(S.Literal("auto"), S.Number.pipe(S.greaterThan(0))), {
608
+ default: () => "auto" as const
609
+ }),
610
+ "n_epochs": S.optionalWith(
611
+ S.Union(S.Literal("auto"), S.Int.pipe(S.greaterThanOrEqualTo(1), S.lessThanOrEqualTo(50))),
612
+ { default: () => "auto" as const }
613
+ )
614
+ })),
615
+ "suffix": S.optionalWith(S.String.pipe(S.minLength(1), S.maxLength(64)), { nullable: true }),
616
+ "validation_file": S.optionalWith(S.String, { nullable: true }),
617
+ "integrations": S.optionalWith(
618
+ S.Array(S.Struct({
619
+ "type": S.Literal("wandb"),
620
+ "wandb": S.Struct({
621
+ "project": S.String,
622
+ "name": S.optionalWith(S.String, { nullable: true }),
623
+ "entity": S.optionalWith(S.String, { nullable: true }),
624
+ "tags": S.optional(S.Array(S.String))
625
+ })
626
+ })),
627
+ { nullable: true }
628
+ ),
629
+ "seed": S.optionalWith(S.Int.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(2147483647)), { nullable: true })
630
+ }) {}
631
+
632
+ export class ListFineTuningEventsParams extends S.Struct({
633
+ "after": S.optional(S.String),
634
+ "limit": S.optionalWith(S.Int, { default: () => 20 as const })
635
+ }) {}
636
+
637
+ export class FineTuningJobEvent extends S.Struct({
638
+ "id": S.String,
639
+ "created_at": S.Int,
640
+ "level": S.Literal("info", "warn", "error"),
641
+ "message": S.String,
642
+ "object": S.Literal("fine_tuning.job.event")
643
+ }) {}
644
+
645
+ export class ListFineTuningJobEventsResponse
646
+ extends S.Class<ListFineTuningJobEventsResponse>("ListFineTuningJobEventsResponse")({
647
+ "data": S.Array(FineTuningJobEvent),
648
+ "object": S.Literal("list")
649
+ })
650
+ {}
651
+
652
+ export class ListFineTuningJobCheckpointsParams extends S.Struct({
653
+ "after": S.optional(S.String),
654
+ "limit": S.optionalWith(S.Int, { default: () => 10 as const })
655
+ }) {}
656
+
657
+ export class FineTuningJobCheckpoint extends S.Struct({
658
+ "id": S.String,
659
+ "created_at": S.Int,
660
+ "fine_tuned_model_checkpoint": S.String,
661
+ "step_number": S.Int,
662
+ "metrics": S.Struct({
663
+ "step": S.optional(S.Number),
664
+ "train_loss": S.optional(S.Number),
665
+ "train_mean_token_accuracy": S.optional(S.Number),
666
+ "valid_loss": S.optional(S.Number),
667
+ "valid_mean_token_accuracy": S.optional(S.Number),
668
+ "full_valid_loss": S.optional(S.Number),
669
+ "full_valid_mean_token_accuracy": S.optional(S.Number)
670
+ }),
671
+ "fine_tuning_job_id": S.String,
672
+ "object": S.Literal("fine_tuning.job.checkpoint")
673
+ }) {}
674
+
675
+ export class ListFineTuningJobCheckpointsResponse
676
+ extends S.Class<ListFineTuningJobCheckpointsResponse>("ListFineTuningJobCheckpointsResponse")({
677
+ "data": S.Array(FineTuningJobCheckpoint),
678
+ "object": S.Literal("list"),
679
+ "first_id": S.optionalWith(S.String, { nullable: true }),
680
+ "last_id": S.optionalWith(S.String, { nullable: true }),
681
+ "has_more": S.Boolean
682
+ })
683
+ {}
684
+
685
+ export class Model extends S.Struct({
686
+ "id": S.String,
687
+ "created": S.Int,
688
+ "object": S.Literal("model"),
689
+ "owned_by": S.String
690
+ }) {}
691
+
692
+ export class ListModelsResponse extends S.Class<ListModelsResponse>("ListModelsResponse")({
693
+ "object": S.Literal("list"),
694
+ "data": S.Array(Model)
695
+ }) {}
696
+
697
+ export class DeleteModelResponse extends S.Class<DeleteModelResponse>("DeleteModelResponse")({
698
+ "id": S.String,
699
+ "deleted": S.Boolean,
700
+ "object": S.String
701
+ }) {}
702
+
703
+ export class CreateModerationRequest extends S.Class<CreateModerationRequest>("CreateModerationRequest")({
704
+ "input": S.Union(
705
+ S.String,
706
+ S.Array(S.String),
707
+ S.Array(S.Union(
708
+ S.Struct({
709
+ "type": S.Literal("image_url"),
710
+ "image_url": S.Struct({
711
+ "url": S.String
712
+ })
713
+ }),
714
+ S.Struct({
715
+ "type": S.Literal("text"),
716
+ "text": S.String
717
+ })
718
+ ))
719
+ ),
720
+ "model": S.optionalWith(
721
+ S.Union(
722
+ S.String,
723
+ S.Literal(
724
+ "omni-moderation-latest",
725
+ "omni-moderation-2024-09-26",
726
+ "text-moderation-latest",
727
+ "text-moderation-stable"
728
+ )
729
+ ),
730
+ { default: () => "omni-moderation-latest" as const }
731
+ )
732
+ }) {}
733
+
734
+ export class CreateModerationResponse extends S.Class<CreateModerationResponse>("CreateModerationResponse")({
735
+ "id": S.String,
736
+ "model": S.String,
737
+ "results": S.Array(S.Struct({
738
+ "flagged": S.Boolean,
739
+ "categories": S.Struct({
740
+ "hate": S.Boolean,
741
+ "hate/threatening": S.Boolean,
742
+ "harassment": S.Boolean,
743
+ "harassment/threatening": S.Boolean,
744
+ "illicit": S.Boolean,
745
+ "illicit/violent": S.Boolean,
746
+ "self-harm": S.Boolean,
747
+ "self-harm/intent": S.Boolean,
748
+ "self-harm/instructions": S.Boolean,
749
+ "sexual": S.Boolean,
750
+ "sexual/minors": S.Boolean,
751
+ "violence": S.Boolean,
752
+ "violence/graphic": S.Boolean
753
+ }),
754
+ "category_scores": S.Struct({
755
+ "hate": S.Number,
756
+ "hate/threatening": S.Number,
757
+ "harassment": S.Number,
758
+ "harassment/threatening": S.Number,
759
+ "illicit": S.Number,
760
+ "illicit/violent": S.Number,
761
+ "self-harm": S.Number,
762
+ "self-harm/intent": S.Number,
763
+ "self-harm/instructions": S.Number,
764
+ "sexual": S.Number,
765
+ "sexual/minors": S.Number,
766
+ "violence": S.Number,
767
+ "violence/graphic": S.Number
768
+ }),
769
+ "category_applied_input_types": S.Struct({
770
+ "hate": S.Array(S.Literal("text")),
771
+ "hate/threatening": S.Array(S.Literal("text")),
772
+ "harassment": S.Array(S.Literal("text")),
773
+ "harassment/threatening": S.Array(S.Literal("text")),
774
+ "illicit": S.Array(S.Literal("text")),
775
+ "illicit/violent": S.Array(S.Literal("text")),
776
+ "self-harm": S.Array(S.Literal("text", "image")),
777
+ "self-harm/intent": S.Array(S.Literal("text", "image")),
778
+ "self-harm/instructions": S.Array(S.Literal("text", "image")),
779
+ "sexual": S.Array(S.Literal("text", "image")),
780
+ "sexual/minors": S.Array(S.Literal("text")),
781
+ "violence": S.Array(S.Literal("text", "image")),
782
+ "violence/graphic": S.Array(S.Literal("text", "image"))
783
+ })
784
+ }))
785
+ }) {}
786
+
787
+ export class ListAssistantsParams extends S.Struct({
788
+ "limit": S.optionalWith(S.Int, { default: () => 20 as const }),
789
+ "order": S.optionalWith(S.Literal("asc", "desc"), { default: () => "desc" as const }),
790
+ "after": S.optional(S.String),
791
+ "before": S.optional(S.String)
792
+ }) {}
793
+
794
+ export class AssistantToolsCode extends S.Struct({
795
+ "type": S.Literal("code_interpreter")
796
+ }) {}
797
+
798
+ export class FileSearchRankingOptions extends S.Struct({
799
+ "ranker": S.optional(S.Literal("auto", "default_2024_08_21")),
800
+ "score_threshold": S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(1))
801
+ }) {}
802
+
803
+ export class AssistantToolsFileSearch extends S.Struct({
804
+ "type": S.Literal("file_search"),
805
+ "file_search": S.optional(S.Struct({
806
+ "max_num_results": S.optional(S.Int.pipe(S.greaterThanOrEqualTo(1), S.lessThanOrEqualTo(50))),
807
+ "ranking_options": S.optional(FileSearchRankingOptions)
808
+ }))
809
+ }) {}
810
+
811
+ export class AssistantToolsFunction extends S.Struct({
812
+ "type": S.Literal("function"),
813
+ "function": FunctionObject
814
+ }) {}
815
+
816
+ export class AssistantsApiResponseFormatOption
817
+ extends S.Union(S.Literal("auto"), ResponseFormatText, ResponseFormatJsonObject, ResponseFormatJsonSchema)
818
+ {}
819
+
820
+ export class AssistantObject extends S.Struct({
821
+ "id": S.String,
822
+ "object": S.Literal("assistant"),
823
+ "created_at": S.Int,
824
+ "name": S.NullOr(S.String.pipe(S.maxLength(256))),
825
+ "description": S.NullOr(S.String.pipe(S.maxLength(512))),
826
+ "model": S.String,
827
+ "instructions": S.NullOr(S.String.pipe(S.maxLength(256000))),
828
+ "tools": S.Array(S.Union(AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction)).pipe(S.maxItems(128))
829
+ .pipe(S.propertySignature, S.withConstructorDefault(() => [] as const)),
830
+ "tool_resources": S.optionalWith(
831
+ S.Struct({
832
+ "code_interpreter": S.optional(S.Struct({
833
+ "file_ids": S.optionalWith(S.Array(S.String).pipe(S.maxItems(20)), { default: () => [] as const })
834
+ })),
835
+ "file_search": S.optional(S.Struct({
836
+ "vector_store_ids": S.optional(S.Array(S.String).pipe(S.maxItems(1)))
837
+ }))
838
+ }),
839
+ { nullable: true }
840
+ ),
841
+ "metadata": S.NullOr(S.Record({ key: S.String, value: S.Unknown })),
842
+ "temperature": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(2)), {
843
+ nullable: true,
844
+ default: () => 1 as const
845
+ }),
846
+ "top_p": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(1)), {
847
+ nullable: true,
848
+ default: () => 1 as const
849
+ }),
850
+ "response_format": S.optional(AssistantsApiResponseFormatOption)
851
+ }) {}
852
+
853
+ export class ListAssistantsResponse extends S.Class<ListAssistantsResponse>("ListAssistantsResponse")({
854
+ "object": S.String,
855
+ "data": S.Array(AssistantObject),
856
+ "first_id": S.String,
857
+ "last_id": S.String,
858
+ "has_more": S.Boolean
859
+ }) {}
860
+
861
+ export class CreateAssistantRequest extends S.Class<CreateAssistantRequest>("CreateAssistantRequest")({
862
+ "model": S.Union(
863
+ S.String,
864
+ S.Literal(
865
+ "gpt-4o",
866
+ "gpt-4o-2024-08-06",
867
+ "gpt-4o-2024-05-13",
868
+ "gpt-4o-2024-08-06",
869
+ "gpt-4o-mini",
870
+ "gpt-4o-mini-2024-07-18",
871
+ "gpt-4-turbo",
872
+ "gpt-4-turbo-2024-04-09",
873
+ "gpt-4-0125-preview",
874
+ "gpt-4-turbo-preview",
875
+ "gpt-4-1106-preview",
876
+ "gpt-4-vision-preview",
877
+ "gpt-4",
878
+ "gpt-4-0314",
879
+ "gpt-4-0613",
880
+ "gpt-4-32k",
881
+ "gpt-4-32k-0314",
882
+ "gpt-4-32k-0613",
883
+ "gpt-3.5-turbo",
884
+ "gpt-3.5-turbo-16k",
885
+ "gpt-3.5-turbo-0613",
886
+ "gpt-3.5-turbo-1106",
887
+ "gpt-3.5-turbo-0125",
888
+ "gpt-3.5-turbo-16k-0613"
889
+ )
890
+ ),
891
+ "name": S.optionalWith(S.String.pipe(S.maxLength(256)), { nullable: true }),
892
+ "description": S.optionalWith(S.String.pipe(S.maxLength(512)), { nullable: true }),
893
+ "instructions": S.optionalWith(S.String.pipe(S.maxLength(256000)), { nullable: true }),
894
+ "tools": S.optionalWith(
895
+ S.Array(S.Union(AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction)).pipe(S.maxItems(128)),
896
+ { default: () => [] as const }
897
+ ),
898
+ "tool_resources": S.optionalWith(
899
+ S.Struct({
900
+ "code_interpreter": S.optional(S.Struct({
901
+ "file_ids": S.optionalWith(S.Array(S.String).pipe(S.maxItems(20)), { default: () => [] as const })
902
+ })),
903
+ "file_search": S.optional(S.Struct({
904
+ "vector_store_ids": S.optional(S.Array(S.String).pipe(S.maxItems(1))),
905
+ "vector_stores": S.optional(
906
+ S.Array(S.Struct({
907
+ "file_ids": S.optional(S.Array(S.String).pipe(S.maxItems(10000))),
908
+ "chunking_strategy": S.optional(S.Record({ key: S.String, value: S.Unknown })),
909
+ "metadata": S.optional(S.Record({ key: S.String, value: S.Unknown }))
910
+ })).pipe(S.maxItems(1))
911
+ )
912
+ }))
913
+ }),
914
+ { nullable: true }
915
+ ),
916
+ "metadata": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true }),
917
+ "temperature": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(2)), {
918
+ nullable: true,
919
+ default: () => 1 as const
920
+ }),
921
+ "top_p": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(1)), {
922
+ nullable: true,
923
+ default: () => 1 as const
924
+ }),
925
+ "response_format": S.optional(AssistantsApiResponseFormatOption)
926
+ }) {}
927
+
928
+ export class ModifyAssistantRequest extends S.Class<ModifyAssistantRequest>("ModifyAssistantRequest")({
929
+ "model": S.optional(S.String),
930
+ "name": S.optionalWith(S.String.pipe(S.maxLength(256)), { nullable: true }),
931
+ "description": S.optionalWith(S.String.pipe(S.maxLength(512)), { nullable: true }),
932
+ "instructions": S.optionalWith(S.String.pipe(S.maxLength(256000)), { nullable: true }),
933
+ "tools": S.optionalWith(
934
+ S.Array(S.Union(AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction)).pipe(S.maxItems(128)),
935
+ { default: () => [] as const }
936
+ ),
937
+ "tool_resources": S.optionalWith(
938
+ S.Struct({
939
+ "code_interpreter": S.optional(S.Struct({
940
+ "file_ids": S.optionalWith(S.Array(S.String).pipe(S.maxItems(20)), { default: () => [] as const })
941
+ })),
942
+ "file_search": S.optional(S.Struct({
943
+ "vector_store_ids": S.optional(S.Array(S.String).pipe(S.maxItems(1)))
944
+ }))
945
+ }),
946
+ { nullable: true }
947
+ ),
948
+ "metadata": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true }),
949
+ "temperature": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(2)), {
950
+ nullable: true,
951
+ default: () => 1 as const
952
+ }),
953
+ "top_p": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(1)), {
954
+ nullable: true,
955
+ default: () => 1 as const
956
+ }),
957
+ "response_format": S.optional(AssistantsApiResponseFormatOption)
958
+ }) {}
959
+
960
+ export class DeleteAssistantResponse extends S.Class<DeleteAssistantResponse>("DeleteAssistantResponse")({
961
+ "id": S.String,
962
+ "deleted": S.Boolean,
963
+ "object": S.Literal("assistant.deleted")
964
+ }) {}
965
+
966
+ export class MessageContentImageFileObject extends S.Struct({
967
+ "type": S.Literal("image_file"),
968
+ "image_file": S.Struct({
969
+ "file_id": S.String,
970
+ "detail": S.optionalWith(S.Literal("auto", "low", "high"), { default: () => "auto" as const })
971
+ })
972
+ }) {}
973
+
974
+ export class MessageContentImageUrlObject extends S.Struct({
975
+ "type": S.Literal("image_url"),
976
+ "image_url": S.Struct({
977
+ "url": S.String,
978
+ "detail": S.optionalWith(S.Literal("auto", "low", "high"), { default: () => "auto" as const })
979
+ })
980
+ }) {}
981
+
982
+ export class MessageRequestContentTextObject extends S.Struct({
983
+ "type": S.Literal("text"),
984
+ "text": S.String
985
+ }) {}
986
+
987
+ export class AssistantToolsFileSearchTypeOnly extends S.Struct({
988
+ "type": S.Literal("file_search")
989
+ }) {}
990
+
991
+ export class CreateMessageRequest extends S.Struct({
992
+ "role": S.Literal("user", "assistant"),
993
+ "content": S.Union(
994
+ S.String,
995
+ S.NonEmptyArray(
996
+ S.Union(MessageContentImageFileObject, MessageContentImageUrlObject, MessageRequestContentTextObject)
997
+ )
998
+ ),
999
+ "attachments": S.optionalWith(
1000
+ S.Array(S.Struct({
1001
+ "file_id": S.optional(S.String),
1002
+ "tools": S.optional(S.Array(S.Union(AssistantToolsCode, AssistantToolsFileSearchTypeOnly)))
1003
+ })),
1004
+ { nullable: true }
1005
+ ),
1006
+ "metadata": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true })
1007
+ }) {}
1008
+
1009
+ export class CreateThreadRequest extends S.Class<CreateThreadRequest>("CreateThreadRequest")({
1010
+ "messages": S.optional(S.Array(CreateMessageRequest)),
1011
+ "tool_resources": S.optionalWith(
1012
+ S.Struct({
1013
+ "code_interpreter": S.optional(S.Struct({
1014
+ "file_ids": S.optionalWith(S.Array(S.String).pipe(S.maxItems(20)), { default: () => [] as const })
1015
+ })),
1016
+ "file_search": S.optional(S.Struct({
1017
+ "vector_store_ids": S.optional(S.Array(S.String).pipe(S.maxItems(1))),
1018
+ "vector_stores": S.optional(
1019
+ S.Array(S.Struct({
1020
+ "file_ids": S.optional(S.Array(S.String).pipe(S.maxItems(10000))),
1021
+ "chunking_strategy": S.optional(S.Record({ key: S.String, value: S.Unknown })),
1022
+ "metadata": S.optional(S.Record({ key: S.String, value: S.Unknown }))
1023
+ })).pipe(S.maxItems(1))
1024
+ )
1025
+ }))
1026
+ }),
1027
+ { nullable: true }
1028
+ ),
1029
+ "metadata": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true })
1030
+ }) {}
1031
+
1032
+ export class ThreadObject extends S.Class<ThreadObject>("ThreadObject")({
1033
+ "id": S.String,
1034
+ "object": S.Literal("thread"),
1035
+ "created_at": S.Int,
1036
+ "tool_resources": S.NullOr(S.Struct({
1037
+ "code_interpreter": S.optional(S.Struct({
1038
+ "file_ids": S.optionalWith(S.Array(S.String).pipe(S.maxItems(20)), { default: () => [] as const })
1039
+ })),
1040
+ "file_search": S.optional(S.Struct({
1041
+ "vector_store_ids": S.optional(S.Array(S.String).pipe(S.maxItems(1)))
1042
+ }))
1043
+ })),
1044
+ "metadata": S.NullOr(S.Record({ key: S.String, value: S.Unknown }))
1045
+ }) {}
1046
+
1047
+ export class ModifyThreadRequest extends S.Class<ModifyThreadRequest>("ModifyThreadRequest")({
1048
+ "tool_resources": S.optionalWith(
1049
+ S.Struct({
1050
+ "code_interpreter": S.optional(S.Struct({
1051
+ "file_ids": S.optionalWith(S.Array(S.String).pipe(S.maxItems(20)), { default: () => [] as const })
1052
+ })),
1053
+ "file_search": S.optional(S.Struct({
1054
+ "vector_store_ids": S.optional(S.Array(S.String).pipe(S.maxItems(1)))
1055
+ }))
1056
+ }),
1057
+ { nullable: true }
1058
+ ),
1059
+ "metadata": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true })
1060
+ }) {}
1061
+
1062
+ export class DeleteThreadResponse extends S.Class<DeleteThreadResponse>("DeleteThreadResponse")({
1063
+ "id": S.String,
1064
+ "deleted": S.Boolean,
1065
+ "object": S.Literal("thread.deleted")
1066
+ }) {}
1067
+
1068
+ export class ListMessagesParams extends S.Struct({
1069
+ "limit": S.optionalWith(S.Int, { default: () => 20 as const }),
1070
+ "order": S.optionalWith(S.Literal("asc", "desc"), { default: () => "desc" as const }),
1071
+ "after": S.optional(S.String),
1072
+ "before": S.optional(S.String),
1073
+ "run_id": S.optional(S.String)
1074
+ }) {}
1075
+
1076
+ export class MessageContentTextAnnotationsFileCitationObject extends S.Struct({
1077
+ "type": S.Literal("file_citation"),
1078
+ "text": S.String,
1079
+ "file_citation": S.Struct({
1080
+ "file_id": S.String
1081
+ }),
1082
+ "start_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
1083
+ "end_index": S.Int.pipe(S.greaterThanOrEqualTo(0))
1084
+ }) {}
1085
+
1086
+ export class MessageContentTextAnnotationsFilePathObject extends S.Struct({
1087
+ "type": S.Literal("file_path"),
1088
+ "text": S.String,
1089
+ "file_path": S.Struct({
1090
+ "file_id": S.String
1091
+ }),
1092
+ "start_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
1093
+ "end_index": S.Int.pipe(S.greaterThanOrEqualTo(0))
1094
+ }) {}
1095
+
1096
+ export class MessageContentTextObject extends S.Struct({
1097
+ "type": S.Literal("text"),
1098
+ "text": S.Struct({
1099
+ "value": S.String,
1100
+ "annotations": S.Array(
1101
+ S.Union(MessageContentTextAnnotationsFileCitationObject, MessageContentTextAnnotationsFilePathObject)
1102
+ )
1103
+ })
1104
+ }) {}
1105
+
1106
+ export class MessageContentRefusalObject extends S.Struct({
1107
+ "type": S.Literal("refusal"),
1108
+ "refusal": S.String
1109
+ }) {}
1110
+
1111
+ export class MessageObject extends S.Struct({
1112
+ "id": S.String,
1113
+ "object": S.Literal("thread.message"),
1114
+ "created_at": S.Int,
1115
+ "thread_id": S.String,
1116
+ "status": S.Literal("in_progress", "incomplete", "completed"),
1117
+ "incomplete_details": S.NullOr(S.Struct({
1118
+ "reason": S.Literal("content_filter", "max_tokens", "run_cancelled", "run_expired", "run_failed")
1119
+ })),
1120
+ "completed_at": S.NullOr(S.Int),
1121
+ "incomplete_at": S.NullOr(S.Int),
1122
+ "role": S.Literal("user", "assistant"),
1123
+ "content": S.Array(
1124
+ S.Union(
1125
+ MessageContentImageFileObject,
1126
+ MessageContentImageUrlObject,
1127
+ MessageContentTextObject,
1128
+ MessageContentRefusalObject
1129
+ )
1130
+ ),
1131
+ "assistant_id": S.NullOr(S.String),
1132
+ "run_id": S.NullOr(S.String),
1133
+ "attachments": S.NullOr(S.Array(S.Struct({
1134
+ "file_id": S.optional(S.String),
1135
+ "tools": S.optional(S.Array(S.Union(AssistantToolsCode, AssistantToolsFileSearchTypeOnly)))
1136
+ }))),
1137
+ "metadata": S.NullOr(S.Record({ key: S.String, value: S.Unknown }))
1138
+ }) {}
1139
+
1140
+ export class ListMessagesResponse extends S.Class<ListMessagesResponse>("ListMessagesResponse")({
1141
+ "object": S.String,
1142
+ "data": S.Array(MessageObject),
1143
+ "first_id": S.String,
1144
+ "last_id": S.String,
1145
+ "has_more": S.Boolean
1146
+ }) {}
1147
+
1148
+ export class ModifyMessageRequest extends S.Class<ModifyMessageRequest>("ModifyMessageRequest")({
1149
+ "metadata": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true })
1150
+ }) {}
1151
+
1152
+ export class DeleteMessageResponse extends S.Class<DeleteMessageResponse>("DeleteMessageResponse")({
1153
+ "id": S.String,
1154
+ "deleted": S.Boolean,
1155
+ "object": S.Literal("thread.message.deleted")
1156
+ }) {}
1157
+
1158
+ export class TruncationObject extends S.Struct({
1159
+ "type": S.Literal("auto", "last_messages"),
1160
+ "last_messages": S.optionalWith(S.Int.pipe(S.greaterThanOrEqualTo(1)), { nullable: true })
1161
+ }) {}
1162
+
1163
+ export class AssistantsNamedToolChoice extends S.Struct({
1164
+ "type": S.Literal("function", "code_interpreter", "file_search"),
1165
+ "function": S.optional(S.Struct({
1166
+ "name": S.String
1167
+ }))
1168
+ }) {}
1169
+
1170
+ export class AssistantsApiToolChoiceOption
1171
+ extends S.Union(S.Literal("none", "auto", "required"), AssistantsNamedToolChoice)
1172
+ {}
1173
+
1174
+ export class CreateThreadAndRunRequest extends S.Class<CreateThreadAndRunRequest>("CreateThreadAndRunRequest")({
1175
+ "assistant_id": S.String,
1176
+ "thread": S.optional(CreateThreadRequest),
1177
+ "model": S.optionalWith(
1178
+ S.Union(
1179
+ S.String,
1180
+ S.Literal(
1181
+ "gpt-4o",
1182
+ "gpt-4o-2024-08-06",
1183
+ "gpt-4o-2024-05-13",
1184
+ "gpt-4o-2024-08-06",
1185
+ "gpt-4o-mini",
1186
+ "gpt-4o-mini-2024-07-18",
1187
+ "gpt-4-turbo",
1188
+ "gpt-4-turbo-2024-04-09",
1189
+ "gpt-4-0125-preview",
1190
+ "gpt-4-turbo-preview",
1191
+ "gpt-4-1106-preview",
1192
+ "gpt-4-vision-preview",
1193
+ "gpt-4",
1194
+ "gpt-4-0314",
1195
+ "gpt-4-0613",
1196
+ "gpt-4-32k",
1197
+ "gpt-4-32k-0314",
1198
+ "gpt-4-32k-0613",
1199
+ "gpt-3.5-turbo",
1200
+ "gpt-3.5-turbo-16k",
1201
+ "gpt-3.5-turbo-0613",
1202
+ "gpt-3.5-turbo-1106",
1203
+ "gpt-3.5-turbo-0125",
1204
+ "gpt-3.5-turbo-16k-0613"
1205
+ )
1206
+ ),
1207
+ { nullable: true }
1208
+ ),
1209
+ "instructions": S.optionalWith(S.String, { nullable: true }),
1210
+ "tools": S.optionalWith(
1211
+ S.Array(S.Union(AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction)).pipe(S.maxItems(20)),
1212
+ { nullable: true }
1213
+ ),
1214
+ "tool_resources": S.optionalWith(
1215
+ S.Struct({
1216
+ "code_interpreter": S.optional(S.Struct({
1217
+ "file_ids": S.optionalWith(S.Array(S.String).pipe(S.maxItems(20)), { default: () => [] as const })
1218
+ })),
1219
+ "file_search": S.optional(S.Struct({
1220
+ "vector_store_ids": S.optional(S.Array(S.String).pipe(S.maxItems(1)))
1221
+ }))
1222
+ }),
1223
+ { nullable: true }
1224
+ ),
1225
+ "metadata": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true }),
1226
+ "temperature": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(2)), {
1227
+ nullable: true,
1228
+ default: () => 1 as const
1229
+ }),
1230
+ "top_p": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(1)), {
1231
+ nullable: true,
1232
+ default: () => 1 as const
1233
+ }),
1234
+ "stream": S.optionalWith(S.Boolean, { nullable: true }),
1235
+ "max_prompt_tokens": S.optionalWith(S.Int.pipe(S.greaterThanOrEqualTo(256)), { nullable: true }),
1236
+ "max_completion_tokens": S.optionalWith(S.Int.pipe(S.greaterThanOrEqualTo(256)), { nullable: true }),
1237
+ "truncation_strategy": S.optional(TruncationObject),
1238
+ "tool_choice": S.optional(AssistantsApiToolChoiceOption),
1239
+ "parallel_tool_calls": S.optionalWith(ParallelToolCalls, { default: () => true as const }),
1240
+ "response_format": S.optional(AssistantsApiResponseFormatOption)
1241
+ }) {}
1242
+
1243
+ export class RunToolCallObject extends S.Struct({
1244
+ "id": S.String,
1245
+ "type": S.Literal("function"),
1246
+ "function": S.Struct({
1247
+ "name": S.String,
1248
+ "arguments": S.String
1249
+ })
1250
+ }) {}
1251
+
1252
+ export class RunCompletionUsage extends S.Struct({
1253
+ "completion_tokens": S.Int,
1254
+ "prompt_tokens": S.Int,
1255
+ "total_tokens": S.Int
1256
+ }) {}
1257
+
1258
+ export class RunObject extends S.Class<RunObject>("RunObject")({
1259
+ "id": S.String,
1260
+ "object": S.Literal("thread.run"),
1261
+ "created_at": S.Int,
1262
+ "thread_id": S.String,
1263
+ "assistant_id": S.String,
1264
+ "status": S.Literal(
1265
+ "queued",
1266
+ "in_progress",
1267
+ "requires_action",
1268
+ "cancelling",
1269
+ "cancelled",
1270
+ "failed",
1271
+ "completed",
1272
+ "incomplete",
1273
+ "expired"
1274
+ ),
1275
+ "required_action": S.NullOr(S.Struct({
1276
+ "type": S.Literal("submit_tool_outputs"),
1277
+ "submit_tool_outputs": S.Struct({
1278
+ "tool_calls": S.Array(RunToolCallObject)
1279
+ })
1280
+ })),
1281
+ "last_error": S.NullOr(S.Struct({
1282
+ "code": S.Literal("server_error", "rate_limit_exceeded", "invalid_prompt"),
1283
+ "message": S.String
1284
+ })),
1285
+ "expires_at": S.NullOr(S.Int),
1286
+ "started_at": S.NullOr(S.Int),
1287
+ "cancelled_at": S.NullOr(S.Int),
1288
+ "failed_at": S.NullOr(S.Int),
1289
+ "completed_at": S.NullOr(S.Int),
1290
+ "incomplete_details": S.NullOr(S.Struct({
1291
+ "reason": S.optional(S.Literal("max_completion_tokens", "max_prompt_tokens"))
1292
+ })),
1293
+ "model": S.String,
1294
+ "instructions": S.String,
1295
+ "tools": S.Array(S.Union(AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction)).pipe(S.maxItems(20))
1296
+ .pipe(S.propertySignature, S.withConstructorDefault(() => [] as const)),
1297
+ "metadata": S.NullOr(S.Record({ key: S.String, value: S.Unknown })),
1298
+ "usage": S.NullOr(RunCompletionUsage),
1299
+ "temperature": S.optionalWith(S.Number, { nullable: true }),
1300
+ "top_p": S.optionalWith(S.Number, { nullable: true }),
1301
+ "max_prompt_tokens": S.NullOr(S.Int.pipe(S.greaterThanOrEqualTo(256))),
1302
+ "max_completion_tokens": S.NullOr(S.Int.pipe(S.greaterThanOrEqualTo(256))),
1303
+ "truncation_strategy": TruncationObject,
1304
+ "tool_choice": AssistantsApiToolChoiceOption,
1305
+ "parallel_tool_calls": ParallelToolCalls.pipe(S.propertySignature, S.withConstructorDefault(() => true as const)),
1306
+ "response_format": AssistantsApiResponseFormatOption
1307
+ }) {}
1308
+
1309
+ export class ListRunsParams extends S.Struct({
1310
+ "limit": S.optionalWith(S.Int, { default: () => 20 as const }),
1311
+ "order": S.optionalWith(S.Literal("asc", "desc"), { default: () => "desc" as const }),
1312
+ "after": S.optional(S.String),
1313
+ "before": S.optional(S.String)
1314
+ }) {}
1315
+
1316
+ export class ListRunsResponse extends S.Class<ListRunsResponse>("ListRunsResponse")({
1317
+ "object": S.String,
1318
+ "data": S.Array(RunObject),
1319
+ "first_id": S.String,
1320
+ "last_id": S.String,
1321
+ "has_more": S.Boolean
1322
+ }) {}
1323
+
1324
+ export class CreateRunParams extends S.Struct({
1325
+ "include[]": S.optional(S.Array(S.Literal("step_details.tool_calls[*].file_search.results[*].content")))
1326
+ }) {}
1327
+
1328
+ export class CreateRunRequest extends S.Class<CreateRunRequest>("CreateRunRequest")({
1329
+ "assistant_id": S.String,
1330
+ "model": S.optionalWith(
1331
+ S.Union(
1332
+ S.String,
1333
+ S.Literal(
1334
+ "gpt-4o",
1335
+ "gpt-4o-2024-08-06",
1336
+ "gpt-4o-2024-05-13",
1337
+ "gpt-4o-2024-08-06",
1338
+ "gpt-4o-mini",
1339
+ "gpt-4o-mini-2024-07-18",
1340
+ "gpt-4-turbo",
1341
+ "gpt-4-turbo-2024-04-09",
1342
+ "gpt-4-0125-preview",
1343
+ "gpt-4-turbo-preview",
1344
+ "gpt-4-1106-preview",
1345
+ "gpt-4-vision-preview",
1346
+ "gpt-4",
1347
+ "gpt-4-0314",
1348
+ "gpt-4-0613",
1349
+ "gpt-4-32k",
1350
+ "gpt-4-32k-0314",
1351
+ "gpt-4-32k-0613",
1352
+ "gpt-3.5-turbo",
1353
+ "gpt-3.5-turbo-16k",
1354
+ "gpt-3.5-turbo-0613",
1355
+ "gpt-3.5-turbo-1106",
1356
+ "gpt-3.5-turbo-0125",
1357
+ "gpt-3.5-turbo-16k-0613"
1358
+ )
1359
+ ),
1360
+ { nullable: true }
1361
+ ),
1362
+ "instructions": S.optionalWith(S.String, { nullable: true }),
1363
+ "additional_instructions": S.optionalWith(S.String, { nullable: true }),
1364
+ "additional_messages": S.optionalWith(S.Array(CreateMessageRequest), { nullable: true }),
1365
+ "tools": S.optionalWith(
1366
+ S.Array(S.Union(AssistantToolsCode, AssistantToolsFileSearch, AssistantToolsFunction)).pipe(S.maxItems(20)),
1367
+ { nullable: true }
1368
+ ),
1369
+ "metadata": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true }),
1370
+ "temperature": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(2)), {
1371
+ nullable: true,
1372
+ default: () => 1 as const
1373
+ }),
1374
+ "top_p": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(1)), {
1375
+ nullable: true,
1376
+ default: () => 1 as const
1377
+ }),
1378
+ "stream": S.optionalWith(S.Boolean, { nullable: true }),
1379
+ "max_prompt_tokens": S.optionalWith(S.Int.pipe(S.greaterThanOrEqualTo(256)), { nullable: true }),
1380
+ "max_completion_tokens": S.optionalWith(S.Int.pipe(S.greaterThanOrEqualTo(256)), { nullable: true }),
1381
+ "truncation_strategy": S.optional(TruncationObject),
1382
+ "tool_choice": S.optional(AssistantsApiToolChoiceOption),
1383
+ "parallel_tool_calls": S.optionalWith(ParallelToolCalls, { default: () => true as const }),
1384
+ "response_format": S.optional(AssistantsApiResponseFormatOption)
1385
+ }) {}
1386
+
1387
+ export class ModifyRunRequest extends S.Class<ModifyRunRequest>("ModifyRunRequest")({
1388
+ "metadata": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true })
1389
+ }) {}
1390
+
1391
+ export class SubmitToolOutputsRunRequest extends S.Class<SubmitToolOutputsRunRequest>("SubmitToolOutputsRunRequest")({
1392
+ "tool_outputs": S.Array(S.Struct({
1393
+ "tool_call_id": S.optional(S.String),
1394
+ "output": S.optional(S.String)
1395
+ })),
1396
+ "stream": S.optionalWith(S.Boolean, { nullable: true })
1397
+ }) {}
1398
+
1399
+ export class ListRunStepsParams extends S.Struct({
1400
+ "limit": S.optionalWith(S.Int, { default: () => 20 as const }),
1401
+ "order": S.optionalWith(S.Literal("asc", "desc"), { default: () => "desc" as const }),
1402
+ "after": S.optional(S.String),
1403
+ "before": S.optional(S.String),
1404
+ "include[]": S.optional(S.Array(S.Literal("step_details.tool_calls[*].file_search.results[*].content")))
1405
+ }) {}
1406
+
1407
+ export class RunStepDetailsMessageCreationObject extends S.Struct({
1408
+ "type": S.Literal("message_creation"),
1409
+ "message_creation": S.Struct({
1410
+ "message_id": S.String
1411
+ })
1412
+ }) {}
1413
+
1414
+ export class RunStepDetailsToolCallsCodeOutputLogsObject extends S.Struct({
1415
+ "type": S.Literal("logs"),
1416
+ "logs": S.String
1417
+ }) {}
1418
+
1419
+ export class RunStepDetailsToolCallsCodeOutputImageObject extends S.Struct({
1420
+ "type": S.Literal("image"),
1421
+ "image": S.Struct({
1422
+ "file_id": S.String
1423
+ })
1424
+ }) {}
1425
+
1426
+ export class RunStepDetailsToolCallsCodeObject extends S.Struct({
1427
+ "id": S.String,
1428
+ "type": S.Literal("code_interpreter"),
1429
+ "code_interpreter": S.Struct({
1430
+ "input": S.String,
1431
+ "outputs": S.Array(S.Record({ key: S.String, value: S.Unknown }))
1432
+ })
1433
+ }) {}
1434
+
1435
+ export class RunStepDetailsToolCallsFileSearchRankingOptionsObject extends S.Struct({
1436
+ "ranker": S.Literal("default_2024_08_21"),
1437
+ "score_threshold": S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(1))
1438
+ }) {}
1439
+
1440
+ export class RunStepDetailsToolCallsFileSearchResultObject extends S.Struct({
1441
+ "file_id": S.String,
1442
+ "file_name": S.String,
1443
+ "score": S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(1)),
1444
+ "content": S.optional(S.Array(S.Struct({
1445
+ "type": S.optional(S.Literal("text")),
1446
+ "text": S.optional(S.String)
1447
+ })))
1448
+ }) {}
1449
+
1450
+ export class RunStepDetailsToolCallsFileSearchObject extends S.Struct({
1451
+ "id": S.String,
1452
+ "type": S.Literal("file_search"),
1453
+ "file_search": S.Struct({
1454
+ "ranking_options": S.optional(RunStepDetailsToolCallsFileSearchRankingOptionsObject),
1455
+ "results": S.optional(S.Array(RunStepDetailsToolCallsFileSearchResultObject))
1456
+ })
1457
+ }) {}
1458
+
1459
+ export class RunStepDetailsToolCallsFunctionObject extends S.Struct({
1460
+ "id": S.String,
1461
+ "type": S.Literal("function"),
1462
+ "function": S.Struct({
1463
+ "name": S.String,
1464
+ "arguments": S.String,
1465
+ "output": S.NullOr(S.String)
1466
+ })
1467
+ }) {}
1468
+
1469
+ export class RunStepDetailsToolCallsObject extends S.Struct({
1470
+ "type": S.Literal("tool_calls"),
1471
+ "tool_calls": S.Array(
1472
+ S.Union(
1473
+ RunStepDetailsToolCallsCodeObject,
1474
+ RunStepDetailsToolCallsFileSearchObject,
1475
+ RunStepDetailsToolCallsFunctionObject
1476
+ )
1477
+ )
1478
+ }) {}
1479
+
1480
+ export class RunStepCompletionUsage extends S.Struct({
1481
+ "completion_tokens": S.Int,
1482
+ "prompt_tokens": S.Int,
1483
+ "total_tokens": S.Int
1484
+ }) {}
1485
+
1486
+ export class RunStepObject extends S.Struct({
1487
+ "id": S.String,
1488
+ "object": S.Literal("thread.run.step"),
1489
+ "created_at": S.Int,
1490
+ "assistant_id": S.String,
1491
+ "thread_id": S.String,
1492
+ "run_id": S.String,
1493
+ "type": S.Literal("message_creation", "tool_calls"),
1494
+ "status": S.Literal("in_progress", "cancelled", "failed", "completed", "expired"),
1495
+ "step_details": S.Record({ key: S.String, value: S.Unknown }),
1496
+ "last_error": S.NullOr(S.Struct({
1497
+ "code": S.Literal("server_error", "rate_limit_exceeded"),
1498
+ "message": S.String
1499
+ })),
1500
+ "expired_at": S.NullOr(S.Int),
1501
+ "cancelled_at": S.NullOr(S.Int),
1502
+ "failed_at": S.NullOr(S.Int),
1503
+ "completed_at": S.NullOr(S.Int),
1504
+ "metadata": S.NullOr(S.Record({ key: S.String, value: S.Unknown })),
1505
+ "usage": S.NullOr(RunStepCompletionUsage)
1506
+ }) {}
1507
+
1508
+ export class ListRunStepsResponse extends S.Class<ListRunStepsResponse>("ListRunStepsResponse")({
1509
+ "object": S.String,
1510
+ "data": S.Array(RunStepObject),
1511
+ "first_id": S.String,
1512
+ "last_id": S.String,
1513
+ "has_more": S.Boolean
1514
+ }) {}
1515
+
1516
+ export class GetRunStepParams extends S.Struct({
1517
+ "include[]": S.optional(S.Array(S.Literal("step_details.tool_calls[*].file_search.results[*].content")))
1518
+ }) {}
1519
+
1520
+ export class ListVectorStoresParams extends S.Struct({
1521
+ "limit": S.optionalWith(S.Int, { default: () => 20 as const }),
1522
+ "order": S.optionalWith(S.Literal("asc", "desc"), { default: () => "desc" as const }),
1523
+ "after": S.optional(S.String),
1524
+ "before": S.optional(S.String)
1525
+ }) {}
1526
+
1527
+ export class VectorStoreExpirationAfter extends S.Struct({
1528
+ "anchor": S.Literal("last_active_at"),
1529
+ "days": S.Int.pipe(S.greaterThanOrEqualTo(1), S.lessThanOrEqualTo(365))
1530
+ }) {}
1531
+
1532
+ export class VectorStoreObject extends S.Struct({
1533
+ "id": S.String,
1534
+ "object": S.Literal("vector_store"),
1535
+ "created_at": S.Int,
1536
+ "name": S.String,
1537
+ "usage_bytes": S.Int,
1538
+ "file_counts": S.Struct({
1539
+ "in_progress": S.Int,
1540
+ "completed": S.Int,
1541
+ "failed": S.Int,
1542
+ "cancelled": S.Int,
1543
+ "total": S.Int
1544
+ }),
1545
+ "status": S.Literal("expired", "in_progress", "completed"),
1546
+ "expires_after": S.optional(VectorStoreExpirationAfter),
1547
+ "expires_at": S.optionalWith(S.Int, { nullable: true }),
1548
+ "last_active_at": S.NullOr(S.Int),
1549
+ "metadata": S.NullOr(S.Record({ key: S.String, value: S.Unknown }))
1550
+ }) {}
1551
+
1552
+ export class ListVectorStoresResponse extends S.Class<ListVectorStoresResponse>("ListVectorStoresResponse")({
1553
+ "object": S.String,
1554
+ "data": S.Array(VectorStoreObject),
1555
+ "first_id": S.String,
1556
+ "last_id": S.String,
1557
+ "has_more": S.Boolean
1558
+ }) {}
1559
+
1560
+ export class AutoChunkingStrategyRequestParam extends S.Struct({
1561
+ "type": S.Literal("auto")
1562
+ }) {}
1563
+
1564
+ export class StaticChunkingStrategy extends S.Struct({
1565
+ "max_chunk_size_tokens": S.Int.pipe(S.greaterThanOrEqualTo(100), S.lessThanOrEqualTo(4096)),
1566
+ "chunk_overlap_tokens": S.Int
1567
+ }) {}
1568
+
1569
+ export class StaticChunkingStrategyRequestParam extends S.Struct({
1570
+ "type": S.Literal("static"),
1571
+ "static": StaticChunkingStrategy
1572
+ }) {}
1573
+
1574
+ export class CreateVectorStoreRequest extends S.Class<CreateVectorStoreRequest>("CreateVectorStoreRequest")({
1575
+ "file_ids": S.optional(S.Array(S.String).pipe(S.maxItems(500))),
1576
+ "name": S.optional(S.String),
1577
+ "expires_after": S.optional(VectorStoreExpirationAfter),
1578
+ "chunking_strategy": S.optional(S.Record({ key: S.String, value: S.Unknown })),
1579
+ "metadata": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true })
1580
+ }) {}
1581
+
1582
+ export class UpdateVectorStoreRequest extends S.Class<UpdateVectorStoreRequest>("UpdateVectorStoreRequest")({
1583
+ "name": S.optionalWith(S.String, { nullable: true }),
1584
+ "expires_after": S.optional(VectorStoreExpirationAfter),
1585
+ "metadata": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true })
1586
+ }) {}
1587
+
1588
+ export class DeleteVectorStoreResponse extends S.Class<DeleteVectorStoreResponse>("DeleteVectorStoreResponse")({
1589
+ "id": S.String,
1590
+ "deleted": S.Boolean,
1591
+ "object": S.Literal("vector_store.deleted")
1592
+ }) {}
1593
+
1594
+ export class ListVectorStoreFilesParams extends S.Struct({
1595
+ "limit": S.optionalWith(S.Int, { default: () => 20 as const }),
1596
+ "order": S.optionalWith(S.Literal("asc", "desc"), { default: () => "desc" as const }),
1597
+ "after": S.optional(S.String),
1598
+ "before": S.optional(S.String),
1599
+ "filter": S.optional(S.Literal("in_progress", "completed", "failed", "cancelled"))
1600
+ }) {}
1601
+
1602
+ export class StaticChunkingStrategyResponseParam extends S.Struct({
1603
+ "type": S.Literal("static"),
1604
+ "static": StaticChunkingStrategy
1605
+ }) {}
1606
+
1607
+ export class OtherChunkingStrategyResponseParam extends S.Struct({
1608
+ "type": S.Literal("other")
1609
+ }) {}
1610
+
1611
+ export class VectorStoreFileObject extends S.Struct({
1612
+ "id": S.String,
1613
+ "object": S.Literal("vector_store.file"),
1614
+ "usage_bytes": S.Int,
1615
+ "created_at": S.Int,
1616
+ "vector_store_id": S.String,
1617
+ "status": S.Literal("in_progress", "completed", "cancelled", "failed"),
1618
+ "last_error": S.NullOr(S.Struct({
1619
+ "code": S.Literal("server_error", "unsupported_file", "invalid_file"),
1620
+ "message": S.String
1621
+ })),
1622
+ "chunking_strategy": S.optional(S.Record({ key: S.String, value: S.Unknown }))
1623
+ }) {}
1624
+
1625
+ export class ListVectorStoreFilesResponse
1626
+ extends S.Class<ListVectorStoreFilesResponse>("ListVectorStoreFilesResponse")({
1627
+ "object": S.String,
1628
+ "data": S.Array(VectorStoreFileObject),
1629
+ "first_id": S.String,
1630
+ "last_id": S.String,
1631
+ "has_more": S.Boolean
1632
+ })
1633
+ {}
1634
+
1635
+ export class ChunkingStrategyRequestParam extends S.Record({ key: S.String, value: S.Unknown }) {}
1636
+
1637
+ export class CreateVectorStoreFileRequest
1638
+ extends S.Class<CreateVectorStoreFileRequest>("CreateVectorStoreFileRequest")({
1639
+ "file_id": S.String,
1640
+ "chunking_strategy": S.optional(ChunkingStrategyRequestParam)
1641
+ })
1642
+ {}
1643
+
1644
+ export class DeleteVectorStoreFileResponse
1645
+ extends S.Class<DeleteVectorStoreFileResponse>("DeleteVectorStoreFileResponse")({
1646
+ "id": S.String,
1647
+ "deleted": S.Boolean,
1648
+ "object": S.Literal("vector_store.file.deleted")
1649
+ })
1650
+ {}
1651
+
1652
+ export class CreateVectorStoreFileBatchRequest
1653
+ extends S.Class<CreateVectorStoreFileBatchRequest>("CreateVectorStoreFileBatchRequest")({
1654
+ "file_ids": S.Array(S.String).pipe(S.minItems(1), S.maxItems(500)),
1655
+ "chunking_strategy": S.optional(ChunkingStrategyRequestParam)
1656
+ })
1657
+ {}
1658
+
1659
+ export class VectorStoreFileBatchObject extends S.Class<VectorStoreFileBatchObject>("VectorStoreFileBatchObject")({
1660
+ "id": S.String,
1661
+ "object": S.Literal("vector_store.files_batch"),
1662
+ "created_at": S.Int,
1663
+ "vector_store_id": S.String,
1664
+ "status": S.Literal("in_progress", "completed", "cancelled", "failed"),
1665
+ "file_counts": S.Struct({
1666
+ "in_progress": S.Int,
1667
+ "completed": S.Int,
1668
+ "failed": S.Int,
1669
+ "cancelled": S.Int,
1670
+ "total": S.Int
1671
+ })
1672
+ }) {}
1673
+
1674
+ export class ListFilesInVectorStoreBatchParams extends S.Struct({
1675
+ "limit": S.optionalWith(S.Int, { default: () => 20 as const }),
1676
+ "order": S.optionalWith(S.Literal("asc", "desc"), { default: () => "desc" as const }),
1677
+ "after": S.optional(S.String),
1678
+ "before": S.optional(S.String),
1679
+ "filter": S.optional(S.Literal("in_progress", "completed", "failed", "cancelled"))
1680
+ }) {}
1681
+
1682
+ export class ListBatchesParams extends S.Struct({
1683
+ "after": S.optional(S.String),
1684
+ "limit": S.optionalWith(S.Int, { default: () => 20 as const })
1685
+ }) {}
1686
+
1687
+ export class Batch extends S.Struct({
1688
+ "id": S.String,
1689
+ "object": S.Literal("batch"),
1690
+ "endpoint": S.String,
1691
+ "errors": S.optional(S.Struct({
1692
+ "object": S.optional(S.String),
1693
+ "data": S.optional(S.Array(S.Struct({
1694
+ "code": S.optional(S.String),
1695
+ "message": S.optional(S.String),
1696
+ "param": S.optionalWith(S.String, { nullable: true }),
1697
+ "line": S.optionalWith(S.Int, { nullable: true })
1698
+ })))
1699
+ })),
1700
+ "input_file_id": S.String,
1701
+ "completion_window": S.String,
1702
+ "status": S.Literal(
1703
+ "validating",
1704
+ "failed",
1705
+ "in_progress",
1706
+ "finalizing",
1707
+ "completed",
1708
+ "expired",
1709
+ "cancelling",
1710
+ "cancelled"
1711
+ ),
1712
+ "output_file_id": S.optional(S.String),
1713
+ "error_file_id": S.optional(S.String),
1714
+ "created_at": S.Int,
1715
+ "in_progress_at": S.optional(S.Int),
1716
+ "expires_at": S.optional(S.Int),
1717
+ "finalizing_at": S.optional(S.Int),
1718
+ "completed_at": S.optional(S.Int),
1719
+ "failed_at": S.optional(S.Int),
1720
+ "expired_at": S.optional(S.Int),
1721
+ "cancelling_at": S.optional(S.Int),
1722
+ "cancelled_at": S.optional(S.Int),
1723
+ "request_counts": S.optional(S.Struct({
1724
+ "total": S.Int,
1725
+ "completed": S.Int,
1726
+ "failed": S.Int
1727
+ })),
1728
+ "metadata": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true })
1729
+ }) {}
1730
+
1731
+ export class ListBatchesResponse extends S.Class<ListBatchesResponse>("ListBatchesResponse")({
1732
+ "data": S.Array(Batch),
1733
+ "first_id": S.optional(S.String),
1734
+ "last_id": S.optional(S.String),
1735
+ "has_more": S.Boolean,
1736
+ "object": S.Literal("list")
1737
+ }) {}
1738
+
1739
+ export class CreateBatchRequest extends S.Class<CreateBatchRequest>("CreateBatchRequest")({
1740
+ "input_file_id": S.String,
1741
+ "endpoint": S.Literal("/v1/chat/completions", "/v1/embeddings", "/v1/completions"),
1742
+ "completion_window": S.Literal("24h"),
1743
+ "metadata": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true })
1744
+ }) {}
1745
+
1746
+ export class AuditLogEventType extends S.Literal(
1747
+ "api_key.created",
1748
+ "api_key.updated",
1749
+ "api_key.deleted",
1750
+ "invite.sent",
1751
+ "invite.accepted",
1752
+ "invite.deleted",
1753
+ "login.succeeded",
1754
+ "login.failed",
1755
+ "logout.succeeded",
1756
+ "logout.failed",
1757
+ "organization.updated",
1758
+ "project.created",
1759
+ "project.updated",
1760
+ "project.archived",
1761
+ "service_account.created",
1762
+ "service_account.updated",
1763
+ "service_account.deleted",
1764
+ "user.added",
1765
+ "user.updated",
1766
+ "user.deleted"
1767
+ ) {}
1768
+
1769
+ export class ListAuditLogsParams extends S.Struct({
1770
+ "effective_at[gt]": S.optional(S.Int),
1771
+ "effective_at[gte]": S.optional(S.Int),
1772
+ "effective_at[lt]": S.optional(S.Int),
1773
+ "effective_at[lte]": S.optional(S.Int),
1774
+ "project_ids[]": S.optional(S.Array(S.String)),
1775
+ "event_types[]": S.optional(S.Array(AuditLogEventType)),
1776
+ "actor_ids[]": S.optional(S.Array(S.String)),
1777
+ "actor_emails[]": S.optional(S.Array(S.String)),
1778
+ "resource_ids[]": S.optional(S.Array(S.String)),
1779
+ "limit": S.optionalWith(S.Int, { default: () => 20 as const }),
1780
+ "after": S.optional(S.String),
1781
+ "before": S.optional(S.String)
1782
+ }) {}
1783
+
1784
+ export class AuditLogActorUser extends S.Struct({
1785
+ "id": S.optional(S.String),
1786
+ "email": S.optional(S.String)
1787
+ }) {}
1788
+
1789
+ export class AuditLogActorSession extends S.Struct({
1790
+ "user": S.optional(AuditLogActorUser),
1791
+ "ip_address": S.optional(S.String)
1792
+ }) {}
1793
+
1794
+ export class AuditLogActorServiceAccount extends S.Struct({
1795
+ "id": S.optional(S.String)
1796
+ }) {}
1797
+
1798
+ export class AuditLogActorApiKey extends S.Struct({
1799
+ "id": S.optional(S.String),
1800
+ "type": S.optional(S.Literal("user", "service_account")),
1801
+ "user": S.optional(AuditLogActorUser),
1802
+ "service_account": S.optional(AuditLogActorServiceAccount)
1803
+ }) {}
1804
+
1805
+ export class AuditLogActor extends S.Struct({
1806
+ "type": S.optional(S.Literal("session", "api_key")),
1807
+ "session": S.optional(S.Record({ key: S.String, value: S.Unknown })),
1808
+ "api_key": S.optional(S.Record({ key: S.String, value: S.Unknown }))
1809
+ }) {}
1810
+
1811
+ export class AuditLog extends S.Struct({
1812
+ "id": S.String,
1813
+ "type": AuditLogEventType,
1814
+ "effective_at": S.Int,
1815
+ "project": S.optional(S.Struct({
1816
+ "id": S.optional(S.String),
1817
+ "name": S.optional(S.String)
1818
+ })),
1819
+ "actor": AuditLogActor,
1820
+ "api_key.created": S.optional(S.Struct({
1821
+ "id": S.optional(S.String),
1822
+ "data": S.optional(S.Struct({
1823
+ "scopes": S.optional(S.Array(S.String))
1824
+ }))
1825
+ })),
1826
+ "api_key.updated": S.optional(S.Struct({
1827
+ "id": S.optional(S.String),
1828
+ "changes_requested": S.optional(S.Struct({
1829
+ "scopes": S.optional(S.Array(S.String))
1830
+ }))
1831
+ })),
1832
+ "api_key.deleted": S.optional(S.Struct({
1833
+ "id": S.optional(S.String)
1834
+ })),
1835
+ "invite.sent": S.optional(S.Struct({
1836
+ "id": S.optional(S.String),
1837
+ "data": S.optional(S.Struct({
1838
+ "email": S.optional(S.String),
1839
+ "role": S.optional(S.String)
1840
+ }))
1841
+ })),
1842
+ "invite.accepted": S.optional(S.Struct({
1843
+ "id": S.optional(S.String)
1844
+ })),
1845
+ "invite.deleted": S.optional(S.Struct({
1846
+ "id": S.optional(S.String)
1847
+ })),
1848
+ "login.failed": S.optional(S.Struct({
1849
+ "error_code": S.optional(S.String),
1850
+ "error_message": S.optional(S.String)
1851
+ })),
1852
+ "logout.failed": S.optional(S.Struct({
1853
+ "error_code": S.optional(S.String),
1854
+ "error_message": S.optional(S.String)
1855
+ })),
1856
+ "organization.updated": S.optional(S.Struct({
1857
+ "id": S.optional(S.String),
1858
+ "changes_requested": S.optional(S.Struct({
1859
+ "title": S.optional(S.String),
1860
+ "description": S.optional(S.String),
1861
+ "name": S.optional(S.String),
1862
+ "settings": S.optional(S.Struct({
1863
+ "threads_ui_visibility": S.optional(S.String),
1864
+ "usage_dashboard_visibility": S.optional(S.String)
1865
+ }))
1866
+ }))
1867
+ })),
1868
+ "project.created": S.optional(S.Struct({
1869
+ "id": S.optional(S.String),
1870
+ "data": S.optional(S.Struct({
1871
+ "name": S.optional(S.String),
1872
+ "title": S.optional(S.String)
1873
+ }))
1874
+ })),
1875
+ "project.updated": S.optional(S.Struct({
1876
+ "id": S.optional(S.String),
1877
+ "changes_requested": S.optional(S.Struct({
1878
+ "title": S.optional(S.String)
1879
+ }))
1880
+ })),
1881
+ "project.archived": S.optional(S.Struct({
1882
+ "id": S.optional(S.String)
1883
+ })),
1884
+ "service_account.created": S.optional(S.Struct({
1885
+ "id": S.optional(S.String),
1886
+ "data": S.optional(S.Struct({
1887
+ "role": S.optional(S.String)
1888
+ }))
1889
+ })),
1890
+ "service_account.updated": S.optional(S.Struct({
1891
+ "id": S.optional(S.String),
1892
+ "changes_requested": S.optional(S.Struct({
1893
+ "role": S.optional(S.String)
1894
+ }))
1895
+ })),
1896
+ "service_account.deleted": S.optional(S.Struct({
1897
+ "id": S.optional(S.String)
1898
+ })),
1899
+ "user.added": S.optional(S.Struct({
1900
+ "id": S.optional(S.String),
1901
+ "data": S.optional(S.Struct({
1902
+ "role": S.optional(S.String)
1903
+ }))
1904
+ })),
1905
+ "user.updated": S.optional(S.Struct({
1906
+ "id": S.optional(S.String),
1907
+ "changes_requested": S.optional(S.Struct({
1908
+ "role": S.optional(S.String)
1909
+ }))
1910
+ })),
1911
+ "user.deleted": S.optional(S.Struct({
1912
+ "id": S.optional(S.String)
1913
+ }))
1914
+ }) {}
1915
+
1916
+ export class ListAuditLogsResponse extends S.Class<ListAuditLogsResponse>("ListAuditLogsResponse")({
1917
+ "object": S.Literal("list"),
1918
+ "data": S.Array(AuditLog),
1919
+ "first_id": S.String,
1920
+ "last_id": S.String,
1921
+ "has_more": S.Boolean
1922
+ }) {}
1923
+
1924
+ export class ListInvitesParams extends S.Struct({
1925
+ "limit": S.optionalWith(S.Int, { default: () => 20 as const }),
1926
+ "after": S.optional(S.String)
1927
+ }) {}
1928
+
1929
+ export class Invite extends S.Struct({
1930
+ "object": S.Literal("organization.invite"),
1931
+ "id": S.String,
1932
+ "email": S.String,
1933
+ "role": S.Literal("owner", "reader"),
1934
+ "status": S.Literal("accepted", "expired", "pending"),
1935
+ "invited_at": S.Int,
1936
+ "expires_at": S.Int,
1937
+ "accepted_at": S.optional(S.Int)
1938
+ }) {}
1939
+
1940
+ export class InviteListResponse extends S.Class<InviteListResponse>("InviteListResponse")({
1941
+ "object": S.Literal("list"),
1942
+ "data": S.Array(Invite),
1943
+ "first_id": S.optional(S.String),
1944
+ "last_id": S.optional(S.String),
1945
+ "has_more": S.optional(S.Boolean)
1946
+ }) {}
1947
+
1948
+ export class InviteRequest extends S.Class<InviteRequest>("InviteRequest")({
1949
+ "email": S.String,
1950
+ "role": S.Literal("reader", "owner")
1951
+ }) {}
1952
+
1953
+ export class InviteDeleteResponse extends S.Class<InviteDeleteResponse>("InviteDeleteResponse")({
1954
+ "object": S.Literal("organization.invite.deleted"),
1955
+ "id": S.String,
1956
+ "deleted": S.Boolean
1957
+ }) {}
1958
+
1959
+ export class ListUsersParams extends S.Struct({
1960
+ "limit": S.optionalWith(S.Int, { default: () => 20 as const }),
1961
+ "after": S.optional(S.String)
1962
+ }) {}
1963
+
1964
+ export class User extends S.Struct({
1965
+ "object": S.Literal("organization.user"),
1966
+ "id": S.String,
1967
+ "name": S.String,
1968
+ "email": S.String,
1969
+ "role": S.Literal("owner", "reader"),
1970
+ "added_at": S.Int
1971
+ }) {}
1972
+
1973
+ export class UserListResponse extends S.Class<UserListResponse>("UserListResponse")({
1974
+ "object": S.Literal("list"),
1975
+ "data": S.Array(User),
1976
+ "first_id": S.String,
1977
+ "last_id": S.String,
1978
+ "has_more": S.Boolean
1979
+ }) {}
1980
+
1981
+ export class UserRoleUpdateRequest extends S.Class<UserRoleUpdateRequest>("UserRoleUpdateRequest")({
1982
+ "role": S.Literal("owner", "reader")
1983
+ }) {}
1984
+
1985
+ export class UserDeleteResponse extends S.Class<UserDeleteResponse>("UserDeleteResponse")({
1986
+ "object": S.Literal("organization.user.deleted"),
1987
+ "id": S.String,
1988
+ "deleted": S.Boolean
1989
+ }) {}
1990
+
1991
+ export class ListProjectsParams extends S.Struct({
1992
+ "limit": S.optionalWith(S.Int, { default: () => 20 as const }),
1993
+ "after": S.optional(S.String),
1994
+ "include_archived": S.optionalWith(S.Boolean, { default: () => false as const })
1995
+ }) {}
1996
+
1997
+ export class Project extends S.Struct({
1998
+ "id": S.String,
1999
+ "object": S.Literal("organization.project"),
2000
+ "name": S.String,
2001
+ "created_at": S.Int,
2002
+ "archived_at": S.optionalWith(S.Int, { nullable: true }),
2003
+ "status": S.Literal("active", "archived")
2004
+ }) {}
2005
+
2006
+ export class ProjectListResponse extends S.Class<ProjectListResponse>("ProjectListResponse")({
2007
+ "object": S.Literal("list"),
2008
+ "data": S.Array(Project),
2009
+ "first_id": S.String,
2010
+ "last_id": S.String,
2011
+ "has_more": S.Boolean
2012
+ }) {}
2013
+
2014
+ export class ProjectCreateRequest extends S.Class<ProjectCreateRequest>("ProjectCreateRequest")({
2015
+ "name": S.String
2016
+ }) {}
2017
+
2018
+ export class ProjectUpdateRequest extends S.Class<ProjectUpdateRequest>("ProjectUpdateRequest")({
2019
+ "name": S.String
2020
+ }) {}
2021
+
2022
+ export class Error extends S.Struct({
2023
+ "code": S.NullOr(S.String),
2024
+ "message": S.String,
2025
+ "param": S.NullOr(S.String),
2026
+ "type": S.String
2027
+ }) {}
2028
+
2029
+ export class ErrorResponse extends S.Class<ErrorResponse>("ErrorResponse")({
2030
+ "error": Error
2031
+ }) {}
2032
+
2033
+ export class ListProjectUsersParams extends S.Struct({
2034
+ "limit": S.optionalWith(S.Int, { default: () => 20 as const }),
2035
+ "after": S.optional(S.String)
2036
+ }) {}
2037
+
2038
+ export class ProjectUser extends S.Struct({
2039
+ "object": S.Literal("organization.project.user"),
2040
+ "id": S.String,
2041
+ "name": S.String,
2042
+ "email": S.String,
2043
+ "role": S.Literal("owner", "member"),
2044
+ "added_at": S.Int
2045
+ }) {}
2046
+
2047
+ export class ProjectUserListResponse extends S.Class<ProjectUserListResponse>("ProjectUserListResponse")({
2048
+ "object": S.String,
2049
+ "data": S.Array(ProjectUser),
2050
+ "first_id": S.String,
2051
+ "last_id": S.String,
2052
+ "has_more": S.Boolean
2053
+ }) {}
2054
+
2055
+ export class ProjectUserCreateRequest extends S.Class<ProjectUserCreateRequest>("ProjectUserCreateRequest")({
2056
+ "user_id": S.String,
2057
+ "role": S.Literal("owner", "member")
2058
+ }) {}
2059
+
2060
+ export class ProjectUserUpdateRequest extends S.Class<ProjectUserUpdateRequest>("ProjectUserUpdateRequest")({
2061
+ "role": S.Literal("owner", "member")
2062
+ }) {}
2063
+
2064
+ export class ProjectUserDeleteResponse extends S.Class<ProjectUserDeleteResponse>("ProjectUserDeleteResponse")({
2065
+ "object": S.Literal("organization.project.user.deleted"),
2066
+ "id": S.String,
2067
+ "deleted": S.Boolean
2068
+ }) {}
2069
+
2070
+ export class ListProjectServiceAccountsParams extends S.Struct({
2071
+ "limit": S.optionalWith(S.Int, { default: () => 20 as const }),
2072
+ "after": S.optional(S.String)
2073
+ }) {}
2074
+
2075
+ export class ProjectServiceAccount extends S.Struct({
2076
+ "object": S.Literal("organization.project.service_account"),
2077
+ "id": S.String,
2078
+ "name": S.String,
2079
+ "role": S.Literal("owner", "member"),
2080
+ "created_at": S.Int
2081
+ }) {}
2082
+
2083
+ export class ProjectServiceAccountListResponse
2084
+ extends S.Class<ProjectServiceAccountListResponse>("ProjectServiceAccountListResponse")({
2085
+ "object": S.Literal("list"),
2086
+ "data": S.Array(ProjectServiceAccount),
2087
+ "first_id": S.String,
2088
+ "last_id": S.String,
2089
+ "has_more": S.Boolean
2090
+ })
2091
+ {}
2092
+
2093
+ export class ProjectServiceAccountCreateRequest
2094
+ extends S.Class<ProjectServiceAccountCreateRequest>("ProjectServiceAccountCreateRequest")({
2095
+ "name": S.String
2096
+ })
2097
+ {}
2098
+
2099
+ export class ProjectServiceAccountApiKey extends S.Struct({
2100
+ "object": S.Literal("organization.project.service_account.api_key"),
2101
+ "value": S.String,
2102
+ "name": S.String,
2103
+ "created_at": S.Int,
2104
+ "id": S.String
2105
+ }) {}
2106
+
2107
+ export class ProjectServiceAccountCreateResponse
2108
+ extends S.Class<ProjectServiceAccountCreateResponse>("ProjectServiceAccountCreateResponse")({
2109
+ "object": S.Literal("organization.project.service_account"),
2110
+ "id": S.String,
2111
+ "name": S.String,
2112
+ "role": S.Literal("member"),
2113
+ "created_at": S.Int,
2114
+ "api_key": ProjectServiceAccountApiKey
2115
+ })
2116
+ {}
2117
+
2118
+ export class ProjectServiceAccountDeleteResponse
2119
+ extends S.Class<ProjectServiceAccountDeleteResponse>("ProjectServiceAccountDeleteResponse")({
2120
+ "object": S.Literal("organization.project.service_account.deleted"),
2121
+ "id": S.String,
2122
+ "deleted": S.Boolean
2123
+ })
2124
+ {}
2125
+
2126
+ export class ListProjectApiKeysParams extends S.Struct({
2127
+ "limit": S.optionalWith(S.Int, { default: () => 20 as const }),
2128
+ "after": S.optional(S.String)
2129
+ }) {}
2130
+
2131
+ export class ProjectApiKey extends S.Struct({
2132
+ "object": S.Literal("organization.project.api_key"),
2133
+ "redacted_value": S.String,
2134
+ "name": S.String,
2135
+ "created_at": S.Int,
2136
+ "id": S.String,
2137
+ "owner": S.Struct({
2138
+ "type": S.optional(S.Literal("user", "service_account")),
2139
+ "user": S.optional(ProjectUser),
2140
+ "service_account": S.optional(ProjectServiceAccount)
2141
+ })
2142
+ }) {}
2143
+
2144
+ export class ProjectApiKeyListResponse extends S.Class<ProjectApiKeyListResponse>("ProjectApiKeyListResponse")({
2145
+ "object": S.Literal("list"),
2146
+ "data": S.Array(ProjectApiKey),
2147
+ "first_id": S.String,
2148
+ "last_id": S.String,
2149
+ "has_more": S.Boolean
2150
+ }) {}
2151
+
2152
+ export class ProjectApiKeyDeleteResponse extends S.Class<ProjectApiKeyDeleteResponse>("ProjectApiKeyDeleteResponse")({
2153
+ "object": S.Literal("organization.project.api_key.deleted"),
2154
+ "id": S.String,
2155
+ "deleted": S.Boolean
2156
+ }) {}
2157
+
2158
+ export const make = (httpClient: HttpClient.HttpClient): Client => {
2159
+ const unexpectedStatus = (
2160
+ request: HttpClientRequest.HttpClientRequest,
2161
+ response: HttpClientResponse.HttpClientResponse
2162
+ ) =>
2163
+ Effect.flatMap(
2164
+ Effect.orElseSucceed(response.text, () => "Unexpected status code"),
2165
+ (description) =>
2166
+ Effect.fail(
2167
+ new HttpClientError.ResponseError({
2168
+ request,
2169
+ response,
2170
+ reason: "StatusCode",
2171
+ description
2172
+ })
2173
+ )
2174
+ )
2175
+ const decodeError = <A, I, R>(response: HttpClientResponse.HttpClientResponse, schema: S.Schema<A, I, R>) =>
2176
+ Effect.flatMap(HttpClientResponse.schemaBodyJson(schema)(response), Effect.fail)
2177
+ return {
2178
+ "createChatCompletion": (options) =>
2179
+ HttpClientRequest.make("POST")(`/chat/completions`).pipe(
2180
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
2181
+ Effect.flatMap((request) =>
2182
+ Effect.flatMap(
2183
+ httpClient.execute(request),
2184
+ HttpClientResponse.matchStatus({
2185
+ "200": (r) => HttpClientResponse.schemaBodyJson(CreateChatCompletionResponse)(r),
2186
+ orElse: (response) => unexpectedStatus(request, response)
2187
+ })
2188
+ )
2189
+ ),
2190
+ Effect.scoped
2191
+ ),
2192
+ "createCompletion": (options) =>
2193
+ HttpClientRequest.make("POST")(`/completions`).pipe(
2194
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
2195
+ Effect.flatMap((request) =>
2196
+ Effect.flatMap(
2197
+ httpClient.execute(request),
2198
+ HttpClientResponse.matchStatus({
2199
+ "200": (r) => HttpClientResponse.schemaBodyJson(CreateCompletionResponse)(r),
2200
+ orElse: (response) => unexpectedStatus(request, response)
2201
+ })
2202
+ )
2203
+ ),
2204
+ Effect.scoped
2205
+ ),
2206
+ "createImage": (options) =>
2207
+ HttpClientRequest.make("POST")(`/images/generations`).pipe(
2208
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
2209
+ Effect.flatMap((request) =>
2210
+ Effect.flatMap(
2211
+ httpClient.execute(request),
2212
+ HttpClientResponse.matchStatus({
2213
+ "200": (r) => HttpClientResponse.schemaBodyJson(ImagesResponse)(r),
2214
+ orElse: (response) => unexpectedStatus(request, response)
2215
+ })
2216
+ )
2217
+ ),
2218
+ Effect.scoped
2219
+ ),
2220
+ "createImageEdit": (options) =>
2221
+ HttpClientRequest.make("POST")(`/images/edits`).pipe(
2222
+ HttpClientRequest.bodyFormData(options),
2223
+ Effect.succeed,
2224
+ Effect.flatMap((request) =>
2225
+ Effect.flatMap(
2226
+ httpClient.execute(request),
2227
+ HttpClientResponse.matchStatus({
2228
+ "200": (r) => HttpClientResponse.schemaBodyJson(ImagesResponse)(r),
2229
+ orElse: (response) => unexpectedStatus(request, response)
2230
+ })
2231
+ )
2232
+ ),
2233
+ Effect.scoped
2234
+ ),
2235
+ "createImageVariation": (options) =>
2236
+ HttpClientRequest.make("POST")(`/images/variations`).pipe(
2237
+ HttpClientRequest.bodyFormData(options),
2238
+ Effect.succeed,
2239
+ Effect.flatMap((request) =>
2240
+ Effect.flatMap(
2241
+ httpClient.execute(request),
2242
+ HttpClientResponse.matchStatus({
2243
+ "200": (r) => HttpClientResponse.schemaBodyJson(ImagesResponse)(r),
2244
+ orElse: (response) => unexpectedStatus(request, response)
2245
+ })
2246
+ )
2247
+ ),
2248
+ Effect.scoped
2249
+ ),
2250
+ "createEmbedding": (options) =>
2251
+ HttpClientRequest.make("POST")(`/embeddings`).pipe(
2252
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
2253
+ Effect.flatMap((request) =>
2254
+ Effect.flatMap(
2255
+ httpClient.execute(request),
2256
+ HttpClientResponse.matchStatus({
2257
+ "200": (r) => HttpClientResponse.schemaBodyJson(CreateEmbeddingResponse)(r),
2258
+ orElse: (response) => unexpectedStatus(request, response)
2259
+ })
2260
+ )
2261
+ ),
2262
+ Effect.scoped
2263
+ ),
2264
+ "createSpeech": (options) =>
2265
+ HttpClientRequest.make("POST")(`/audio/speech`).pipe(
2266
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
2267
+ Effect.flatMap((request) =>
2268
+ Effect.flatMap(
2269
+ httpClient.execute(request),
2270
+ HttpClientResponse.matchStatus({
2271
+ orElse: (response) => unexpectedStatus(request, response)
2272
+ })
2273
+ )
2274
+ ),
2275
+ Effect.scoped
2276
+ ),
2277
+ "createTranscription": (options) =>
2278
+ HttpClientRequest.make("POST")(`/audio/transcriptions`).pipe(
2279
+ HttpClientRequest.bodyFormData(options),
2280
+ Effect.succeed,
2281
+ Effect.flatMap((request) =>
2282
+ Effect.flatMap(
2283
+ httpClient.execute(request),
2284
+ HttpClientResponse.matchStatus({
2285
+ "200": (r) => HttpClientResponse.schemaBodyJson(CreateTranscription200)(r),
2286
+ orElse: (response) => unexpectedStatus(request, response)
2287
+ })
2288
+ )
2289
+ ),
2290
+ Effect.scoped
2291
+ ),
2292
+ "createTranslation": (options) =>
2293
+ HttpClientRequest.make("POST")(`/audio/translations`).pipe(
2294
+ HttpClientRequest.bodyFormData(options),
2295
+ Effect.succeed,
2296
+ Effect.flatMap((request) =>
2297
+ Effect.flatMap(
2298
+ httpClient.execute(request),
2299
+ HttpClientResponse.matchStatus({
2300
+ "200": (r) => HttpClientResponse.schemaBodyJson(CreateTranslation200)(r),
2301
+ orElse: (response) => unexpectedStatus(request, response)
2302
+ })
2303
+ )
2304
+ ),
2305
+ Effect.scoped
2306
+ ),
2307
+ "listFiles": (options) =>
2308
+ HttpClientRequest.make("GET")(`/files`).pipe(
2309
+ HttpClientRequest.setUrlParams({ "purpose": options["purpose"] }),
2310
+ Effect.succeed,
2311
+ Effect.flatMap((request) =>
2312
+ Effect.flatMap(
2313
+ httpClient.execute(request),
2314
+ HttpClientResponse.matchStatus({
2315
+ "200": (r) => HttpClientResponse.schemaBodyJson(ListFilesResponse)(r),
2316
+ orElse: (response) => unexpectedStatus(request, response)
2317
+ })
2318
+ )
2319
+ ),
2320
+ Effect.scoped
2321
+ ),
2322
+ "createFile": (options) =>
2323
+ HttpClientRequest.make("POST")(`/files`).pipe(
2324
+ HttpClientRequest.bodyFormData(options),
2325
+ Effect.succeed,
2326
+ Effect.flatMap((request) =>
2327
+ Effect.flatMap(
2328
+ httpClient.execute(request),
2329
+ HttpClientResponse.matchStatus({
2330
+ "200": (r) => HttpClientResponse.schemaBodyJson(OpenAIFile)(r),
2331
+ orElse: (response) => unexpectedStatus(request, response)
2332
+ })
2333
+ )
2334
+ ),
2335
+ Effect.scoped
2336
+ ),
2337
+ "retrieveFile": (fileId) =>
2338
+ HttpClientRequest.make("GET")(`/files/${fileId}`).pipe(
2339
+ Effect.succeed,
2340
+ Effect.flatMap((request) =>
2341
+ Effect.flatMap(
2342
+ httpClient.execute(request),
2343
+ HttpClientResponse.matchStatus({
2344
+ "200": (r) => HttpClientResponse.schemaBodyJson(OpenAIFile)(r),
2345
+ orElse: (response) => unexpectedStatus(request, response)
2346
+ })
2347
+ )
2348
+ ),
2349
+ Effect.scoped
2350
+ ),
2351
+ "deleteFile": (fileId) =>
2352
+ HttpClientRequest.make("DELETE")(`/files/${fileId}`).pipe(
2353
+ Effect.succeed,
2354
+ Effect.flatMap((request) =>
2355
+ Effect.flatMap(
2356
+ httpClient.execute(request),
2357
+ HttpClientResponse.matchStatus({
2358
+ "200": (r) => HttpClientResponse.schemaBodyJson(DeleteFileResponse)(r),
2359
+ orElse: (response) => unexpectedStatus(request, response)
2360
+ })
2361
+ )
2362
+ ),
2363
+ Effect.scoped
2364
+ ),
2365
+ "downloadFile": (fileId) =>
2366
+ HttpClientRequest.make("GET")(`/files/${fileId}/content`).pipe(
2367
+ Effect.succeed,
2368
+ Effect.flatMap((request) =>
2369
+ Effect.flatMap(
2370
+ httpClient.execute(request),
2371
+ HttpClientResponse.matchStatus({
2372
+ "200": (r) => HttpClientResponse.schemaBodyJson(DownloadFile200)(r),
2373
+ orElse: (response) => unexpectedStatus(request, response)
2374
+ })
2375
+ )
2376
+ ),
2377
+ Effect.scoped
2378
+ ),
2379
+ "createUpload": (options) =>
2380
+ HttpClientRequest.make("POST")(`/uploads`).pipe(
2381
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
2382
+ Effect.flatMap((request) =>
2383
+ Effect.flatMap(
2384
+ httpClient.execute(request),
2385
+ HttpClientResponse.matchStatus({
2386
+ "200": (r) => HttpClientResponse.schemaBodyJson(Upload)(r),
2387
+ orElse: (response) => unexpectedStatus(request, response)
2388
+ })
2389
+ )
2390
+ ),
2391
+ Effect.scoped
2392
+ ),
2393
+ "addUploadPart": (uploadId, options) =>
2394
+ HttpClientRequest.make("POST")(`/uploads/${uploadId}/parts`).pipe(
2395
+ HttpClientRequest.bodyFormData(options),
2396
+ Effect.succeed,
2397
+ Effect.flatMap((request) =>
2398
+ Effect.flatMap(
2399
+ httpClient.execute(request),
2400
+ HttpClientResponse.matchStatus({
2401
+ "200": (r) => HttpClientResponse.schemaBodyJson(UploadPart)(r),
2402
+ orElse: (response) => unexpectedStatus(request, response)
2403
+ })
2404
+ )
2405
+ ),
2406
+ Effect.scoped
2407
+ ),
2408
+ "completeUpload": (uploadId, options) =>
2409
+ HttpClientRequest.make("POST")(`/uploads/${uploadId}/complete`).pipe(
2410
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
2411
+ Effect.flatMap((request) =>
2412
+ Effect.flatMap(
2413
+ httpClient.execute(request),
2414
+ HttpClientResponse.matchStatus({
2415
+ "200": (r) => HttpClientResponse.schemaBodyJson(Upload)(r),
2416
+ orElse: (response) => unexpectedStatus(request, response)
2417
+ })
2418
+ )
2419
+ ),
2420
+ Effect.scoped
2421
+ ),
2422
+ "cancelUpload": (uploadId) =>
2423
+ HttpClientRequest.make("POST")(`/uploads/${uploadId}/cancel`).pipe(
2424
+ Effect.succeed,
2425
+ Effect.flatMap((request) =>
2426
+ Effect.flatMap(
2427
+ httpClient.execute(request),
2428
+ HttpClientResponse.matchStatus({
2429
+ "200": (r) => HttpClientResponse.schemaBodyJson(Upload)(r),
2430
+ orElse: (response) => unexpectedStatus(request, response)
2431
+ })
2432
+ )
2433
+ ),
2434
+ Effect.scoped
2435
+ ),
2436
+ "listPaginatedFineTuningJobs": (options) =>
2437
+ HttpClientRequest.make("GET")(`/fine_tuning/jobs`).pipe(
2438
+ HttpClientRequest.setUrlParams({ "after": options["after"], "limit": options["limit"] }),
2439
+ Effect.succeed,
2440
+ Effect.flatMap((request) =>
2441
+ Effect.flatMap(
2442
+ httpClient.execute(request),
2443
+ HttpClientResponse.matchStatus({
2444
+ "200": (r) => HttpClientResponse.schemaBodyJson(ListPaginatedFineTuningJobsResponse)(r),
2445
+ orElse: (response) => unexpectedStatus(request, response)
2446
+ })
2447
+ )
2448
+ ),
2449
+ Effect.scoped
2450
+ ),
2451
+ "createFineTuningJob": (options) =>
2452
+ HttpClientRequest.make("POST")(`/fine_tuning/jobs`).pipe(
2453
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
2454
+ Effect.flatMap((request) =>
2455
+ Effect.flatMap(
2456
+ httpClient.execute(request),
2457
+ HttpClientResponse.matchStatus({
2458
+ "200": (r) => HttpClientResponse.schemaBodyJson(FineTuningJob)(r),
2459
+ orElse: (response) => unexpectedStatus(request, response)
2460
+ })
2461
+ )
2462
+ ),
2463
+ Effect.scoped
2464
+ ),
2465
+ "retrieveFineTuningJob": (fineTuningJobId) =>
2466
+ HttpClientRequest.make("GET")(`/fine_tuning/jobs/${fineTuningJobId}`).pipe(
2467
+ Effect.succeed,
2468
+ Effect.flatMap((request) =>
2469
+ Effect.flatMap(
2470
+ httpClient.execute(request),
2471
+ HttpClientResponse.matchStatus({
2472
+ "200": (r) => HttpClientResponse.schemaBodyJson(FineTuningJob)(r),
2473
+ orElse: (response) => unexpectedStatus(request, response)
2474
+ })
2475
+ )
2476
+ ),
2477
+ Effect.scoped
2478
+ ),
2479
+ "listFineTuningEvents": (fineTuningJobId, options) =>
2480
+ HttpClientRequest.make("GET")(`/fine_tuning/jobs/${fineTuningJobId}/events`).pipe(
2481
+ HttpClientRequest.setUrlParams({ "after": options["after"], "limit": options["limit"] }),
2482
+ Effect.succeed,
2483
+ Effect.flatMap((request) =>
2484
+ Effect.flatMap(
2485
+ httpClient.execute(request),
2486
+ HttpClientResponse.matchStatus({
2487
+ "200": (r) => HttpClientResponse.schemaBodyJson(ListFineTuningJobEventsResponse)(r),
2488
+ orElse: (response) => unexpectedStatus(request, response)
2489
+ })
2490
+ )
2491
+ ),
2492
+ Effect.scoped
2493
+ ),
2494
+ "cancelFineTuningJob": (fineTuningJobId) =>
2495
+ HttpClientRequest.make("POST")(`/fine_tuning/jobs/${fineTuningJobId}/cancel`).pipe(
2496
+ Effect.succeed,
2497
+ Effect.flatMap((request) =>
2498
+ Effect.flatMap(
2499
+ httpClient.execute(request),
2500
+ HttpClientResponse.matchStatus({
2501
+ "200": (r) => HttpClientResponse.schemaBodyJson(FineTuningJob)(r),
2502
+ orElse: (response) => unexpectedStatus(request, response)
2503
+ })
2504
+ )
2505
+ ),
2506
+ Effect.scoped
2507
+ ),
2508
+ "listFineTuningJobCheckpoints": (fineTuningJobId, options) =>
2509
+ HttpClientRequest.make("GET")(`/fine_tuning/jobs/${fineTuningJobId}/checkpoints`).pipe(
2510
+ HttpClientRequest.setUrlParams({ "after": options["after"], "limit": options["limit"] }),
2511
+ Effect.succeed,
2512
+ Effect.flatMap((request) =>
2513
+ Effect.flatMap(
2514
+ httpClient.execute(request),
2515
+ HttpClientResponse.matchStatus({
2516
+ "200": (r) => HttpClientResponse.schemaBodyJson(ListFineTuningJobCheckpointsResponse)(r),
2517
+ orElse: (response) => unexpectedStatus(request, response)
2518
+ })
2519
+ )
2520
+ ),
2521
+ Effect.scoped
2522
+ ),
2523
+ "listModels": () =>
2524
+ HttpClientRequest.make("GET")(`/models`).pipe(
2525
+ Effect.succeed,
2526
+ Effect.flatMap((request) =>
2527
+ Effect.flatMap(
2528
+ httpClient.execute(request),
2529
+ HttpClientResponse.matchStatus({
2530
+ "200": (r) => HttpClientResponse.schemaBodyJson(ListModelsResponse)(r),
2531
+ orElse: (response) => unexpectedStatus(request, response)
2532
+ })
2533
+ )
2534
+ ),
2535
+ Effect.scoped
2536
+ ),
2537
+ "retrieveModel": (model) =>
2538
+ HttpClientRequest.make("GET")(`/models/${model}`).pipe(
2539
+ Effect.succeed,
2540
+ Effect.flatMap((request) =>
2541
+ Effect.flatMap(
2542
+ httpClient.execute(request),
2543
+ HttpClientResponse.matchStatus({
2544
+ "200": (r) => HttpClientResponse.schemaBodyJson(Model)(r),
2545
+ orElse: (response) => unexpectedStatus(request, response)
2546
+ })
2547
+ )
2548
+ ),
2549
+ Effect.scoped
2550
+ ),
2551
+ "deleteModel": (model) =>
2552
+ HttpClientRequest.make("DELETE")(`/models/${model}`).pipe(
2553
+ Effect.succeed,
2554
+ Effect.flatMap((request) =>
2555
+ Effect.flatMap(
2556
+ httpClient.execute(request),
2557
+ HttpClientResponse.matchStatus({
2558
+ "200": (r) => HttpClientResponse.schemaBodyJson(DeleteModelResponse)(r),
2559
+ orElse: (response) => unexpectedStatus(request, response)
2560
+ })
2561
+ )
2562
+ ),
2563
+ Effect.scoped
2564
+ ),
2565
+ "createModeration": (options) =>
2566
+ HttpClientRequest.make("POST")(`/moderations`).pipe(
2567
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
2568
+ Effect.flatMap((request) =>
2569
+ Effect.flatMap(
2570
+ httpClient.execute(request),
2571
+ HttpClientResponse.matchStatus({
2572
+ "200": (r) => HttpClientResponse.schemaBodyJson(CreateModerationResponse)(r),
2573
+ orElse: (response) => unexpectedStatus(request, response)
2574
+ })
2575
+ )
2576
+ ),
2577
+ Effect.scoped
2578
+ ),
2579
+ "listAssistants": (options) =>
2580
+ HttpClientRequest.make("GET")(`/assistants`).pipe(
2581
+ HttpClientRequest.setUrlParams({
2582
+ "limit": options["limit"],
2583
+ "order": options["order"],
2584
+ "after": options["after"],
2585
+ "before": options["before"]
2586
+ }),
2587
+ Effect.succeed,
2588
+ Effect.flatMap((request) =>
2589
+ Effect.flatMap(
2590
+ httpClient.execute(request),
2591
+ HttpClientResponse.matchStatus({
2592
+ "200": (r) => HttpClientResponse.schemaBodyJson(ListAssistantsResponse)(r),
2593
+ orElse: (response) => unexpectedStatus(request, response)
2594
+ })
2595
+ )
2596
+ ),
2597
+ Effect.scoped
2598
+ ),
2599
+ "createAssistant": (options) =>
2600
+ HttpClientRequest.make("POST")(`/assistants`).pipe(
2601
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
2602
+ Effect.flatMap((request) =>
2603
+ Effect.flatMap(
2604
+ httpClient.execute(request),
2605
+ HttpClientResponse.matchStatus({
2606
+ "200": (r) => HttpClientResponse.schemaBodyJson(AssistantObject)(r),
2607
+ orElse: (response) => unexpectedStatus(request, response)
2608
+ })
2609
+ )
2610
+ ),
2611
+ Effect.scoped
2612
+ ),
2613
+ "getAssistant": (assistantId) =>
2614
+ HttpClientRequest.make("GET")(`/assistants/${assistantId}`).pipe(
2615
+ Effect.succeed,
2616
+ Effect.flatMap((request) =>
2617
+ Effect.flatMap(
2618
+ httpClient.execute(request),
2619
+ HttpClientResponse.matchStatus({
2620
+ "200": (r) => HttpClientResponse.schemaBodyJson(AssistantObject)(r),
2621
+ orElse: (response) => unexpectedStatus(request, response)
2622
+ })
2623
+ )
2624
+ ),
2625
+ Effect.scoped
2626
+ ),
2627
+ "modifyAssistant": (assistantId, options) =>
2628
+ HttpClientRequest.make("POST")(`/assistants/${assistantId}`).pipe(
2629
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
2630
+ Effect.flatMap((request) =>
2631
+ Effect.flatMap(
2632
+ httpClient.execute(request),
2633
+ HttpClientResponse.matchStatus({
2634
+ "200": (r) => HttpClientResponse.schemaBodyJson(AssistantObject)(r),
2635
+ orElse: (response) => unexpectedStatus(request, response)
2636
+ })
2637
+ )
2638
+ ),
2639
+ Effect.scoped
2640
+ ),
2641
+ "deleteAssistant": (assistantId) =>
2642
+ HttpClientRequest.make("DELETE")(`/assistants/${assistantId}`).pipe(
2643
+ Effect.succeed,
2644
+ Effect.flatMap((request) =>
2645
+ Effect.flatMap(
2646
+ httpClient.execute(request),
2647
+ HttpClientResponse.matchStatus({
2648
+ "200": (r) => HttpClientResponse.schemaBodyJson(DeleteAssistantResponse)(r),
2649
+ orElse: (response) => unexpectedStatus(request, response)
2650
+ })
2651
+ )
2652
+ ),
2653
+ Effect.scoped
2654
+ ),
2655
+ "createThread": (options) =>
2656
+ HttpClientRequest.make("POST")(`/threads`).pipe(
2657
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
2658
+ Effect.flatMap((request) =>
2659
+ Effect.flatMap(
2660
+ httpClient.execute(request),
2661
+ HttpClientResponse.matchStatus({
2662
+ "200": (r) => HttpClientResponse.schemaBodyJson(ThreadObject)(r),
2663
+ orElse: (response) => unexpectedStatus(request, response)
2664
+ })
2665
+ )
2666
+ ),
2667
+ Effect.scoped
2668
+ ),
2669
+ "getThread": (threadId) =>
2670
+ HttpClientRequest.make("GET")(`/threads/${threadId}`).pipe(
2671
+ Effect.succeed,
2672
+ Effect.flatMap((request) =>
2673
+ Effect.flatMap(
2674
+ httpClient.execute(request),
2675
+ HttpClientResponse.matchStatus({
2676
+ "200": (r) => HttpClientResponse.schemaBodyJson(ThreadObject)(r),
2677
+ orElse: (response) => unexpectedStatus(request, response)
2678
+ })
2679
+ )
2680
+ ),
2681
+ Effect.scoped
2682
+ ),
2683
+ "modifyThread": (threadId, options) =>
2684
+ HttpClientRequest.make("POST")(`/threads/${threadId}`).pipe(
2685
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
2686
+ Effect.flatMap((request) =>
2687
+ Effect.flatMap(
2688
+ httpClient.execute(request),
2689
+ HttpClientResponse.matchStatus({
2690
+ "200": (r) => HttpClientResponse.schemaBodyJson(ThreadObject)(r),
2691
+ orElse: (response) => unexpectedStatus(request, response)
2692
+ })
2693
+ )
2694
+ ),
2695
+ Effect.scoped
2696
+ ),
2697
+ "deleteThread": (threadId) =>
2698
+ HttpClientRequest.make("DELETE")(`/threads/${threadId}`).pipe(
2699
+ Effect.succeed,
2700
+ Effect.flatMap((request) =>
2701
+ Effect.flatMap(
2702
+ httpClient.execute(request),
2703
+ HttpClientResponse.matchStatus({
2704
+ "200": (r) => HttpClientResponse.schemaBodyJson(DeleteThreadResponse)(r),
2705
+ orElse: (response) => unexpectedStatus(request, response)
2706
+ })
2707
+ )
2708
+ ),
2709
+ Effect.scoped
2710
+ ),
2711
+ "listMessages": (threadId, options) =>
2712
+ HttpClientRequest.make("GET")(`/threads/${threadId}/messages`).pipe(
2713
+ HttpClientRequest.setUrlParams({
2714
+ "limit": options["limit"],
2715
+ "order": options["order"],
2716
+ "after": options["after"],
2717
+ "before": options["before"],
2718
+ "run_id": options["run_id"]
2719
+ }),
2720
+ Effect.succeed,
2721
+ Effect.flatMap((request) =>
2722
+ Effect.flatMap(
2723
+ httpClient.execute(request),
2724
+ HttpClientResponse.matchStatus({
2725
+ "200": (r) => HttpClientResponse.schemaBodyJson(ListMessagesResponse)(r),
2726
+ orElse: (response) => unexpectedStatus(request, response)
2727
+ })
2728
+ )
2729
+ ),
2730
+ Effect.scoped
2731
+ ),
2732
+ "createMessage": (threadId, options) =>
2733
+ HttpClientRequest.make("POST")(`/threads/${threadId}/messages`).pipe(
2734
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
2735
+ Effect.flatMap((request) =>
2736
+ Effect.flatMap(
2737
+ httpClient.execute(request),
2738
+ HttpClientResponse.matchStatus({
2739
+ "200": (r) => HttpClientResponse.schemaBodyJson(MessageObject)(r),
2740
+ orElse: (response) => unexpectedStatus(request, response)
2741
+ })
2742
+ )
2743
+ ),
2744
+ Effect.scoped
2745
+ ),
2746
+ "getMessage": (threadId, messageId) =>
2747
+ HttpClientRequest.make("GET")(`/threads/${threadId}/messages/${messageId}`).pipe(
2748
+ Effect.succeed,
2749
+ Effect.flatMap((request) =>
2750
+ Effect.flatMap(
2751
+ httpClient.execute(request),
2752
+ HttpClientResponse.matchStatus({
2753
+ "200": (r) => HttpClientResponse.schemaBodyJson(MessageObject)(r),
2754
+ orElse: (response) => unexpectedStatus(request, response)
2755
+ })
2756
+ )
2757
+ ),
2758
+ Effect.scoped
2759
+ ),
2760
+ "modifyMessage": (threadId, messageId, options) =>
2761
+ HttpClientRequest.make("POST")(`/threads/${threadId}/messages/${messageId}`).pipe(
2762
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
2763
+ Effect.flatMap((request) =>
2764
+ Effect.flatMap(
2765
+ httpClient.execute(request),
2766
+ HttpClientResponse.matchStatus({
2767
+ "200": (r) => HttpClientResponse.schemaBodyJson(MessageObject)(r),
2768
+ orElse: (response) => unexpectedStatus(request, response)
2769
+ })
2770
+ )
2771
+ ),
2772
+ Effect.scoped
2773
+ ),
2774
+ "deleteMessage": (threadId, messageId) =>
2775
+ HttpClientRequest.make("DELETE")(`/threads/${threadId}/messages/${messageId}`).pipe(
2776
+ Effect.succeed,
2777
+ Effect.flatMap((request) =>
2778
+ Effect.flatMap(
2779
+ httpClient.execute(request),
2780
+ HttpClientResponse.matchStatus({
2781
+ "200": (r) => HttpClientResponse.schemaBodyJson(DeleteMessageResponse)(r),
2782
+ orElse: (response) => unexpectedStatus(request, response)
2783
+ })
2784
+ )
2785
+ ),
2786
+ Effect.scoped
2787
+ ),
2788
+ "createThreadAndRun": (options) =>
2789
+ HttpClientRequest.make("POST")(`/threads/runs`).pipe(
2790
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
2791
+ Effect.flatMap((request) =>
2792
+ Effect.flatMap(
2793
+ httpClient.execute(request),
2794
+ HttpClientResponse.matchStatus({
2795
+ "200": (r) => HttpClientResponse.schemaBodyJson(RunObject)(r),
2796
+ orElse: (response) => unexpectedStatus(request, response)
2797
+ })
2798
+ )
2799
+ ),
2800
+ Effect.scoped
2801
+ ),
2802
+ "listRuns": (threadId, options) =>
2803
+ HttpClientRequest.make("GET")(`/threads/${threadId}/runs`).pipe(
2804
+ HttpClientRequest.setUrlParams({
2805
+ "limit": options["limit"],
2806
+ "order": options["order"],
2807
+ "after": options["after"],
2808
+ "before": options["before"]
2809
+ }),
2810
+ Effect.succeed,
2811
+ Effect.flatMap((request) =>
2812
+ Effect.flatMap(
2813
+ httpClient.execute(request),
2814
+ HttpClientResponse.matchStatus({
2815
+ "200": (r) => HttpClientResponse.schemaBodyJson(ListRunsResponse)(r),
2816
+ orElse: (response) => unexpectedStatus(request, response)
2817
+ })
2818
+ )
2819
+ ),
2820
+ Effect.scoped
2821
+ ),
2822
+ "createRun": (threadId, options) =>
2823
+ HttpClientRequest.make("POST")(`/threads/${threadId}/runs`).pipe(
2824
+ HttpClientRequest.setUrlParams({ "include[]": options.params["include[]"] }),
2825
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options.payload)),
2826
+ Effect.flatMap((request) =>
2827
+ Effect.flatMap(
2828
+ httpClient.execute(request),
2829
+ HttpClientResponse.matchStatus({
2830
+ "200": (r) => HttpClientResponse.schemaBodyJson(RunObject)(r),
2831
+ orElse: (response) => unexpectedStatus(request, response)
2832
+ })
2833
+ )
2834
+ ),
2835
+ Effect.scoped
2836
+ ),
2837
+ "getRun": (threadId, runId) =>
2838
+ HttpClientRequest.make("GET")(`/threads/${threadId}/runs/${runId}`).pipe(
2839
+ Effect.succeed,
2840
+ Effect.flatMap((request) =>
2841
+ Effect.flatMap(
2842
+ httpClient.execute(request),
2843
+ HttpClientResponse.matchStatus({
2844
+ "200": (r) => HttpClientResponse.schemaBodyJson(RunObject)(r),
2845
+ orElse: (response) => unexpectedStatus(request, response)
2846
+ })
2847
+ )
2848
+ ),
2849
+ Effect.scoped
2850
+ ),
2851
+ "modifyRun": (threadId, runId, options) =>
2852
+ HttpClientRequest.make("POST")(`/threads/${threadId}/runs/${runId}`).pipe(
2853
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
2854
+ Effect.flatMap((request) =>
2855
+ Effect.flatMap(
2856
+ httpClient.execute(request),
2857
+ HttpClientResponse.matchStatus({
2858
+ "200": (r) => HttpClientResponse.schemaBodyJson(RunObject)(r),
2859
+ orElse: (response) => unexpectedStatus(request, response)
2860
+ })
2861
+ )
2862
+ ),
2863
+ Effect.scoped
2864
+ ),
2865
+ "submitToolOuputsToRun": (threadId, runId, options) =>
2866
+ HttpClientRequest.make("POST")(`/threads/${threadId}/runs/${runId}/submit_tool_outputs`).pipe(
2867
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
2868
+ Effect.flatMap((request) =>
2869
+ Effect.flatMap(
2870
+ httpClient.execute(request),
2871
+ HttpClientResponse.matchStatus({
2872
+ "200": (r) => HttpClientResponse.schemaBodyJson(RunObject)(r),
2873
+ orElse: (response) => unexpectedStatus(request, response)
2874
+ })
2875
+ )
2876
+ ),
2877
+ Effect.scoped
2878
+ ),
2879
+ "cancelRun": (threadId, runId) =>
2880
+ HttpClientRequest.make("POST")(`/threads/${threadId}/runs/${runId}/cancel`).pipe(
2881
+ Effect.succeed,
2882
+ Effect.flatMap((request) =>
2883
+ Effect.flatMap(
2884
+ httpClient.execute(request),
2885
+ HttpClientResponse.matchStatus({
2886
+ "200": (r) => HttpClientResponse.schemaBodyJson(RunObject)(r),
2887
+ orElse: (response) => unexpectedStatus(request, response)
2888
+ })
2889
+ )
2890
+ ),
2891
+ Effect.scoped
2892
+ ),
2893
+ "listRunSteps": (threadId, runId, options) =>
2894
+ HttpClientRequest.make("GET")(`/threads/${threadId}/runs/${runId}/steps`).pipe(
2895
+ HttpClientRequest.setUrlParams({
2896
+ "limit": options["limit"],
2897
+ "order": options["order"],
2898
+ "after": options["after"],
2899
+ "before": options["before"],
2900
+ "include[]": options["include[]"]
2901
+ }),
2902
+ Effect.succeed,
2903
+ Effect.flatMap((request) =>
2904
+ Effect.flatMap(
2905
+ httpClient.execute(request),
2906
+ HttpClientResponse.matchStatus({
2907
+ "200": (r) => HttpClientResponse.schemaBodyJson(ListRunStepsResponse)(r),
2908
+ orElse: (response) => unexpectedStatus(request, response)
2909
+ })
2910
+ )
2911
+ ),
2912
+ Effect.scoped
2913
+ ),
2914
+ "getRunStep": (threadId, runId, stepId, options) =>
2915
+ HttpClientRequest.make("GET")(`/threads/${threadId}/runs/${runId}/steps/${stepId}`).pipe(
2916
+ HttpClientRequest.setUrlParams({ "include[]": options["include[]"] }),
2917
+ Effect.succeed,
2918
+ Effect.flatMap((request) =>
2919
+ Effect.flatMap(
2920
+ httpClient.execute(request),
2921
+ HttpClientResponse.matchStatus({
2922
+ "200": (r) => HttpClientResponse.schemaBodyJson(RunStepObject)(r),
2923
+ orElse: (response) => unexpectedStatus(request, response)
2924
+ })
2925
+ )
2926
+ ),
2927
+ Effect.scoped
2928
+ ),
2929
+ "listVectorStores": (options) =>
2930
+ HttpClientRequest.make("GET")(`/vector_stores`).pipe(
2931
+ HttpClientRequest.setUrlParams({
2932
+ "limit": options["limit"],
2933
+ "order": options["order"],
2934
+ "after": options["after"],
2935
+ "before": options["before"]
2936
+ }),
2937
+ Effect.succeed,
2938
+ Effect.flatMap((request) =>
2939
+ Effect.flatMap(
2940
+ httpClient.execute(request),
2941
+ HttpClientResponse.matchStatus({
2942
+ "200": (r) => HttpClientResponse.schemaBodyJson(ListVectorStoresResponse)(r),
2943
+ orElse: (response) => unexpectedStatus(request, response)
2944
+ })
2945
+ )
2946
+ ),
2947
+ Effect.scoped
2948
+ ),
2949
+ "createVectorStore": (options) =>
2950
+ HttpClientRequest.make("POST")(`/vector_stores`).pipe(
2951
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
2952
+ Effect.flatMap((request) =>
2953
+ Effect.flatMap(
2954
+ httpClient.execute(request),
2955
+ HttpClientResponse.matchStatus({
2956
+ "200": (r) => HttpClientResponse.schemaBodyJson(VectorStoreObject)(r),
2957
+ orElse: (response) => unexpectedStatus(request, response)
2958
+ })
2959
+ )
2960
+ ),
2961
+ Effect.scoped
2962
+ ),
2963
+ "getVectorStore": (vectorStoreId) =>
2964
+ HttpClientRequest.make("GET")(`/vector_stores/${vectorStoreId}`).pipe(
2965
+ Effect.succeed,
2966
+ Effect.flatMap((request) =>
2967
+ Effect.flatMap(
2968
+ httpClient.execute(request),
2969
+ HttpClientResponse.matchStatus({
2970
+ "200": (r) => HttpClientResponse.schemaBodyJson(VectorStoreObject)(r),
2971
+ orElse: (response) => unexpectedStatus(request, response)
2972
+ })
2973
+ )
2974
+ ),
2975
+ Effect.scoped
2976
+ ),
2977
+ "modifyVectorStore": (vectorStoreId, options) =>
2978
+ HttpClientRequest.make("POST")(`/vector_stores/${vectorStoreId}`).pipe(
2979
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
2980
+ Effect.flatMap((request) =>
2981
+ Effect.flatMap(
2982
+ httpClient.execute(request),
2983
+ HttpClientResponse.matchStatus({
2984
+ "200": (r) => HttpClientResponse.schemaBodyJson(VectorStoreObject)(r),
2985
+ orElse: (response) => unexpectedStatus(request, response)
2986
+ })
2987
+ )
2988
+ ),
2989
+ Effect.scoped
2990
+ ),
2991
+ "deleteVectorStore": (vectorStoreId) =>
2992
+ HttpClientRequest.make("DELETE")(`/vector_stores/${vectorStoreId}`).pipe(
2993
+ Effect.succeed,
2994
+ Effect.flatMap((request) =>
2995
+ Effect.flatMap(
2996
+ httpClient.execute(request),
2997
+ HttpClientResponse.matchStatus({
2998
+ "200": (r) => HttpClientResponse.schemaBodyJson(DeleteVectorStoreResponse)(r),
2999
+ orElse: (response) => unexpectedStatus(request, response)
3000
+ })
3001
+ )
3002
+ ),
3003
+ Effect.scoped
3004
+ ),
3005
+ "listVectorStoreFiles": (vectorStoreId, options) =>
3006
+ HttpClientRequest.make("GET")(`/vector_stores/${vectorStoreId}/files`).pipe(
3007
+ HttpClientRequest.setUrlParams({
3008
+ "limit": options["limit"],
3009
+ "order": options["order"],
3010
+ "after": options["after"],
3011
+ "before": options["before"],
3012
+ "filter": options["filter"]
3013
+ }),
3014
+ Effect.succeed,
3015
+ Effect.flatMap((request) =>
3016
+ Effect.flatMap(
3017
+ httpClient.execute(request),
3018
+ HttpClientResponse.matchStatus({
3019
+ "200": (r) => HttpClientResponse.schemaBodyJson(ListVectorStoreFilesResponse)(r),
3020
+ orElse: (response) => unexpectedStatus(request, response)
3021
+ })
3022
+ )
3023
+ ),
3024
+ Effect.scoped
3025
+ ),
3026
+ "createVectorStoreFile": (vectorStoreId, options) =>
3027
+ HttpClientRequest.make("POST")(`/vector_stores/${vectorStoreId}/files`).pipe(
3028
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
3029
+ Effect.flatMap((request) =>
3030
+ Effect.flatMap(
3031
+ httpClient.execute(request),
3032
+ HttpClientResponse.matchStatus({
3033
+ "200": (r) => HttpClientResponse.schemaBodyJson(VectorStoreFileObject)(r),
3034
+ orElse: (response) => unexpectedStatus(request, response)
3035
+ })
3036
+ )
3037
+ ),
3038
+ Effect.scoped
3039
+ ),
3040
+ "getVectorStoreFile": (vectorStoreId, fileId) =>
3041
+ HttpClientRequest.make("GET")(`/vector_stores/${vectorStoreId}/files/${fileId}`).pipe(
3042
+ Effect.succeed,
3043
+ Effect.flatMap((request) =>
3044
+ Effect.flatMap(
3045
+ httpClient.execute(request),
3046
+ HttpClientResponse.matchStatus({
3047
+ "200": (r) => HttpClientResponse.schemaBodyJson(VectorStoreFileObject)(r),
3048
+ orElse: (response) => unexpectedStatus(request, response)
3049
+ })
3050
+ )
3051
+ ),
3052
+ Effect.scoped
3053
+ ),
3054
+ "deleteVectorStoreFile": (vectorStoreId, fileId) =>
3055
+ HttpClientRequest.make("DELETE")(`/vector_stores/${vectorStoreId}/files/${fileId}`).pipe(
3056
+ Effect.succeed,
3057
+ Effect.flatMap((request) =>
3058
+ Effect.flatMap(
3059
+ httpClient.execute(request),
3060
+ HttpClientResponse.matchStatus({
3061
+ "200": (r) => HttpClientResponse.schemaBodyJson(DeleteVectorStoreFileResponse)(r),
3062
+ orElse: (response) => unexpectedStatus(request, response)
3063
+ })
3064
+ )
3065
+ ),
3066
+ Effect.scoped
3067
+ ),
3068
+ "createVectorStoreFileBatch": (vectorStoreId, options) =>
3069
+ HttpClientRequest.make("POST")(`/vector_stores/${vectorStoreId}/file_batches`).pipe(
3070
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
3071
+ Effect.flatMap((request) =>
3072
+ Effect.flatMap(
3073
+ httpClient.execute(request),
3074
+ HttpClientResponse.matchStatus({
3075
+ "200": (r) => HttpClientResponse.schemaBodyJson(VectorStoreFileBatchObject)(r),
3076
+ orElse: (response) => unexpectedStatus(request, response)
3077
+ })
3078
+ )
3079
+ ),
3080
+ Effect.scoped
3081
+ ),
3082
+ "getVectorStoreFileBatch": (vectorStoreId, batchId) =>
3083
+ HttpClientRequest.make("GET")(`/vector_stores/${vectorStoreId}/file_batches/${batchId}`).pipe(
3084
+ Effect.succeed,
3085
+ Effect.flatMap((request) =>
3086
+ Effect.flatMap(
3087
+ httpClient.execute(request),
3088
+ HttpClientResponse.matchStatus({
3089
+ "200": (r) => HttpClientResponse.schemaBodyJson(VectorStoreFileBatchObject)(r),
3090
+ orElse: (response) => unexpectedStatus(request, response)
3091
+ })
3092
+ )
3093
+ ),
3094
+ Effect.scoped
3095
+ ),
3096
+ "cancelVectorStoreFileBatch": (vectorStoreId, batchId) =>
3097
+ HttpClientRequest.make("POST")(`/vector_stores/${vectorStoreId}/file_batches/${batchId}/cancel`).pipe(
3098
+ Effect.succeed,
3099
+ Effect.flatMap((request) =>
3100
+ Effect.flatMap(
3101
+ httpClient.execute(request),
3102
+ HttpClientResponse.matchStatus({
3103
+ "200": (r) => HttpClientResponse.schemaBodyJson(VectorStoreFileBatchObject)(r),
3104
+ orElse: (response) => unexpectedStatus(request, response)
3105
+ })
3106
+ )
3107
+ ),
3108
+ Effect.scoped
3109
+ ),
3110
+ "listFilesInVectorStoreBatch": (vectorStoreId, batchId, options) =>
3111
+ HttpClientRequest.make("GET")(`/vector_stores/${vectorStoreId}/file_batches/${batchId}/files`).pipe(
3112
+ HttpClientRequest.setUrlParams({
3113
+ "limit": options["limit"],
3114
+ "order": options["order"],
3115
+ "after": options["after"],
3116
+ "before": options["before"],
3117
+ "filter": options["filter"]
3118
+ }),
3119
+ Effect.succeed,
3120
+ Effect.flatMap((request) =>
3121
+ Effect.flatMap(
3122
+ httpClient.execute(request),
3123
+ HttpClientResponse.matchStatus({
3124
+ "200": (r) => HttpClientResponse.schemaBodyJson(ListVectorStoreFilesResponse)(r),
3125
+ orElse: (response) => unexpectedStatus(request, response)
3126
+ })
3127
+ )
3128
+ ),
3129
+ Effect.scoped
3130
+ ),
3131
+ "listBatches": (options) =>
3132
+ HttpClientRequest.make("GET")(`/batches`).pipe(
3133
+ HttpClientRequest.setUrlParams({ "after": options["after"], "limit": options["limit"] }),
3134
+ Effect.succeed,
3135
+ Effect.flatMap((request) =>
3136
+ Effect.flatMap(
3137
+ httpClient.execute(request),
3138
+ HttpClientResponse.matchStatus({
3139
+ "200": (r) => HttpClientResponse.schemaBodyJson(ListBatchesResponse)(r),
3140
+ orElse: (response) => unexpectedStatus(request, response)
3141
+ })
3142
+ )
3143
+ ),
3144
+ Effect.scoped
3145
+ ),
3146
+ "createBatch": (options) =>
3147
+ HttpClientRequest.make("POST")(`/batches`).pipe(
3148
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
3149
+ Effect.flatMap((request) =>
3150
+ Effect.flatMap(
3151
+ httpClient.execute(request),
3152
+ HttpClientResponse.matchStatus({
3153
+ "200": (r) => HttpClientResponse.schemaBodyJson(Batch)(r),
3154
+ orElse: (response) => unexpectedStatus(request, response)
3155
+ })
3156
+ )
3157
+ ),
3158
+ Effect.scoped
3159
+ ),
3160
+ "retrieveBatch": (batchId) =>
3161
+ HttpClientRequest.make("GET")(`/batches/${batchId}`).pipe(
3162
+ Effect.succeed,
3163
+ Effect.flatMap((request) =>
3164
+ Effect.flatMap(
3165
+ httpClient.execute(request),
3166
+ HttpClientResponse.matchStatus({
3167
+ "200": (r) => HttpClientResponse.schemaBodyJson(Batch)(r),
3168
+ orElse: (response) => unexpectedStatus(request, response)
3169
+ })
3170
+ )
3171
+ ),
3172
+ Effect.scoped
3173
+ ),
3174
+ "cancelBatch": (batchId) =>
3175
+ HttpClientRequest.make("POST")(`/batches/${batchId}/cancel`).pipe(
3176
+ Effect.succeed,
3177
+ Effect.flatMap((request) =>
3178
+ Effect.flatMap(
3179
+ httpClient.execute(request),
3180
+ HttpClientResponse.matchStatus({
3181
+ "200": (r) => HttpClientResponse.schemaBodyJson(Batch)(r),
3182
+ orElse: (response) => unexpectedStatus(request, response)
3183
+ })
3184
+ )
3185
+ ),
3186
+ Effect.scoped
3187
+ ),
3188
+ "listAuditLogs": (options) =>
3189
+ HttpClientRequest.make("GET")(`/organization/audit_logs`).pipe(
3190
+ HttpClientRequest.setUrlParams({
3191
+ "effective_at[gt]": options["effective_at[gt]"],
3192
+ "effective_at[gte]": options["effective_at[gte]"],
3193
+ "effective_at[lt]": options["effective_at[lt]"],
3194
+ "effective_at[lte]": options["effective_at[lte]"],
3195
+ "project_ids[]": options["project_ids[]"],
3196
+ "event_types[]": options["event_types[]"],
3197
+ "actor_ids[]": options["actor_ids[]"],
3198
+ "actor_emails[]": options["actor_emails[]"],
3199
+ "resource_ids[]": options["resource_ids[]"],
3200
+ "limit": options["limit"],
3201
+ "after": options["after"],
3202
+ "before": options["before"]
3203
+ }),
3204
+ Effect.succeed,
3205
+ Effect.flatMap((request) =>
3206
+ Effect.flatMap(
3207
+ httpClient.execute(request),
3208
+ HttpClientResponse.matchStatus({
3209
+ "200": (r) => HttpClientResponse.schemaBodyJson(ListAuditLogsResponse)(r),
3210
+ orElse: (response) => unexpectedStatus(request, response)
3211
+ })
3212
+ )
3213
+ ),
3214
+ Effect.scoped
3215
+ ),
3216
+ "listInvites": (options) =>
3217
+ HttpClientRequest.make("GET")(`/organization/invites`).pipe(
3218
+ HttpClientRequest.setUrlParams({ "limit": options["limit"], "after": options["after"] }),
3219
+ Effect.succeed,
3220
+ Effect.flatMap((request) =>
3221
+ Effect.flatMap(
3222
+ httpClient.execute(request),
3223
+ HttpClientResponse.matchStatus({
3224
+ "200": (r) => HttpClientResponse.schemaBodyJson(InviteListResponse)(r),
3225
+ orElse: (response) => unexpectedStatus(request, response)
3226
+ })
3227
+ )
3228
+ ),
3229
+ Effect.scoped
3230
+ ),
3231
+ "inviteUser": (options) =>
3232
+ HttpClientRequest.make("POST")(`/organization/invites`).pipe(
3233
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
3234
+ Effect.flatMap((request) =>
3235
+ Effect.flatMap(
3236
+ httpClient.execute(request),
3237
+ HttpClientResponse.matchStatus({
3238
+ "200": (r) => HttpClientResponse.schemaBodyJson(Invite)(r),
3239
+ orElse: (response) => unexpectedStatus(request, response)
3240
+ })
3241
+ )
3242
+ ),
3243
+ Effect.scoped
3244
+ ),
3245
+ "retrieveInvite": (inviteId) =>
3246
+ HttpClientRequest.make("GET")(`/organization/invites/${inviteId}`).pipe(
3247
+ Effect.succeed,
3248
+ Effect.flatMap((request) =>
3249
+ Effect.flatMap(
3250
+ httpClient.execute(request),
3251
+ HttpClientResponse.matchStatus({
3252
+ "200": (r) => HttpClientResponse.schemaBodyJson(Invite)(r),
3253
+ orElse: (response) => unexpectedStatus(request, response)
3254
+ })
3255
+ )
3256
+ ),
3257
+ Effect.scoped
3258
+ ),
3259
+ "deleteInvite": (inviteId) =>
3260
+ HttpClientRequest.make("DELETE")(`/organization/invites/${inviteId}`).pipe(
3261
+ Effect.succeed,
3262
+ Effect.flatMap((request) =>
3263
+ Effect.flatMap(
3264
+ httpClient.execute(request),
3265
+ HttpClientResponse.matchStatus({
3266
+ "200": (r) => HttpClientResponse.schemaBodyJson(InviteDeleteResponse)(r),
3267
+ orElse: (response) => unexpectedStatus(request, response)
3268
+ })
3269
+ )
3270
+ ),
3271
+ Effect.scoped
3272
+ ),
3273
+ "listUsers": (options) =>
3274
+ HttpClientRequest.make("GET")(`/organization/users`).pipe(
3275
+ HttpClientRequest.setUrlParams({ "limit": options["limit"], "after": options["after"] }),
3276
+ Effect.succeed,
3277
+ Effect.flatMap((request) =>
3278
+ Effect.flatMap(
3279
+ httpClient.execute(request),
3280
+ HttpClientResponse.matchStatus({
3281
+ "200": (r) => HttpClientResponse.schemaBodyJson(UserListResponse)(r),
3282
+ orElse: (response) => unexpectedStatus(request, response)
3283
+ })
3284
+ )
3285
+ ),
3286
+ Effect.scoped
3287
+ ),
3288
+ "retrieveUser": (userId) =>
3289
+ HttpClientRequest.make("GET")(`/organization/users/${userId}`).pipe(
3290
+ Effect.succeed,
3291
+ Effect.flatMap((request) =>
3292
+ Effect.flatMap(
3293
+ httpClient.execute(request),
3294
+ HttpClientResponse.matchStatus({
3295
+ "200": (r) => HttpClientResponse.schemaBodyJson(User)(r),
3296
+ orElse: (response) => unexpectedStatus(request, response)
3297
+ })
3298
+ )
3299
+ ),
3300
+ Effect.scoped
3301
+ ),
3302
+ "modifyUser": (userId, options) =>
3303
+ HttpClientRequest.make("POST")(`/organization/users/${userId}`).pipe(
3304
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
3305
+ Effect.flatMap((request) =>
3306
+ Effect.flatMap(
3307
+ httpClient.execute(request),
3308
+ HttpClientResponse.matchStatus({
3309
+ "200": (r) => HttpClientResponse.schemaBodyJson(User)(r),
3310
+ orElse: (response) => unexpectedStatus(request, response)
3311
+ })
3312
+ )
3313
+ ),
3314
+ Effect.scoped
3315
+ ),
3316
+ "deleteUser": (userId) =>
3317
+ HttpClientRequest.make("DELETE")(`/organization/users/${userId}`).pipe(
3318
+ Effect.succeed,
3319
+ Effect.flatMap((request) =>
3320
+ Effect.flatMap(
3321
+ httpClient.execute(request),
3322
+ HttpClientResponse.matchStatus({
3323
+ "200": (r) => HttpClientResponse.schemaBodyJson(UserDeleteResponse)(r),
3324
+ orElse: (response) => unexpectedStatus(request, response)
3325
+ })
3326
+ )
3327
+ ),
3328
+ Effect.scoped
3329
+ ),
3330
+ "listProjects": (options) =>
3331
+ HttpClientRequest.make("GET")(`/organization/projects`).pipe(
3332
+ HttpClientRequest.setUrlParams({
3333
+ "limit": options["limit"],
3334
+ "after": options["after"],
3335
+ "include_archived": options["include_archived"]
3336
+ }),
3337
+ Effect.succeed,
3338
+ Effect.flatMap((request) =>
3339
+ Effect.flatMap(
3340
+ httpClient.execute(request),
3341
+ HttpClientResponse.matchStatus({
3342
+ "200": (r) => HttpClientResponse.schemaBodyJson(ProjectListResponse)(r),
3343
+ orElse: (response) => unexpectedStatus(request, response)
3344
+ })
3345
+ )
3346
+ ),
3347
+ Effect.scoped
3348
+ ),
3349
+ "createProject": (options) =>
3350
+ HttpClientRequest.make("POST")(`/organization/projects`).pipe(
3351
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
3352
+ Effect.flatMap((request) =>
3353
+ Effect.flatMap(
3354
+ httpClient.execute(request),
3355
+ HttpClientResponse.matchStatus({
3356
+ "200": (r) => HttpClientResponse.schemaBodyJson(Project)(r),
3357
+ orElse: (response) => unexpectedStatus(request, response)
3358
+ })
3359
+ )
3360
+ ),
3361
+ Effect.scoped
3362
+ ),
3363
+ "retrieveProject": (projectId) =>
3364
+ HttpClientRequest.make("GET")(`/organization/projects/${projectId}`).pipe(
3365
+ Effect.succeed,
3366
+ Effect.flatMap((request) =>
3367
+ Effect.flatMap(
3368
+ httpClient.execute(request),
3369
+ HttpClientResponse.matchStatus({
3370
+ "200": (r) => HttpClientResponse.schemaBodyJson(Project)(r),
3371
+ orElse: (response) => unexpectedStatus(request, response)
3372
+ })
3373
+ )
3374
+ ),
3375
+ Effect.scoped
3376
+ ),
3377
+ "modifyProject": (projectId, options) =>
3378
+ HttpClientRequest.make("POST")(`/organization/projects/${projectId}`).pipe(
3379
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
3380
+ Effect.flatMap((request) =>
3381
+ Effect.flatMap(
3382
+ httpClient.execute(request),
3383
+ HttpClientResponse.matchStatus({
3384
+ "200": (r) => HttpClientResponse.schemaBodyJson(Project)(r),
3385
+ "400": (r) => decodeError(r, ErrorResponse),
3386
+ orElse: (response) => unexpectedStatus(request, response)
3387
+ })
3388
+ )
3389
+ ),
3390
+ Effect.scoped
3391
+ ),
3392
+ "archiveProject": (projectId) =>
3393
+ HttpClientRequest.make("POST")(`/organization/projects/${projectId}/archive`).pipe(
3394
+ Effect.succeed,
3395
+ Effect.flatMap((request) =>
3396
+ Effect.flatMap(
3397
+ httpClient.execute(request),
3398
+ HttpClientResponse.matchStatus({
3399
+ "200": (r) => HttpClientResponse.schemaBodyJson(Project)(r),
3400
+ orElse: (response) => unexpectedStatus(request, response)
3401
+ })
3402
+ )
3403
+ ),
3404
+ Effect.scoped
3405
+ ),
3406
+ "listProjectUsers": (projectId, options) =>
3407
+ HttpClientRequest.make("GET")(`/organization/projects/${projectId}/users`).pipe(
3408
+ HttpClientRequest.setUrlParams({ "limit": options["limit"], "after": options["after"] }),
3409
+ Effect.succeed,
3410
+ Effect.flatMap((request) =>
3411
+ Effect.flatMap(
3412
+ httpClient.execute(request),
3413
+ HttpClientResponse.matchStatus({
3414
+ "200": (r) => HttpClientResponse.schemaBodyJson(ProjectUserListResponse)(r),
3415
+ "400": (r) => decodeError(r, ErrorResponse),
3416
+ orElse: (response) => unexpectedStatus(request, response)
3417
+ })
3418
+ )
3419
+ ),
3420
+ Effect.scoped
3421
+ ),
3422
+ "createProjectUser": (projectId, options) =>
3423
+ HttpClientRequest.make("POST")(`/organization/projects/${projectId}/users`).pipe(
3424
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
3425
+ Effect.flatMap((request) =>
3426
+ Effect.flatMap(
3427
+ httpClient.execute(request),
3428
+ HttpClientResponse.matchStatus({
3429
+ "200": (r) => HttpClientResponse.schemaBodyJson(ProjectUser)(r),
3430
+ "400": (r) => decodeError(r, ErrorResponse),
3431
+ orElse: (response) => unexpectedStatus(request, response)
3432
+ })
3433
+ )
3434
+ ),
3435
+ Effect.scoped
3436
+ ),
3437
+ "retrieveProjectUser": (projectId, userId) =>
3438
+ HttpClientRequest.make("GET")(`/organization/projects/${projectId}/users/${userId}`).pipe(
3439
+ Effect.succeed,
3440
+ Effect.flatMap((request) =>
3441
+ Effect.flatMap(
3442
+ httpClient.execute(request),
3443
+ HttpClientResponse.matchStatus({
3444
+ "200": (r) => HttpClientResponse.schemaBodyJson(ProjectUser)(r),
3445
+ orElse: (response) => unexpectedStatus(request, response)
3446
+ })
3447
+ )
3448
+ ),
3449
+ Effect.scoped
3450
+ ),
3451
+ "modifyProjectUser": (projectId, userId, options) =>
3452
+ HttpClientRequest.make("POST")(`/organization/projects/${projectId}/users/${userId}`).pipe(
3453
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
3454
+ Effect.flatMap((request) =>
3455
+ Effect.flatMap(
3456
+ httpClient.execute(request),
3457
+ HttpClientResponse.matchStatus({
3458
+ "200": (r) => HttpClientResponse.schemaBodyJson(ProjectUser)(r),
3459
+ "400": (r) => decodeError(r, ErrorResponse),
3460
+ orElse: (response) => unexpectedStatus(request, response)
3461
+ })
3462
+ )
3463
+ ),
3464
+ Effect.scoped
3465
+ ),
3466
+ "deleteProjectUser": (projectId, userId) =>
3467
+ HttpClientRequest.make("DELETE")(`/organization/projects/${projectId}/users/${userId}`).pipe(
3468
+ Effect.succeed,
3469
+ Effect.flatMap((request) =>
3470
+ Effect.flatMap(
3471
+ httpClient.execute(request),
3472
+ HttpClientResponse.matchStatus({
3473
+ "200": (r) => HttpClientResponse.schemaBodyJson(ProjectUserDeleteResponse)(r),
3474
+ "400": (r) => decodeError(r, ErrorResponse),
3475
+ orElse: (response) => unexpectedStatus(request, response)
3476
+ })
3477
+ )
3478
+ ),
3479
+ Effect.scoped
3480
+ ),
3481
+ "listProjectServiceAccounts": (projectId, options) =>
3482
+ HttpClientRequest.make("GET")(`/organization/projects/${projectId}/service_accounts`).pipe(
3483
+ HttpClientRequest.setUrlParams({ "limit": options["limit"], "after": options["after"] }),
3484
+ Effect.succeed,
3485
+ Effect.flatMap((request) =>
3486
+ Effect.flatMap(
3487
+ httpClient.execute(request),
3488
+ HttpClientResponse.matchStatus({
3489
+ "200": (r) => HttpClientResponse.schemaBodyJson(ProjectServiceAccountListResponse)(r),
3490
+ "400": (r) => decodeError(r, ErrorResponse),
3491
+ orElse: (response) => unexpectedStatus(request, response)
3492
+ })
3493
+ )
3494
+ ),
3495
+ Effect.scoped
3496
+ ),
3497
+ "createProjectServiceAccount": (projectId, options) =>
3498
+ HttpClientRequest.make("POST")(`/organization/projects/${projectId}/service_accounts`).pipe(
3499
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options)),
3500
+ Effect.flatMap((request) =>
3501
+ Effect.flatMap(
3502
+ httpClient.execute(request),
3503
+ HttpClientResponse.matchStatus({
3504
+ "200": (r) => HttpClientResponse.schemaBodyJson(ProjectServiceAccountCreateResponse)(r),
3505
+ "400": (r) => decodeError(r, ErrorResponse),
3506
+ orElse: (response) => unexpectedStatus(request, response)
3507
+ })
3508
+ )
3509
+ ),
3510
+ Effect.scoped
3511
+ ),
3512
+ "retrieveProjectServiceAccount": (projectId, serviceAccountId) =>
3513
+ HttpClientRequest.make("GET")(`/organization/projects/${projectId}/service_accounts/${serviceAccountId}`).pipe(
3514
+ Effect.succeed,
3515
+ Effect.flatMap((request) =>
3516
+ Effect.flatMap(
3517
+ httpClient.execute(request),
3518
+ HttpClientResponse.matchStatus({
3519
+ "200": (r) => HttpClientResponse.schemaBodyJson(ProjectServiceAccount)(r),
3520
+ orElse: (response) => unexpectedStatus(request, response)
3521
+ })
3522
+ )
3523
+ ),
3524
+ Effect.scoped
3525
+ ),
3526
+ "deleteProjectServiceAccount": (projectId, serviceAccountId) =>
3527
+ HttpClientRequest.make("DELETE")(`/organization/projects/${projectId}/service_accounts/${serviceAccountId}`).pipe(
3528
+ Effect.succeed,
3529
+ Effect.flatMap((request) =>
3530
+ Effect.flatMap(
3531
+ httpClient.execute(request),
3532
+ HttpClientResponse.matchStatus({
3533
+ "200": (r) => HttpClientResponse.schemaBodyJson(ProjectServiceAccountDeleteResponse)(r),
3534
+ orElse: (response) => unexpectedStatus(request, response)
3535
+ })
3536
+ )
3537
+ ),
3538
+ Effect.scoped
3539
+ ),
3540
+ "listProjectApiKeys": (projectId, options) =>
3541
+ HttpClientRequest.make("GET")(`/organization/projects/${projectId}/api_keys`).pipe(
3542
+ HttpClientRequest.setUrlParams({ "limit": options["limit"], "after": options["after"] }),
3543
+ Effect.succeed,
3544
+ Effect.flatMap((request) =>
3545
+ Effect.flatMap(
3546
+ httpClient.execute(request),
3547
+ HttpClientResponse.matchStatus({
3548
+ "200": (r) => HttpClientResponse.schemaBodyJson(ProjectApiKeyListResponse)(r),
3549
+ orElse: (response) => unexpectedStatus(request, response)
3550
+ })
3551
+ )
3552
+ ),
3553
+ Effect.scoped
3554
+ ),
3555
+ "retrieveProjectApiKey": (projectId, keyId) =>
3556
+ HttpClientRequest.make("GET")(`/organization/projects/${projectId}/api_keys/${keyId}`).pipe(
3557
+ Effect.succeed,
3558
+ Effect.flatMap((request) =>
3559
+ Effect.flatMap(
3560
+ httpClient.execute(request),
3561
+ HttpClientResponse.matchStatus({
3562
+ "200": (r) => HttpClientResponse.schemaBodyJson(ProjectApiKey)(r),
3563
+ orElse: (response) => unexpectedStatus(request, response)
3564
+ })
3565
+ )
3566
+ ),
3567
+ Effect.scoped
3568
+ ),
3569
+ "deleteProjectApiKey": (projectId, keyId) =>
3570
+ HttpClientRequest.make("DELETE")(`/organization/projects/${projectId}/api_keys/${keyId}`).pipe(
3571
+ Effect.succeed,
3572
+ Effect.flatMap((request) =>
3573
+ Effect.flatMap(
3574
+ httpClient.execute(request),
3575
+ HttpClientResponse.matchStatus({
3576
+ "200": (r) => HttpClientResponse.schemaBodyJson(ProjectApiKeyDeleteResponse)(r),
3577
+ "400": (r) => decodeError(r, ErrorResponse),
3578
+ orElse: (response) => unexpectedStatus(request, response)
3579
+ })
3580
+ )
3581
+ ),
3582
+ Effect.scoped
3583
+ )
3584
+ }
3585
+ }
3586
+
3587
+ export interface Client {
3588
+ readonly "createChatCompletion": (
3589
+ options: typeof CreateChatCompletionRequest.Encoded
3590
+ ) => Effect.Effect<typeof CreateChatCompletionResponse.Type, HttpClientError.HttpClientError | ParseError>
3591
+ readonly "createCompletion": (
3592
+ options: typeof CreateCompletionRequest.Encoded
3593
+ ) => Effect.Effect<typeof CreateCompletionResponse.Type, HttpClientError.HttpClientError | ParseError>
3594
+ readonly "createImage": (
3595
+ options: typeof CreateImageRequest.Encoded
3596
+ ) => Effect.Effect<typeof ImagesResponse.Type, HttpClientError.HttpClientError | ParseError>
3597
+ readonly "createImageEdit": (
3598
+ options: globalThis.FormData
3599
+ ) => Effect.Effect<typeof ImagesResponse.Type, HttpClientError.HttpClientError | ParseError>
3600
+ readonly "createImageVariation": (
3601
+ options: globalThis.FormData
3602
+ ) => Effect.Effect<typeof ImagesResponse.Type, HttpClientError.HttpClientError | ParseError>
3603
+ readonly "createEmbedding": (
3604
+ options: typeof CreateEmbeddingRequest.Encoded
3605
+ ) => Effect.Effect<typeof CreateEmbeddingResponse.Type, HttpClientError.HttpClientError | ParseError>
3606
+ readonly "createSpeech": (
3607
+ options: typeof CreateSpeechRequest.Encoded
3608
+ ) => Effect.Effect<void, HttpClientError.HttpClientError | ParseError>
3609
+ readonly "createTranscription": (
3610
+ options: globalThis.FormData
3611
+ ) => Effect.Effect<typeof CreateTranscription200.Type, HttpClientError.HttpClientError | ParseError>
3612
+ readonly "createTranslation": (
3613
+ options: globalThis.FormData
3614
+ ) => Effect.Effect<typeof CreateTranslation200.Type, HttpClientError.HttpClientError | ParseError>
3615
+ readonly "listFiles": (
3616
+ options: typeof ListFilesParams.Encoded
3617
+ ) => Effect.Effect<typeof ListFilesResponse.Type, HttpClientError.HttpClientError | ParseError>
3618
+ readonly "createFile": (
3619
+ options: globalThis.FormData
3620
+ ) => Effect.Effect<typeof OpenAIFile.Type, HttpClientError.HttpClientError | ParseError>
3621
+ readonly "retrieveFile": (
3622
+ fileId: string
3623
+ ) => Effect.Effect<typeof OpenAIFile.Type, HttpClientError.HttpClientError | ParseError>
3624
+ readonly "deleteFile": (
3625
+ fileId: string
3626
+ ) => Effect.Effect<typeof DeleteFileResponse.Type, HttpClientError.HttpClientError | ParseError>
3627
+ readonly "downloadFile": (
3628
+ fileId: string
3629
+ ) => Effect.Effect<typeof DownloadFile200.Type, HttpClientError.HttpClientError | ParseError>
3630
+ readonly "createUpload": (
3631
+ options: typeof CreateUploadRequest.Encoded
3632
+ ) => Effect.Effect<typeof Upload.Type, HttpClientError.HttpClientError | ParseError>
3633
+ readonly "addUploadPart": (
3634
+ uploadId: string,
3635
+ options: globalThis.FormData
3636
+ ) => Effect.Effect<typeof UploadPart.Type, HttpClientError.HttpClientError | ParseError>
3637
+ readonly "completeUpload": (
3638
+ uploadId: string,
3639
+ options: typeof CompleteUploadRequest.Encoded
3640
+ ) => Effect.Effect<typeof Upload.Type, HttpClientError.HttpClientError | ParseError>
3641
+ readonly "cancelUpload": (
3642
+ uploadId: string
3643
+ ) => Effect.Effect<typeof Upload.Type, HttpClientError.HttpClientError | ParseError>
3644
+ readonly "listPaginatedFineTuningJobs": (
3645
+ options: typeof ListPaginatedFineTuningJobsParams.Encoded
3646
+ ) => Effect.Effect<typeof ListPaginatedFineTuningJobsResponse.Type, HttpClientError.HttpClientError | ParseError>
3647
+ readonly "createFineTuningJob": (
3648
+ options: typeof CreateFineTuningJobRequest.Encoded
3649
+ ) => Effect.Effect<typeof FineTuningJob.Type, HttpClientError.HttpClientError | ParseError>
3650
+ readonly "retrieveFineTuningJob": (
3651
+ fineTuningJobId: string
3652
+ ) => Effect.Effect<typeof FineTuningJob.Type, HttpClientError.HttpClientError | ParseError>
3653
+ readonly "listFineTuningEvents": (
3654
+ fineTuningJobId: string,
3655
+ options: typeof ListFineTuningEventsParams.Encoded
3656
+ ) => Effect.Effect<typeof ListFineTuningJobEventsResponse.Type, HttpClientError.HttpClientError | ParseError>
3657
+ readonly "cancelFineTuningJob": (
3658
+ fineTuningJobId: string
3659
+ ) => Effect.Effect<typeof FineTuningJob.Type, HttpClientError.HttpClientError | ParseError>
3660
+ readonly "listFineTuningJobCheckpoints": (
3661
+ fineTuningJobId: string,
3662
+ options: typeof ListFineTuningJobCheckpointsParams.Encoded
3663
+ ) => Effect.Effect<typeof ListFineTuningJobCheckpointsResponse.Type, HttpClientError.HttpClientError | ParseError>
3664
+ readonly "listModels": () => Effect.Effect<
3665
+ typeof ListModelsResponse.Type,
3666
+ HttpClientError.HttpClientError | ParseError
3667
+ >
3668
+ readonly "retrieveModel": (
3669
+ model: string
3670
+ ) => Effect.Effect<typeof Model.Type, HttpClientError.HttpClientError | ParseError>
3671
+ readonly "deleteModel": (
3672
+ model: string
3673
+ ) => Effect.Effect<typeof DeleteModelResponse.Type, HttpClientError.HttpClientError | ParseError>
3674
+ readonly "createModeration": (
3675
+ options: typeof CreateModerationRequest.Encoded
3676
+ ) => Effect.Effect<typeof CreateModerationResponse.Type, HttpClientError.HttpClientError | ParseError>
3677
+ readonly "listAssistants": (
3678
+ options: typeof ListAssistantsParams.Encoded
3679
+ ) => Effect.Effect<typeof ListAssistantsResponse.Type, HttpClientError.HttpClientError | ParseError>
3680
+ readonly "createAssistant": (
3681
+ options: typeof CreateAssistantRequest.Encoded
3682
+ ) => Effect.Effect<typeof AssistantObject.Type, HttpClientError.HttpClientError | ParseError>
3683
+ readonly "getAssistant": (
3684
+ assistantId: string
3685
+ ) => Effect.Effect<typeof AssistantObject.Type, HttpClientError.HttpClientError | ParseError>
3686
+ readonly "modifyAssistant": (
3687
+ assistantId: string,
3688
+ options: typeof ModifyAssistantRequest.Encoded
3689
+ ) => Effect.Effect<typeof AssistantObject.Type, HttpClientError.HttpClientError | ParseError>
3690
+ readonly "deleteAssistant": (
3691
+ assistantId: string
3692
+ ) => Effect.Effect<typeof DeleteAssistantResponse.Type, HttpClientError.HttpClientError | ParseError>
3693
+ readonly "createThread": (
3694
+ options: typeof CreateThreadRequest.Encoded
3695
+ ) => Effect.Effect<typeof ThreadObject.Type, HttpClientError.HttpClientError | ParseError>
3696
+ readonly "getThread": (
3697
+ threadId: string
3698
+ ) => Effect.Effect<typeof ThreadObject.Type, HttpClientError.HttpClientError | ParseError>
3699
+ readonly "modifyThread": (
3700
+ threadId: string,
3701
+ options: typeof ModifyThreadRequest.Encoded
3702
+ ) => Effect.Effect<typeof ThreadObject.Type, HttpClientError.HttpClientError | ParseError>
3703
+ readonly "deleteThread": (
3704
+ threadId: string
3705
+ ) => Effect.Effect<typeof DeleteThreadResponse.Type, HttpClientError.HttpClientError | ParseError>
3706
+ readonly "listMessages": (
3707
+ threadId: string,
3708
+ options: typeof ListMessagesParams.Encoded
3709
+ ) => Effect.Effect<typeof ListMessagesResponse.Type, HttpClientError.HttpClientError | ParseError>
3710
+ readonly "createMessage": (
3711
+ threadId: string,
3712
+ options: typeof CreateMessageRequest.Encoded
3713
+ ) => Effect.Effect<typeof MessageObject.Type, HttpClientError.HttpClientError | ParseError>
3714
+ readonly "getMessage": (
3715
+ threadId: string,
3716
+ messageId: string
3717
+ ) => Effect.Effect<typeof MessageObject.Type, HttpClientError.HttpClientError | ParseError>
3718
+ readonly "modifyMessage": (
3719
+ threadId: string,
3720
+ messageId: string,
3721
+ options: typeof ModifyMessageRequest.Encoded
3722
+ ) => Effect.Effect<typeof MessageObject.Type, HttpClientError.HttpClientError | ParseError>
3723
+ readonly "deleteMessage": (
3724
+ threadId: string,
3725
+ messageId: string
3726
+ ) => Effect.Effect<typeof DeleteMessageResponse.Type, HttpClientError.HttpClientError | ParseError>
3727
+ readonly "createThreadAndRun": (
3728
+ options: typeof CreateThreadAndRunRequest.Encoded
3729
+ ) => Effect.Effect<typeof RunObject.Type, HttpClientError.HttpClientError | ParseError>
3730
+ readonly "listRuns": (
3731
+ threadId: string,
3732
+ options: typeof ListRunsParams.Encoded
3733
+ ) => Effect.Effect<typeof ListRunsResponse.Type, HttpClientError.HttpClientError | ParseError>
3734
+ readonly "createRun": (
3735
+ threadId: string,
3736
+ options: { readonly params: typeof CreateRunParams.Encoded; readonly payload: typeof CreateRunRequest.Encoded }
3737
+ ) => Effect.Effect<typeof RunObject.Type, HttpClientError.HttpClientError | ParseError>
3738
+ readonly "getRun": (
3739
+ threadId: string,
3740
+ runId: string
3741
+ ) => Effect.Effect<typeof RunObject.Type, HttpClientError.HttpClientError | ParseError>
3742
+ readonly "modifyRun": (
3743
+ threadId: string,
3744
+ runId: string,
3745
+ options: typeof ModifyRunRequest.Encoded
3746
+ ) => Effect.Effect<typeof RunObject.Type, HttpClientError.HttpClientError | ParseError>
3747
+ readonly "submitToolOuputsToRun": (
3748
+ threadId: string,
3749
+ runId: string,
3750
+ options: typeof SubmitToolOutputsRunRequest.Encoded
3751
+ ) => Effect.Effect<typeof RunObject.Type, HttpClientError.HttpClientError | ParseError>
3752
+ readonly "cancelRun": (
3753
+ threadId: string,
3754
+ runId: string
3755
+ ) => Effect.Effect<typeof RunObject.Type, HttpClientError.HttpClientError | ParseError>
3756
+ readonly "listRunSteps": (
3757
+ threadId: string,
3758
+ runId: string,
3759
+ options: typeof ListRunStepsParams.Encoded
3760
+ ) => Effect.Effect<typeof ListRunStepsResponse.Type, HttpClientError.HttpClientError | ParseError>
3761
+ readonly "getRunStep": (
3762
+ threadId: string,
3763
+ runId: string,
3764
+ stepId: string,
3765
+ options: typeof GetRunStepParams.Encoded
3766
+ ) => Effect.Effect<typeof RunStepObject.Type, HttpClientError.HttpClientError | ParseError>
3767
+ readonly "listVectorStores": (
3768
+ options: typeof ListVectorStoresParams.Encoded
3769
+ ) => Effect.Effect<typeof ListVectorStoresResponse.Type, HttpClientError.HttpClientError | ParseError>
3770
+ readonly "createVectorStore": (
3771
+ options: typeof CreateVectorStoreRequest.Encoded
3772
+ ) => Effect.Effect<typeof VectorStoreObject.Type, HttpClientError.HttpClientError | ParseError>
3773
+ readonly "getVectorStore": (
3774
+ vectorStoreId: string
3775
+ ) => Effect.Effect<typeof VectorStoreObject.Type, HttpClientError.HttpClientError | ParseError>
3776
+ readonly "modifyVectorStore": (
3777
+ vectorStoreId: string,
3778
+ options: typeof UpdateVectorStoreRequest.Encoded
3779
+ ) => Effect.Effect<typeof VectorStoreObject.Type, HttpClientError.HttpClientError | ParseError>
3780
+ readonly "deleteVectorStore": (
3781
+ vectorStoreId: string
3782
+ ) => Effect.Effect<typeof DeleteVectorStoreResponse.Type, HttpClientError.HttpClientError | ParseError>
3783
+ readonly "listVectorStoreFiles": (
3784
+ vectorStoreId: string,
3785
+ options: typeof ListVectorStoreFilesParams.Encoded
3786
+ ) => Effect.Effect<typeof ListVectorStoreFilesResponse.Type, HttpClientError.HttpClientError | ParseError>
3787
+ readonly "createVectorStoreFile": (
3788
+ vectorStoreId: string,
3789
+ options: typeof CreateVectorStoreFileRequest.Encoded
3790
+ ) => Effect.Effect<typeof VectorStoreFileObject.Type, HttpClientError.HttpClientError | ParseError>
3791
+ readonly "getVectorStoreFile": (
3792
+ vectorStoreId: string,
3793
+ fileId: string
3794
+ ) => Effect.Effect<typeof VectorStoreFileObject.Type, HttpClientError.HttpClientError | ParseError>
3795
+ readonly "deleteVectorStoreFile": (
3796
+ vectorStoreId: string,
3797
+ fileId: string
3798
+ ) => Effect.Effect<typeof DeleteVectorStoreFileResponse.Type, HttpClientError.HttpClientError | ParseError>
3799
+ readonly "createVectorStoreFileBatch": (
3800
+ vectorStoreId: string,
3801
+ options: typeof CreateVectorStoreFileBatchRequest.Encoded
3802
+ ) => Effect.Effect<typeof VectorStoreFileBatchObject.Type, HttpClientError.HttpClientError | ParseError>
3803
+ readonly "getVectorStoreFileBatch": (
3804
+ vectorStoreId: string,
3805
+ batchId: string
3806
+ ) => Effect.Effect<typeof VectorStoreFileBatchObject.Type, HttpClientError.HttpClientError | ParseError>
3807
+ readonly "cancelVectorStoreFileBatch": (
3808
+ vectorStoreId: string,
3809
+ batchId: string
3810
+ ) => Effect.Effect<typeof VectorStoreFileBatchObject.Type, HttpClientError.HttpClientError | ParseError>
3811
+ readonly "listFilesInVectorStoreBatch": (
3812
+ vectorStoreId: string,
3813
+ batchId: string,
3814
+ options: typeof ListFilesInVectorStoreBatchParams.Encoded
3815
+ ) => Effect.Effect<typeof ListVectorStoreFilesResponse.Type, HttpClientError.HttpClientError | ParseError>
3816
+ readonly "listBatches": (
3817
+ options: typeof ListBatchesParams.Encoded
3818
+ ) => Effect.Effect<typeof ListBatchesResponse.Type, HttpClientError.HttpClientError | ParseError>
3819
+ readonly "createBatch": (
3820
+ options: typeof CreateBatchRequest.Encoded
3821
+ ) => Effect.Effect<typeof Batch.Type, HttpClientError.HttpClientError | ParseError>
3822
+ readonly "retrieveBatch": (
3823
+ batchId: string
3824
+ ) => Effect.Effect<typeof Batch.Type, HttpClientError.HttpClientError | ParseError>
3825
+ readonly "cancelBatch": (
3826
+ batchId: string
3827
+ ) => Effect.Effect<typeof Batch.Type, HttpClientError.HttpClientError | ParseError>
3828
+ readonly "listAuditLogs": (
3829
+ options: typeof ListAuditLogsParams.Encoded
3830
+ ) => Effect.Effect<typeof ListAuditLogsResponse.Type, HttpClientError.HttpClientError | ParseError>
3831
+ readonly "listInvites": (
3832
+ options: typeof ListInvitesParams.Encoded
3833
+ ) => Effect.Effect<typeof InviteListResponse.Type, HttpClientError.HttpClientError | ParseError>
3834
+ readonly "inviteUser": (
3835
+ options: typeof InviteRequest.Encoded
3836
+ ) => Effect.Effect<typeof Invite.Type, HttpClientError.HttpClientError | ParseError>
3837
+ readonly "retrieveInvite": (
3838
+ inviteId: string
3839
+ ) => Effect.Effect<typeof Invite.Type, HttpClientError.HttpClientError | ParseError>
3840
+ readonly "deleteInvite": (
3841
+ inviteId: string
3842
+ ) => Effect.Effect<typeof InviteDeleteResponse.Type, HttpClientError.HttpClientError | ParseError>
3843
+ readonly "listUsers": (
3844
+ options: typeof ListUsersParams.Encoded
3845
+ ) => Effect.Effect<typeof UserListResponse.Type, HttpClientError.HttpClientError | ParseError>
3846
+ readonly "retrieveUser": (
3847
+ userId: string
3848
+ ) => Effect.Effect<typeof User.Type, HttpClientError.HttpClientError | ParseError>
3849
+ readonly "modifyUser": (
3850
+ userId: string,
3851
+ options: typeof UserRoleUpdateRequest.Encoded
3852
+ ) => Effect.Effect<typeof User.Type, HttpClientError.HttpClientError | ParseError>
3853
+ readonly "deleteUser": (
3854
+ userId: string
3855
+ ) => Effect.Effect<typeof UserDeleteResponse.Type, HttpClientError.HttpClientError | ParseError>
3856
+ readonly "listProjects": (
3857
+ options: typeof ListProjectsParams.Encoded
3858
+ ) => Effect.Effect<typeof ProjectListResponse.Type, HttpClientError.HttpClientError | ParseError>
3859
+ readonly "createProject": (
3860
+ options: typeof ProjectCreateRequest.Encoded
3861
+ ) => Effect.Effect<typeof Project.Type, HttpClientError.HttpClientError | ParseError>
3862
+ readonly "retrieveProject": (
3863
+ projectId: string
3864
+ ) => Effect.Effect<typeof Project.Type, HttpClientError.HttpClientError | ParseError>
3865
+ readonly "modifyProject": (
3866
+ projectId: string,
3867
+ options: typeof ProjectUpdateRequest.Encoded
3868
+ ) => Effect.Effect<typeof Project.Type, HttpClientError.HttpClientError | ParseError | typeof ErrorResponse.Type>
3869
+ readonly "archiveProject": (
3870
+ projectId: string
3871
+ ) => Effect.Effect<typeof Project.Type, HttpClientError.HttpClientError | ParseError>
3872
+ readonly "listProjectUsers": (
3873
+ projectId: string,
3874
+ options: typeof ListProjectUsersParams.Encoded
3875
+ ) => Effect.Effect<
3876
+ typeof ProjectUserListResponse.Type,
3877
+ HttpClientError.HttpClientError | ParseError | typeof ErrorResponse.Type
3878
+ >
3879
+ readonly "createProjectUser": (
3880
+ projectId: string,
3881
+ options: typeof ProjectUserCreateRequest.Encoded
3882
+ ) => Effect.Effect<typeof ProjectUser.Type, HttpClientError.HttpClientError | ParseError | typeof ErrorResponse.Type>
3883
+ readonly "retrieveProjectUser": (
3884
+ projectId: string,
3885
+ userId: string
3886
+ ) => Effect.Effect<typeof ProjectUser.Type, HttpClientError.HttpClientError | ParseError>
3887
+ readonly "modifyProjectUser": (
3888
+ projectId: string,
3889
+ userId: string,
3890
+ options: typeof ProjectUserUpdateRequest.Encoded
3891
+ ) => Effect.Effect<typeof ProjectUser.Type, HttpClientError.HttpClientError | ParseError | typeof ErrorResponse.Type>
3892
+ readonly "deleteProjectUser": (
3893
+ projectId: string,
3894
+ userId: string
3895
+ ) => Effect.Effect<
3896
+ typeof ProjectUserDeleteResponse.Type,
3897
+ HttpClientError.HttpClientError | ParseError | typeof ErrorResponse.Type
3898
+ >
3899
+ readonly "listProjectServiceAccounts": (
3900
+ projectId: string,
3901
+ options: typeof ListProjectServiceAccountsParams.Encoded
3902
+ ) => Effect.Effect<
3903
+ typeof ProjectServiceAccountListResponse.Type,
3904
+ HttpClientError.HttpClientError | ParseError | typeof ErrorResponse.Type
3905
+ >
3906
+ readonly "createProjectServiceAccount": (
3907
+ projectId: string,
3908
+ options: typeof ProjectServiceAccountCreateRequest.Encoded
3909
+ ) => Effect.Effect<
3910
+ typeof ProjectServiceAccountCreateResponse.Type,
3911
+ HttpClientError.HttpClientError | ParseError | typeof ErrorResponse.Type
3912
+ >
3913
+ readonly "retrieveProjectServiceAccount": (
3914
+ projectId: string,
3915
+ serviceAccountId: string
3916
+ ) => Effect.Effect<typeof ProjectServiceAccount.Type, HttpClientError.HttpClientError | ParseError>
3917
+ readonly "deleteProjectServiceAccount": (
3918
+ projectId: string,
3919
+ serviceAccountId: string
3920
+ ) => Effect.Effect<typeof ProjectServiceAccountDeleteResponse.Type, HttpClientError.HttpClientError | ParseError>
3921
+ readonly "listProjectApiKeys": (
3922
+ projectId: string,
3923
+ options: typeof ListProjectApiKeysParams.Encoded
3924
+ ) => Effect.Effect<typeof ProjectApiKeyListResponse.Type, HttpClientError.HttpClientError | ParseError>
3925
+ readonly "retrieveProjectApiKey": (
3926
+ projectId: string,
3927
+ keyId: string
3928
+ ) => Effect.Effect<typeof ProjectApiKey.Type, HttpClientError.HttpClientError | ParseError>
3929
+ readonly "deleteProjectApiKey": (
3930
+ projectId: string,
3931
+ keyId: string
3932
+ ) => Effect.Effect<
3933
+ typeof ProjectApiKeyDeleteResponse.Type,
3934
+ HttpClientError.HttpClientError | ParseError | typeof ErrorResponse.Type
3935
+ >
3936
+ }