assistants.d.ts 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236
  1. import { APIResource } from "../../resource.js";
  2. import * as Core from "../../core.js";
  3. import * as Shared from "../shared.js";
  4. import * as MessagesAPI from "./threads/messages.js";
  5. import * as ThreadsAPI from "./threads/threads.js";
  6. import * as RunsAPI from "./threads/runs/runs.js";
  7. import * as StepsAPI from "./threads/runs/steps.js";
  8. import { CursorPage, type CursorPageParams } from "../../pagination.js";
  9. import { AssistantStream } from "../../lib/AssistantStream.js";
  10. export declare class Assistants extends APIResource {
  11. /**
  12. * Create an assistant with a model and instructions.
  13. *
  14. * @example
  15. * ```ts
  16. * const assistant = await client.beta.assistants.create({
  17. * model: 'gpt-4o',
  18. * });
  19. * ```
  20. */
  21. create(body: AssistantCreateParams, options?: Core.RequestOptions): Core.APIPromise<Assistant>;
  22. /**
  23. * Retrieves an assistant.
  24. *
  25. * @example
  26. * ```ts
  27. * const assistant = await client.beta.assistants.retrieve(
  28. * 'assistant_id',
  29. * );
  30. * ```
  31. */
  32. retrieve(assistantId: string, options?: Core.RequestOptions): Core.APIPromise<Assistant>;
  33. /**
  34. * Modifies an assistant.
  35. *
  36. * @example
  37. * ```ts
  38. * const assistant = await client.beta.assistants.update(
  39. * 'assistant_id',
  40. * );
  41. * ```
  42. */
  43. update(assistantId: string, body: AssistantUpdateParams, options?: Core.RequestOptions): Core.APIPromise<Assistant>;
  44. /**
  45. * Returns a list of assistants.
  46. *
  47. * @example
  48. * ```ts
  49. * // Automatically fetches more pages as needed.
  50. * for await (const assistant of client.beta.assistants.list()) {
  51. * // ...
  52. * }
  53. * ```
  54. */
  55. list(query?: AssistantListParams, options?: Core.RequestOptions): Core.PagePromise<AssistantsPage, Assistant>;
  56. list(options?: Core.RequestOptions): Core.PagePromise<AssistantsPage, Assistant>;
  57. /**
  58. * Delete an assistant.
  59. *
  60. * @example
  61. * ```ts
  62. * const assistantDeleted = await client.beta.assistants.del(
  63. * 'assistant_id',
  64. * );
  65. * ```
  66. */
  67. del(assistantId: string, options?: Core.RequestOptions): Core.APIPromise<AssistantDeleted>;
  68. }
  69. export declare class AssistantsPage extends CursorPage<Assistant> {
  70. }
  71. /**
  72. * Represents an `assistant` that can call the model and use tools.
  73. */
  74. export interface Assistant {
  75. /**
  76. * The identifier, which can be referenced in API endpoints.
  77. */
  78. id: string;
  79. /**
  80. * The Unix timestamp (in seconds) for when the assistant was created.
  81. */
  82. created_at: number;
  83. /**
  84. * The description of the assistant. The maximum length is 512 characters.
  85. */
  86. description: string | null;
  87. /**
  88. * The system instructions that the assistant uses. The maximum length is 256,000
  89. * characters.
  90. */
  91. instructions: string | null;
  92. /**
  93. * Set of 16 key-value pairs that can be attached to an object. This can be useful
  94. * for storing additional information about the object in a structured format, and
  95. * querying for objects via API or the dashboard.
  96. *
  97. * Keys are strings with a maximum length of 64 characters. Values are strings with
  98. * a maximum length of 512 characters.
  99. */
  100. metadata: Shared.Metadata | null;
  101. /**
  102. * ID of the model to use. You can use the
  103. * [List models](https://platform.openai.com/docs/api-reference/models/list) API to
  104. * see all of your available models, or see our
  105. * [Model overview](https://platform.openai.com/docs/models) for descriptions of
  106. * them.
  107. */
  108. model: string;
  109. /**
  110. * The name of the assistant. The maximum length is 256 characters.
  111. */
  112. name: string | null;
  113. /**
  114. * The object type, which is always `assistant`.
  115. */
  116. object: 'assistant';
  117. /**
  118. * A list of tool enabled on the assistant. There can be a maximum of 128 tools per
  119. * assistant. Tools can be of types `code_interpreter`, `file_search`, or
  120. * `function`.
  121. */
  122. tools: Array<AssistantTool>;
  123. /**
  124. * Specifies the format that the model must output. Compatible with
  125. * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
  126. * [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
  127. * and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
  128. *
  129. * Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
  130. * Outputs which ensures the model will match your supplied JSON schema. Learn more
  131. * in the
  132. * [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  133. *
  134. * Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
  135. * message the model generates is valid JSON.
  136. *
  137. * **Important:** when using JSON mode, you **must** also instruct the model to
  138. * produce JSON yourself via a system or user message. Without this, the model may
  139. * generate an unending stream of whitespace until the generation reaches the token
  140. * limit, resulting in a long-running and seemingly "stuck" request. Also note that
  141. * the message content may be partially cut off if `finish_reason="length"`, which
  142. * indicates the generation exceeded `max_tokens` or the conversation exceeded the
  143. * max context length.
  144. */
  145. response_format?: ThreadsAPI.AssistantResponseFormatOption | null;
  146. /**
  147. * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
  148. * make the output more random, while lower values like 0.2 will make it more
  149. * focused and deterministic.
  150. */
  151. temperature?: number | null;
  152. /**
  153. * A set of resources that are used by the assistant's tools. The resources are
  154. * specific to the type of tool. For example, the `code_interpreter` tool requires
  155. * a list of file IDs, while the `file_search` tool requires a list of vector store
  156. * IDs.
  157. */
  158. tool_resources?: Assistant.ToolResources | null;
  159. /**
  160. * An alternative to sampling with temperature, called nucleus sampling, where the
  161. * model considers the results of the tokens with top_p probability mass. So 0.1
  162. * means only the tokens comprising the top 10% probability mass are considered.
  163. *
  164. * We generally recommend altering this or temperature but not both.
  165. */
  166. top_p?: number | null;
  167. }
  168. export declare namespace Assistant {
  169. /**
  170. * A set of resources that are used by the assistant's tools. The resources are
  171. * specific to the type of tool. For example, the `code_interpreter` tool requires
  172. * a list of file IDs, while the `file_search` tool requires a list of vector store
  173. * IDs.
  174. */
  175. interface ToolResources {
  176. code_interpreter?: ToolResources.CodeInterpreter;
  177. file_search?: ToolResources.FileSearch;
  178. }
  179. namespace ToolResources {
  180. interface CodeInterpreter {
  181. /**
  182. * A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
  183. * available to the `code_interpreter`` tool. There can be a maximum of 20 files
  184. * associated with the tool.
  185. */
  186. file_ids?: Array<string>;
  187. }
  188. interface FileSearch {
  189. /**
  190. * The ID of the
  191. * [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
  192. * attached to this assistant. There can be a maximum of 1 vector store attached to
  193. * the assistant.
  194. */
  195. vector_store_ids?: Array<string>;
  196. }
  197. }
  198. }
  199. export interface AssistantDeleted {
  200. id: string;
  201. deleted: boolean;
  202. object: 'assistant.deleted';
  203. }
  204. /**
  205. * Represents an event emitted when streaming a Run.
  206. *
  207. * Each event in a server-sent events stream has an `event` and `data` property:
  208. *
  209. * ```
  210. * event: thread.created
  211. * data: {"id": "thread_123", "object": "thread", ...}
  212. * ```
  213. *
  214. * We emit events whenever a new object is created, transitions to a new state, or
  215. * is being streamed in parts (deltas). For example, we emit `thread.run.created`
  216. * when a new run is created, `thread.run.completed` when a run completes, and so
  217. * on. When an Assistant chooses to create a message during a run, we emit a
  218. * `thread.message.created event`, a `thread.message.in_progress` event, many
  219. * `thread.message.delta` events, and finally a `thread.message.completed` event.
  220. *
  221. * We may add additional events over time, so we recommend handling unknown events
  222. * gracefully in your code. See the
  223. * [Assistants API quickstart](https://platform.openai.com/docs/assistants/overview)
  224. * to learn how to integrate the Assistants API with streaming.
  225. */
  226. export type AssistantStreamEvent = AssistantStreamEvent.ThreadCreated | AssistantStreamEvent.ThreadRunCreated | AssistantStreamEvent.ThreadRunQueued | AssistantStreamEvent.ThreadRunInProgress | AssistantStreamEvent.ThreadRunRequiresAction | AssistantStreamEvent.ThreadRunCompleted | AssistantStreamEvent.ThreadRunIncomplete | AssistantStreamEvent.ThreadRunFailed | AssistantStreamEvent.ThreadRunCancelling | AssistantStreamEvent.ThreadRunCancelled | AssistantStreamEvent.ThreadRunExpired | AssistantStreamEvent.ThreadRunStepCreated | AssistantStreamEvent.ThreadRunStepInProgress | AssistantStreamEvent.ThreadRunStepDelta | AssistantStreamEvent.ThreadRunStepCompleted | AssistantStreamEvent.ThreadRunStepFailed | AssistantStreamEvent.ThreadRunStepCancelled | AssistantStreamEvent.ThreadRunStepExpired | AssistantStreamEvent.ThreadMessageCreated | AssistantStreamEvent.ThreadMessageInProgress | AssistantStreamEvent.ThreadMessageDelta | AssistantStreamEvent.ThreadMessageCompleted | AssistantStreamEvent.ThreadMessageIncomplete | AssistantStreamEvent.ErrorEvent;
  227. export declare namespace AssistantStreamEvent {
  228. /**
  229. * Occurs when a new
  230. * [thread](https://platform.openai.com/docs/api-reference/threads/object) is
  231. * created.
  232. */
  233. interface ThreadCreated {
  234. /**
  235. * Represents a thread that contains
  236. * [messages](https://platform.openai.com/docs/api-reference/messages).
  237. */
  238. data: ThreadsAPI.Thread;
  239. event: 'thread.created';
  240. /**
  241. * Whether to enable input audio transcription.
  242. */
  243. enabled?: boolean;
  244. }
  245. /**
  246. * Occurs when a new
  247. * [run](https://platform.openai.com/docs/api-reference/runs/object) is created.
  248. */
  249. interface ThreadRunCreated {
  250. /**
  251. * Represents an execution run on a
  252. * [thread](https://platform.openai.com/docs/api-reference/threads).
  253. */
  254. data: RunsAPI.Run;
  255. event: 'thread.run.created';
  256. }
  257. /**
  258. * Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  259. * moves to a `queued` status.
  260. */
  261. interface ThreadRunQueued {
  262. /**
  263. * Represents an execution run on a
  264. * [thread](https://platform.openai.com/docs/api-reference/threads).
  265. */
  266. data: RunsAPI.Run;
  267. event: 'thread.run.queued';
  268. }
  269. /**
  270. * Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  271. * moves to an `in_progress` status.
  272. */
  273. interface ThreadRunInProgress {
  274. /**
  275. * Represents an execution run on a
  276. * [thread](https://platform.openai.com/docs/api-reference/threads).
  277. */
  278. data: RunsAPI.Run;
  279. event: 'thread.run.in_progress';
  280. }
  281. /**
  282. * Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  283. * moves to a `requires_action` status.
  284. */
  285. interface ThreadRunRequiresAction {
  286. /**
  287. * Represents an execution run on a
  288. * [thread](https://platform.openai.com/docs/api-reference/threads).
  289. */
  290. data: RunsAPI.Run;
  291. event: 'thread.run.requires_action';
  292. }
  293. /**
  294. * Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  295. * is completed.
  296. */
  297. interface ThreadRunCompleted {
  298. /**
  299. * Represents an execution run on a
  300. * [thread](https://platform.openai.com/docs/api-reference/threads).
  301. */
  302. data: RunsAPI.Run;
  303. event: 'thread.run.completed';
  304. }
  305. /**
  306. * Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  307. * ends with status `incomplete`.
  308. */
  309. interface ThreadRunIncomplete {
  310. /**
  311. * Represents an execution run on a
  312. * [thread](https://platform.openai.com/docs/api-reference/threads).
  313. */
  314. data: RunsAPI.Run;
  315. event: 'thread.run.incomplete';
  316. }
  317. /**
  318. * Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  319. * fails.
  320. */
  321. interface ThreadRunFailed {
  322. /**
  323. * Represents an execution run on a
  324. * [thread](https://platform.openai.com/docs/api-reference/threads).
  325. */
  326. data: RunsAPI.Run;
  327. event: 'thread.run.failed';
  328. }
  329. /**
  330. * Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  331. * moves to a `cancelling` status.
  332. */
  333. interface ThreadRunCancelling {
  334. /**
  335. * Represents an execution run on a
  336. * [thread](https://platform.openai.com/docs/api-reference/threads).
  337. */
  338. data: RunsAPI.Run;
  339. event: 'thread.run.cancelling';
  340. }
  341. /**
  342. * Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  343. * is cancelled.
  344. */
  345. interface ThreadRunCancelled {
  346. /**
  347. * Represents an execution run on a
  348. * [thread](https://platform.openai.com/docs/api-reference/threads).
  349. */
  350. data: RunsAPI.Run;
  351. event: 'thread.run.cancelled';
  352. }
  353. /**
  354. * Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  355. * expires.
  356. */
  357. interface ThreadRunExpired {
  358. /**
  359. * Represents an execution run on a
  360. * [thread](https://platform.openai.com/docs/api-reference/threads).
  361. */
  362. data: RunsAPI.Run;
  363. event: 'thread.run.expired';
  364. }
  365. /**
  366. * Occurs when a
  367. * [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  368. * is created.
  369. */
  370. interface ThreadRunStepCreated {
  371. /**
  372. * Represents a step in execution of a run.
  373. */
  374. data: StepsAPI.RunStep;
  375. event: 'thread.run.step.created';
  376. }
  377. /**
  378. * Occurs when a
  379. * [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  380. * moves to an `in_progress` state.
  381. */
  382. interface ThreadRunStepInProgress {
  383. /**
  384. * Represents a step in execution of a run.
  385. */
  386. data: StepsAPI.RunStep;
  387. event: 'thread.run.step.in_progress';
  388. }
  389. /**
  390. * Occurs when parts of a
  391. * [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  392. * are being streamed.
  393. */
  394. interface ThreadRunStepDelta {
  395. /**
  396. * Represents a run step delta i.e. any changed fields on a run step during
  397. * streaming.
  398. */
  399. data: StepsAPI.RunStepDeltaEvent;
  400. event: 'thread.run.step.delta';
  401. }
  402. /**
  403. * Occurs when a
  404. * [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  405. * is completed.
  406. */
  407. interface ThreadRunStepCompleted {
  408. /**
  409. * Represents a step in execution of a run.
  410. */
  411. data: StepsAPI.RunStep;
  412. event: 'thread.run.step.completed';
  413. }
  414. /**
  415. * Occurs when a
  416. * [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  417. * fails.
  418. */
  419. interface ThreadRunStepFailed {
  420. /**
  421. * Represents a step in execution of a run.
  422. */
  423. data: StepsAPI.RunStep;
  424. event: 'thread.run.step.failed';
  425. }
  426. /**
  427. * Occurs when a
  428. * [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  429. * is cancelled.
  430. */
  431. interface ThreadRunStepCancelled {
  432. /**
  433. * Represents a step in execution of a run.
  434. */
  435. data: StepsAPI.RunStep;
  436. event: 'thread.run.step.cancelled';
  437. }
  438. /**
  439. * Occurs when a
  440. * [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  441. * expires.
  442. */
  443. interface ThreadRunStepExpired {
  444. /**
  445. * Represents a step in execution of a run.
  446. */
  447. data: StepsAPI.RunStep;
  448. event: 'thread.run.step.expired';
  449. }
  450. /**
  451. * Occurs when a
  452. * [message](https://platform.openai.com/docs/api-reference/messages/object) is
  453. * created.
  454. */
  455. interface ThreadMessageCreated {
  456. /**
  457. * Represents a message within a
  458. * [thread](https://platform.openai.com/docs/api-reference/threads).
  459. */
  460. data: MessagesAPI.Message;
  461. event: 'thread.message.created';
  462. }
  463. /**
  464. * Occurs when a
  465. * [message](https://platform.openai.com/docs/api-reference/messages/object) moves
  466. * to an `in_progress` state.
  467. */
  468. interface ThreadMessageInProgress {
  469. /**
  470. * Represents a message within a
  471. * [thread](https://platform.openai.com/docs/api-reference/threads).
  472. */
  473. data: MessagesAPI.Message;
  474. event: 'thread.message.in_progress';
  475. }
  476. /**
  477. * Occurs when parts of a
  478. * [Message](https://platform.openai.com/docs/api-reference/messages/object) are
  479. * being streamed.
  480. */
  481. interface ThreadMessageDelta {
  482. /**
  483. * Represents a message delta i.e. any changed fields on a message during
  484. * streaming.
  485. */
  486. data: MessagesAPI.MessageDeltaEvent;
  487. event: 'thread.message.delta';
  488. }
  489. /**
  490. * Occurs when a
  491. * [message](https://platform.openai.com/docs/api-reference/messages/object) is
  492. * completed.
  493. */
  494. interface ThreadMessageCompleted {
  495. /**
  496. * Represents a message within a
  497. * [thread](https://platform.openai.com/docs/api-reference/threads).
  498. */
  499. data: MessagesAPI.Message;
  500. event: 'thread.message.completed';
  501. }
  502. /**
  503. * Occurs when a
  504. * [message](https://platform.openai.com/docs/api-reference/messages/object) ends
  505. * before it is completed.
  506. */
  507. interface ThreadMessageIncomplete {
  508. /**
  509. * Represents a message within a
  510. * [thread](https://platform.openai.com/docs/api-reference/threads).
  511. */
  512. data: MessagesAPI.Message;
  513. event: 'thread.message.incomplete';
  514. }
  515. /**
  516. * Occurs when an
  517. * [error](https://platform.openai.com/docs/guides/error-codes#api-errors) occurs.
  518. * This can happen due to an internal server error or a timeout.
  519. */
  520. interface ErrorEvent {
  521. data: Shared.ErrorObject;
  522. event: 'error';
  523. }
  524. }
  525. export type AssistantTool = CodeInterpreterTool | FileSearchTool | FunctionTool;
  526. export interface CodeInterpreterTool {
  527. /**
  528. * The type of tool being defined: `code_interpreter`
  529. */
  530. type: 'code_interpreter';
  531. }
  532. export interface FileSearchTool {
  533. /**
  534. * The type of tool being defined: `file_search`
  535. */
  536. type: 'file_search';
  537. /**
  538. * Overrides for the file search tool.
  539. */
  540. file_search?: FileSearchTool.FileSearch;
  541. }
  542. export declare namespace FileSearchTool {
  543. /**
  544. * Overrides for the file search tool.
  545. */
  546. interface FileSearch {
  547. /**
  548. * The maximum number of results the file search tool should output. The default is
  549. * 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between
  550. * 1 and 50 inclusive.
  551. *
  552. * Note that the file search tool may output fewer than `max_num_results` results.
  553. * See the
  554. * [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
  555. * for more information.
  556. */
  557. max_num_results?: number;
  558. /**
  559. * The ranking options for the file search. If not specified, the file search tool
  560. * will use the `auto` ranker and a score_threshold of 0.
  561. *
  562. * See the
  563. * [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
  564. * for more information.
  565. */
  566. ranking_options?: FileSearch.RankingOptions;
  567. }
  568. namespace FileSearch {
  569. /**
  570. * The ranking options for the file search. If not specified, the file search tool
  571. * will use the `auto` ranker and a score_threshold of 0.
  572. *
  573. * See the
  574. * [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
  575. * for more information.
  576. */
  577. interface RankingOptions {
  578. /**
  579. * The score threshold for the file search. All values must be a floating point
  580. * number between 0 and 1.
  581. */
  582. score_threshold: number;
  583. /**
  584. * The ranker to use for the file search. If not specified will use the `auto`
  585. * ranker.
  586. */
  587. ranker?: 'auto' | 'default_2024_08_21';
  588. }
  589. }
  590. }
  591. export interface FunctionTool {
  592. function: Shared.FunctionDefinition;
  593. /**
  594. * The type of tool being defined: `function`
  595. */
  596. type: 'function';
  597. }
  598. /**
  599. * Occurs when a
  600. * [message](https://platform.openai.com/docs/api-reference/messages/object) is
  601. * created.
  602. */
  603. export type MessageStreamEvent = MessageStreamEvent.ThreadMessageCreated | MessageStreamEvent.ThreadMessageInProgress | MessageStreamEvent.ThreadMessageDelta | MessageStreamEvent.ThreadMessageCompleted | MessageStreamEvent.ThreadMessageIncomplete;
  604. export declare namespace MessageStreamEvent {
  605. /**
  606. * Occurs when a
  607. * [message](https://platform.openai.com/docs/api-reference/messages/object) is
  608. * created.
  609. */
  610. interface ThreadMessageCreated {
  611. /**
  612. * Represents a message within a
  613. * [thread](https://platform.openai.com/docs/api-reference/threads).
  614. */
  615. data: MessagesAPI.Message;
  616. event: 'thread.message.created';
  617. }
  618. /**
  619. * Occurs when a
  620. * [message](https://platform.openai.com/docs/api-reference/messages/object) moves
  621. * to an `in_progress` state.
  622. */
  623. interface ThreadMessageInProgress {
  624. /**
  625. * Represents a message within a
  626. * [thread](https://platform.openai.com/docs/api-reference/threads).
  627. */
  628. data: MessagesAPI.Message;
  629. event: 'thread.message.in_progress';
  630. }
  631. /**
  632. * Occurs when parts of a
  633. * [Message](https://platform.openai.com/docs/api-reference/messages/object) are
  634. * being streamed.
  635. */
  636. interface ThreadMessageDelta {
  637. /**
  638. * Represents a message delta i.e. any changed fields on a message during
  639. * streaming.
  640. */
  641. data: MessagesAPI.MessageDeltaEvent;
  642. event: 'thread.message.delta';
  643. }
  644. /**
  645. * Occurs when a
  646. * [message](https://platform.openai.com/docs/api-reference/messages/object) is
  647. * completed.
  648. */
  649. interface ThreadMessageCompleted {
  650. /**
  651. * Represents a message within a
  652. * [thread](https://platform.openai.com/docs/api-reference/threads).
  653. */
  654. data: MessagesAPI.Message;
  655. event: 'thread.message.completed';
  656. }
  657. /**
  658. * Occurs when a
  659. * [message](https://platform.openai.com/docs/api-reference/messages/object) ends
  660. * before it is completed.
  661. */
  662. interface ThreadMessageIncomplete {
  663. /**
  664. * Represents a message within a
  665. * [thread](https://platform.openai.com/docs/api-reference/threads).
  666. */
  667. data: MessagesAPI.Message;
  668. event: 'thread.message.incomplete';
  669. }
  670. }
  671. /**
  672. * Occurs when a
  673. * [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  674. * is created.
  675. */
  676. export type RunStepStreamEvent = RunStepStreamEvent.ThreadRunStepCreated | RunStepStreamEvent.ThreadRunStepInProgress | RunStepStreamEvent.ThreadRunStepDelta | RunStepStreamEvent.ThreadRunStepCompleted | RunStepStreamEvent.ThreadRunStepFailed | RunStepStreamEvent.ThreadRunStepCancelled | RunStepStreamEvent.ThreadRunStepExpired;
  677. export declare namespace RunStepStreamEvent {
  678. /**
  679. * Occurs when a
  680. * [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  681. * is created.
  682. */
  683. interface ThreadRunStepCreated {
  684. /**
  685. * Represents a step in execution of a run.
  686. */
  687. data: StepsAPI.RunStep;
  688. event: 'thread.run.step.created';
  689. }
  690. /**
  691. * Occurs when a
  692. * [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  693. * moves to an `in_progress` state.
  694. */
  695. interface ThreadRunStepInProgress {
  696. /**
  697. * Represents a step in execution of a run.
  698. */
  699. data: StepsAPI.RunStep;
  700. event: 'thread.run.step.in_progress';
  701. }
  702. /**
  703. * Occurs when parts of a
  704. * [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  705. * are being streamed.
  706. */
  707. interface ThreadRunStepDelta {
  708. /**
  709. * Represents a run step delta i.e. any changed fields on a run step during
  710. * streaming.
  711. */
  712. data: StepsAPI.RunStepDeltaEvent;
  713. event: 'thread.run.step.delta';
  714. }
  715. /**
  716. * Occurs when a
  717. * [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  718. * is completed.
  719. */
  720. interface ThreadRunStepCompleted {
  721. /**
  722. * Represents a step in execution of a run.
  723. */
  724. data: StepsAPI.RunStep;
  725. event: 'thread.run.step.completed';
  726. }
  727. /**
  728. * Occurs when a
  729. * [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  730. * fails.
  731. */
  732. interface ThreadRunStepFailed {
  733. /**
  734. * Represents a step in execution of a run.
  735. */
  736. data: StepsAPI.RunStep;
  737. event: 'thread.run.step.failed';
  738. }
  739. /**
  740. * Occurs when a
  741. * [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  742. * is cancelled.
  743. */
  744. interface ThreadRunStepCancelled {
  745. /**
  746. * Represents a step in execution of a run.
  747. */
  748. data: StepsAPI.RunStep;
  749. event: 'thread.run.step.cancelled';
  750. }
  751. /**
  752. * Occurs when a
  753. * [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  754. * expires.
  755. */
  756. interface ThreadRunStepExpired {
  757. /**
  758. * Represents a step in execution of a run.
  759. */
  760. data: StepsAPI.RunStep;
  761. event: 'thread.run.step.expired';
  762. }
  763. }
  764. /**
  765. * Occurs when a new
  766. * [run](https://platform.openai.com/docs/api-reference/runs/object) is created.
  767. */
  768. export type RunStreamEvent = RunStreamEvent.ThreadRunCreated | RunStreamEvent.ThreadRunQueued | RunStreamEvent.ThreadRunInProgress | RunStreamEvent.ThreadRunRequiresAction | RunStreamEvent.ThreadRunCompleted | RunStreamEvent.ThreadRunIncomplete | RunStreamEvent.ThreadRunFailed | RunStreamEvent.ThreadRunCancelling | RunStreamEvent.ThreadRunCancelled | RunStreamEvent.ThreadRunExpired;
  769. export declare namespace RunStreamEvent {
  770. /**
  771. * Occurs when a new
  772. * [run](https://platform.openai.com/docs/api-reference/runs/object) is created.
  773. */
  774. interface ThreadRunCreated {
  775. /**
  776. * Represents an execution run on a
  777. * [thread](https://platform.openai.com/docs/api-reference/threads).
  778. */
  779. data: RunsAPI.Run;
  780. event: 'thread.run.created';
  781. }
  782. /**
  783. * Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  784. * moves to a `queued` status.
  785. */
  786. interface ThreadRunQueued {
  787. /**
  788. * Represents an execution run on a
  789. * [thread](https://platform.openai.com/docs/api-reference/threads).
  790. */
  791. data: RunsAPI.Run;
  792. event: 'thread.run.queued';
  793. }
  794. /**
  795. * Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  796. * moves to an `in_progress` status.
  797. */
  798. interface ThreadRunInProgress {
  799. /**
  800. * Represents an execution run on a
  801. * [thread](https://platform.openai.com/docs/api-reference/threads).
  802. */
  803. data: RunsAPI.Run;
  804. event: 'thread.run.in_progress';
  805. }
  806. /**
  807. * Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  808. * moves to a `requires_action` status.
  809. */
  810. interface ThreadRunRequiresAction {
  811. /**
  812. * Represents an execution run on a
  813. * [thread](https://platform.openai.com/docs/api-reference/threads).
  814. */
  815. data: RunsAPI.Run;
  816. event: 'thread.run.requires_action';
  817. }
  818. /**
  819. * Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  820. * is completed.
  821. */
  822. interface ThreadRunCompleted {
  823. /**
  824. * Represents an execution run on a
  825. * [thread](https://platform.openai.com/docs/api-reference/threads).
  826. */
  827. data: RunsAPI.Run;
  828. event: 'thread.run.completed';
  829. }
  830. /**
  831. * Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  832. * ends with status `incomplete`.
  833. */
  834. interface ThreadRunIncomplete {
  835. /**
  836. * Represents an execution run on a
  837. * [thread](https://platform.openai.com/docs/api-reference/threads).
  838. */
  839. data: RunsAPI.Run;
  840. event: 'thread.run.incomplete';
  841. }
  842. /**
  843. * Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  844. * fails.
  845. */
  846. interface ThreadRunFailed {
  847. /**
  848. * Represents an execution run on a
  849. * [thread](https://platform.openai.com/docs/api-reference/threads).
  850. */
  851. data: RunsAPI.Run;
  852. event: 'thread.run.failed';
  853. }
  854. /**
  855. * Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  856. * moves to a `cancelling` status.
  857. */
  858. interface ThreadRunCancelling {
  859. /**
  860. * Represents an execution run on a
  861. * [thread](https://platform.openai.com/docs/api-reference/threads).
  862. */
  863. data: RunsAPI.Run;
  864. event: 'thread.run.cancelling';
  865. }
  866. /**
  867. * Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  868. * is cancelled.
  869. */
  870. interface ThreadRunCancelled {
  871. /**
  872. * Represents an execution run on a
  873. * [thread](https://platform.openai.com/docs/api-reference/threads).
  874. */
  875. data: RunsAPI.Run;
  876. event: 'thread.run.cancelled';
  877. }
  878. /**
  879. * Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  880. * expires.
  881. */
  882. interface ThreadRunExpired {
  883. /**
  884. * Represents an execution run on a
  885. * [thread](https://platform.openai.com/docs/api-reference/threads).
  886. */
  887. data: RunsAPI.Run;
  888. event: 'thread.run.expired';
  889. }
  890. }
  891. /**
  892. * Occurs when a new
  893. * [thread](https://platform.openai.com/docs/api-reference/threads/object) is
  894. * created.
  895. */
  896. export interface ThreadStreamEvent {
  897. /**
  898. * Represents a thread that contains
  899. * [messages](https://platform.openai.com/docs/api-reference/messages).
  900. */
  901. data: ThreadsAPI.Thread;
  902. event: 'thread.created';
  903. /**
  904. * Whether to enable input audio transcription.
  905. */
  906. enabled?: boolean;
  907. }
  908. export interface AssistantCreateParams {
  909. /**
  910. * ID of the model to use. You can use the
  911. * [List models](https://platform.openai.com/docs/api-reference/models/list) API to
  912. * see all of your available models, or see our
  913. * [Model overview](https://platform.openai.com/docs/models) for descriptions of
  914. * them.
  915. */
  916. model: (string & {}) | Shared.ChatModel;
  917. /**
  918. * The description of the assistant. The maximum length is 512 characters.
  919. */
  920. description?: string | null;
  921. /**
  922. * The system instructions that the assistant uses. The maximum length is 256,000
  923. * characters.
  924. */
  925. instructions?: string | null;
  926. /**
  927. * Set of 16 key-value pairs that can be attached to an object. This can be useful
  928. * for storing additional information about the object in a structured format, and
  929. * querying for objects via API or the dashboard.
  930. *
  931. * Keys are strings with a maximum length of 64 characters. Values are strings with
  932. * a maximum length of 512 characters.
  933. */
  934. metadata?: Shared.Metadata | null;
  935. /**
  936. * The name of the assistant. The maximum length is 256 characters.
  937. */
  938. name?: string | null;
  939. /**
  940. * **o-series models only**
  941. *
  942. * Constrains effort on reasoning for
  943. * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
  944. * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
  945. * result in faster responses and fewer tokens used on reasoning in a response.
  946. */
  947. reasoning_effort?: Shared.ReasoningEffort | null;
  948. /**
  949. * Specifies the format that the model must output. Compatible with
  950. * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
  951. * [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
  952. * and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
  953. *
  954. * Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
  955. * Outputs which ensures the model will match your supplied JSON schema. Learn more
  956. * in the
  957. * [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  958. *
  959. * Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
  960. * message the model generates is valid JSON.
  961. *
  962. * **Important:** when using JSON mode, you **must** also instruct the model to
  963. * produce JSON yourself via a system or user message. Without this, the model may
  964. * generate an unending stream of whitespace until the generation reaches the token
  965. * limit, resulting in a long-running and seemingly "stuck" request. Also note that
  966. * the message content may be partially cut off if `finish_reason="length"`, which
  967. * indicates the generation exceeded `max_tokens` or the conversation exceeded the
  968. * max context length.
  969. */
  970. response_format?: ThreadsAPI.AssistantResponseFormatOption | null;
  971. /**
  972. * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
  973. * make the output more random, while lower values like 0.2 will make it more
  974. * focused and deterministic.
  975. */
  976. temperature?: number | null;
  977. /**
  978. * A set of resources that are used by the assistant's tools. The resources are
  979. * specific to the type of tool. For example, the `code_interpreter` tool requires
  980. * a list of file IDs, while the `file_search` tool requires a list of vector store
  981. * IDs.
  982. */
  983. tool_resources?: AssistantCreateParams.ToolResources | null;
  984. /**
  985. * A list of tool enabled on the assistant. There can be a maximum of 128 tools per
  986. * assistant. Tools can be of types `code_interpreter`, `file_search`, or
  987. * `function`.
  988. */
  989. tools?: Array<AssistantTool>;
  990. /**
  991. * An alternative to sampling with temperature, called nucleus sampling, where the
  992. * model considers the results of the tokens with top_p probability mass. So 0.1
  993. * means only the tokens comprising the top 10% probability mass are considered.
  994. *
  995. * We generally recommend altering this or temperature but not both.
  996. */
  997. top_p?: number | null;
  998. }
  999. export declare namespace AssistantCreateParams {
  1000. /**
  1001. * A set of resources that are used by the assistant's tools. The resources are
  1002. * specific to the type of tool. For example, the `code_interpreter` tool requires
  1003. * a list of file IDs, while the `file_search` tool requires a list of vector store
  1004. * IDs.
  1005. */
  1006. interface ToolResources {
  1007. code_interpreter?: ToolResources.CodeInterpreter;
  1008. file_search?: ToolResources.FileSearch;
  1009. }
  1010. namespace ToolResources {
  1011. interface CodeInterpreter {
  1012. /**
  1013. * A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
  1014. * available to the `code_interpreter` tool. There can be a maximum of 20 files
  1015. * associated with the tool.
  1016. */
  1017. file_ids?: Array<string>;
  1018. }
  1019. interface FileSearch {
  1020. /**
  1021. * The
  1022. * [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
  1023. * attached to this assistant. There can be a maximum of 1 vector store attached to
  1024. * the assistant.
  1025. */
  1026. vector_store_ids?: Array<string>;
  1027. /**
  1028. * A helper to create a
  1029. * [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
  1030. * with file_ids and attach it to this assistant. There can be a maximum of 1
  1031. * vector store attached to the assistant.
  1032. */
  1033. vector_stores?: Array<FileSearch.VectorStore>;
  1034. }
  1035. namespace FileSearch {
  1036. interface VectorStore {
  1037. /**
  1038. * The chunking strategy used to chunk the file(s). If not set, will use the `auto`
  1039. * strategy.
  1040. */
  1041. chunking_strategy?: VectorStore.Auto | VectorStore.Static;
  1042. /**
  1043. * A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
  1044. * add to the vector store. There can be a maximum of 10000 files in a vector
  1045. * store.
  1046. */
  1047. file_ids?: Array<string>;
  1048. /**
  1049. * Set of 16 key-value pairs that can be attached to an object. This can be useful
  1050. * for storing additional information about the object in a structured format, and
  1051. * querying for objects via API or the dashboard.
  1052. *
  1053. * Keys are strings with a maximum length of 64 characters. Values are strings with
  1054. * a maximum length of 512 characters.
  1055. */
  1056. metadata?: Shared.Metadata | null;
  1057. }
  1058. namespace VectorStore {
  1059. /**
  1060. * The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
  1061. * `800` and `chunk_overlap_tokens` of `400`.
  1062. */
  1063. interface Auto {
  1064. /**
  1065. * Always `auto`.
  1066. */
  1067. type: 'auto';
  1068. }
  1069. interface Static {
  1070. static: Static.Static;
  1071. /**
  1072. * Always `static`.
  1073. */
  1074. type: 'static';
  1075. }
  1076. namespace Static {
  1077. interface Static {
  1078. /**
  1079. * The number of tokens that overlap between chunks. The default value is `400`.
  1080. *
  1081. * Note that the overlap must not exceed half of `max_chunk_size_tokens`.
  1082. */
  1083. chunk_overlap_tokens: number;
  1084. /**
  1085. * The maximum number of tokens in each chunk. The default value is `800`. The
  1086. * minimum value is `100` and the maximum value is `4096`.
  1087. */
  1088. max_chunk_size_tokens: number;
  1089. }
  1090. }
  1091. }
  1092. }
  1093. }
  1094. }
  1095. export interface AssistantUpdateParams {
  1096. /**
  1097. * The description of the assistant. The maximum length is 512 characters.
  1098. */
  1099. description?: string | null;
  1100. /**
  1101. * The system instructions that the assistant uses. The maximum length is 256,000
  1102. * characters.
  1103. */
  1104. instructions?: string | null;
  1105. /**
  1106. * Set of 16 key-value pairs that can be attached to an object. This can be useful
  1107. * for storing additional information about the object in a structured format, and
  1108. * querying for objects via API or the dashboard.
  1109. *
  1110. * Keys are strings with a maximum length of 64 characters. Values are strings with
  1111. * a maximum length of 512 characters.
  1112. */
  1113. metadata?: Shared.Metadata | null;
  1114. /**
  1115. * ID of the model to use. You can use the
  1116. * [List models](https://platform.openai.com/docs/api-reference/models/list) API to
  1117. * see all of your available models, or see our
  1118. * [Model overview](https://platform.openai.com/docs/models) for descriptions of
  1119. * them.
  1120. */
  1121. model?: (string & {}) | 'gpt-4.1' | 'gpt-4.1-mini' | 'gpt-4.1-nano' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano-2025-04-14' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o1' | 'o1-2024-12-17' | 'gpt-4o' | 'gpt-4o-2024-11-20' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-05-13' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-0125-preview' | 'gpt-4-turbo-preview' | 'gpt-4-1106-preview' | 'gpt-4-vision-preview' | 'gpt-4' | 'gpt-4-0314' | 'gpt-4-0613' | 'gpt-4-32k' | 'gpt-4-32k-0314' | 'gpt-4-32k-0613' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-16k' | 'gpt-3.5-turbo-0613' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-16k-0613';
  1122. /**
  1123. * The name of the assistant. The maximum length is 256 characters.
  1124. */
  1125. name?: string | null;
  1126. /**
  1127. * **o-series models only**
  1128. *
  1129. * Constrains effort on reasoning for
  1130. * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
  1131. * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
  1132. * result in faster responses and fewer tokens used on reasoning in a response.
  1133. */
  1134. reasoning_effort?: Shared.ReasoningEffort | null;
  1135. /**
  1136. * Specifies the format that the model must output. Compatible with
  1137. * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
  1138. * [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
  1139. * and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
  1140. *
  1141. * Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
  1142. * Outputs which ensures the model will match your supplied JSON schema. Learn more
  1143. * in the
  1144. * [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  1145. *
  1146. * Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
  1147. * message the model generates is valid JSON.
  1148. *
  1149. * **Important:** when using JSON mode, you **must** also instruct the model to
  1150. * produce JSON yourself via a system or user message. Without this, the model may
  1151. * generate an unending stream of whitespace until the generation reaches the token
  1152. * limit, resulting in a long-running and seemingly "stuck" request. Also note that
  1153. * the message content may be partially cut off if `finish_reason="length"`, which
  1154. * indicates the generation exceeded `max_tokens` or the conversation exceeded the
  1155. * max context length.
  1156. */
  1157. response_format?: ThreadsAPI.AssistantResponseFormatOption | null;
  1158. /**
  1159. * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
  1160. * make the output more random, while lower values like 0.2 will make it more
  1161. * focused and deterministic.
  1162. */
  1163. temperature?: number | null;
  1164. /**
  1165. * A set of resources that are used by the assistant's tools. The resources are
  1166. * specific to the type of tool. For example, the `code_interpreter` tool requires
  1167. * a list of file IDs, while the `file_search` tool requires a list of vector store
  1168. * IDs.
  1169. */
  1170. tool_resources?: AssistantUpdateParams.ToolResources | null;
  1171. /**
  1172. * A list of tool enabled on the assistant. There can be a maximum of 128 tools per
  1173. * assistant. Tools can be of types `code_interpreter`, `file_search`, or
  1174. * `function`.
  1175. */
  1176. tools?: Array<AssistantTool>;
  1177. /**
  1178. * An alternative to sampling with temperature, called nucleus sampling, where the
  1179. * model considers the results of the tokens with top_p probability mass. So 0.1
  1180. * means only the tokens comprising the top 10% probability mass are considered.
  1181. *
  1182. * We generally recommend altering this or temperature but not both.
  1183. */
  1184. top_p?: number | null;
  1185. }
  1186. export declare namespace AssistantUpdateParams {
  1187. /**
  1188. * A set of resources that are used by the assistant's tools. The resources are
  1189. * specific to the type of tool. For example, the `code_interpreter` tool requires
  1190. * a list of file IDs, while the `file_search` tool requires a list of vector store
  1191. * IDs.
  1192. */
  1193. interface ToolResources {
  1194. code_interpreter?: ToolResources.CodeInterpreter;
  1195. file_search?: ToolResources.FileSearch;
  1196. }
  1197. namespace ToolResources {
  1198. interface CodeInterpreter {
  1199. /**
  1200. * Overrides the list of
  1201. * [file](https://platform.openai.com/docs/api-reference/files) IDs made available
  1202. * to the `code_interpreter` tool. There can be a maximum of 20 files associated
  1203. * with the tool.
  1204. */
  1205. file_ids?: Array<string>;
  1206. }
  1207. interface FileSearch {
  1208. /**
  1209. * Overrides the
  1210. * [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
  1211. * attached to this assistant. There can be a maximum of 1 vector store attached to
  1212. * the assistant.
  1213. */
  1214. vector_store_ids?: Array<string>;
  1215. }
  1216. }
  1217. }
  1218. export interface AssistantListParams extends CursorPageParams {
  1219. /**
  1220. * A cursor for use in pagination. `before` is an object ID that defines your place
  1221. * in the list. For instance, if you make a list request and receive 100 objects,
  1222. * starting with obj_foo, your subsequent call can include before=obj_foo in order
  1223. * to fetch the previous page of the list.
  1224. */
  1225. before?: string;
  1226. /**
  1227. * Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  1228. * order and `desc` for descending order.
  1229. */
  1230. order?: 'asc' | 'desc';
  1231. }
  1232. export declare namespace Assistants {
  1233. export { type Assistant as Assistant, type AssistantDeleted as AssistantDeleted, type AssistantStreamEvent as AssistantStreamEvent, type AssistantTool as AssistantTool, type CodeInterpreterTool as CodeInterpreterTool, type FileSearchTool as FileSearchTool, type FunctionTool as FunctionTool, type MessageStreamEvent as MessageStreamEvent, type RunStepStreamEvent as RunStepStreamEvent, type RunStreamEvent as RunStreamEvent, type ThreadStreamEvent as ThreadStreamEvent, AssistantsPage as AssistantsPage, type AssistantCreateParams as AssistantCreateParams, type AssistantUpdateParams as AssistantUpdateParams, type AssistantListParams as AssistantListParams, };
  1234. export { AssistantStream };
  1235. }
  1236. //# sourceMappingURL=assistants.d.ts.map