files.d.ts 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. import { APIResource } from "../resource.js";
  2. import * as Core from "../core.js";
  3. import { CursorPage, type CursorPageParams } from "../pagination.js";
  4. import { type Response } from "../_shims/index.js";
  5. export declare class Files extends APIResource {
  6. /**
  7. * Upload a file that can be used across various endpoints. Individual files can be
  8. * up to 512 MB, and the size of all files uploaded by one organization can be up
  9. * to 100 GB.
  10. *
  11. * The Assistants API supports files up to 2 million tokens and of specific file
  12. * types. See the
  13. * [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) for
  14. * details.
  15. *
  16. * The Fine-tuning API only supports `.jsonl` files. The input also has certain
  17. * required formats for fine-tuning
  18. * [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or
  19. * [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
  20. * models.
  21. *
  22. * The Batch API only supports `.jsonl` files up to 200 MB in size. The input also
  23. * has a specific required
  24. * [format](https://platform.openai.com/docs/api-reference/batch/request-input).
  25. *
  26. * Please [contact us](https://help.openai.com/) if you need to increase these
  27. * storage limits.
  28. */
  29. create(body: FileCreateParams, options?: Core.RequestOptions): Core.APIPromise<FileObject>;
  30. /**
  31. * Returns information about a specific file.
  32. */
  33. retrieve(fileId: string, options?: Core.RequestOptions): Core.APIPromise<FileObject>;
  34. /**
  35. * Returns a list of files.
  36. */
  37. list(query?: FileListParams, options?: Core.RequestOptions): Core.PagePromise<FileObjectsPage, FileObject>;
  38. list(options?: Core.RequestOptions): Core.PagePromise<FileObjectsPage, FileObject>;
  39. /**
  40. * Delete a file.
  41. */
  42. del(fileId: string, options?: Core.RequestOptions): Core.APIPromise<FileDeleted>;
  43. /**
  44. * Returns the contents of the specified file.
  45. */
  46. content(fileId: string, options?: Core.RequestOptions): Core.APIPromise<Response>;
  47. /**
  48. * Returns the contents of the specified file.
  49. *
  50. * @deprecated The `.content()` method should be used instead
  51. */
  52. retrieveContent(fileId: string, options?: Core.RequestOptions): Core.APIPromise<string>;
  53. /**
  54. * Waits for the given file to be processed, default timeout is 30 mins.
  55. */
  56. waitForProcessing(id: string, { pollInterval, maxWait }?: {
  57. pollInterval?: number;
  58. maxWait?: number;
  59. }): Promise<FileObject>;
  60. }
  61. export declare class FileObjectsPage extends CursorPage<FileObject> {
  62. }
  63. export type FileContent = string;
  64. export interface FileDeleted {
  65. id: string;
  66. deleted: boolean;
  67. object: 'file';
  68. }
  69. /**
  70. * The `File` object represents a document that has been uploaded to OpenAI.
  71. */
  72. export interface FileObject {
  73. /**
  74. * The file identifier, which can be referenced in the API endpoints.
  75. */
  76. id: string;
  77. /**
  78. * The size of the file, in bytes.
  79. */
  80. bytes: number;
  81. /**
  82. * The Unix timestamp (in seconds) for when the file was created.
  83. */
  84. created_at: number;
  85. /**
  86. * The name of the file.
  87. */
  88. filename: string;
  89. /**
  90. * The object type, which is always `file`.
  91. */
  92. object: 'file';
  93. /**
  94. * The intended purpose of the file. Supported values are `assistants`,
  95. * `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`
  96. * and `vision`.
  97. */
  98. purpose: 'assistants' | 'assistants_output' | 'batch' | 'batch_output' | 'fine-tune' | 'fine-tune-results' | 'vision';
  99. /**
  100. * @deprecated Deprecated. The current status of the file, which can be either
  101. * `uploaded`, `processed`, or `error`.
  102. */
  103. status: 'uploaded' | 'processed' | 'error';
  104. /**
  105. * The Unix timestamp (in seconds) for when the file will expire.
  106. */
  107. expires_at?: number;
  108. /**
  109. * @deprecated Deprecated. For details on why a fine-tuning training file failed
  110. * validation, see the `error` field on `fine_tuning.job`.
  111. */
  112. status_details?: string;
  113. }
  114. /**
  115. * The intended purpose of the uploaded file. One of: - `assistants`: Used in the
  116. * Assistants API - `batch`: Used in the Batch API - `fine-tune`: Used for
  117. * fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`:
  118. * Flexible file type for any purpose - `evals`: Used for eval data sets
  119. */
  120. export type FilePurpose = 'assistants' | 'batch' | 'fine-tune' | 'vision' | 'user_data' | 'evals';
  121. export interface FileCreateParams {
  122. /**
  123. * The File object (not file name) to be uploaded.
  124. */
  125. file: Core.Uploadable;
  126. /**
  127. * The intended purpose of the uploaded file. One of: - `assistants`: Used in the
  128. * Assistants API - `batch`: Used in the Batch API - `fine-tune`: Used for
  129. * fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`:
  130. * Flexible file type for any purpose - `evals`: Used for eval data sets
  131. */
  132. purpose: FilePurpose;
  133. }
  134. export interface FileListParams extends CursorPageParams {
  135. /**
  136. * Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  137. * order and `desc` for descending order.
  138. */
  139. order?: 'asc' | 'desc';
  140. /**
  141. * Only return files with the given purpose.
  142. */
  143. purpose?: string;
  144. }
  145. export declare namespace Files {
  146. export { type FileContent as FileContent, type FileDeleted as FileDeleted, type FileObject as FileObject, type FilePurpose as FilePurpose, FileObjectsPage as FileObjectsPage, type FileCreateParams as FileCreateParams, type FileListParams as FileListParams, };
  147. }
  148. //# sourceMappingURL=files.d.ts.map