uploads.d.ts 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import { APIResource } from "../../resource.js";
  2. import * as Core from "../../core.js";
  3. import * as FilesAPI from "../files.js";
  4. import * as PartsAPI from "./parts.js";
  5. import { PartCreateParams, Parts, UploadPart } from "./parts.js";
  6. export declare class Uploads extends APIResource {
  7. parts: PartsAPI.Parts;
  8. /**
  9. * Creates an intermediate
  10. * [Upload](https://platform.openai.com/docs/api-reference/uploads/object) object
  11. * that you can add
  12. * [Parts](https://platform.openai.com/docs/api-reference/uploads/part-object) to.
  13. * Currently, an Upload can accept at most 8 GB in total and expires after an hour
  14. * after you create it.
  15. *
  16. * Once you complete the Upload, we will create a
  17. * [File](https://platform.openai.com/docs/api-reference/files/object) object that
  18. * contains all the parts you uploaded. This File is usable in the rest of our
  19. * platform as a regular File object.
  20. *
  21. * For certain `purpose` values, the correct `mime_type` must be specified. Please
  22. * refer to documentation for the
  23. * [supported MIME types for your use case](https://platform.openai.com/docs/assistants/tools/file-search#supported-files).
  24. *
  25. * For guidance on the proper filename extensions for each purpose, please follow
  26. * the documentation on
  27. * [creating a File](https://platform.openai.com/docs/api-reference/files/create).
  28. */
  29. create(body: UploadCreateParams, options?: Core.RequestOptions): Core.APIPromise<Upload>;
  30. /**
  31. * Cancels the Upload. No Parts may be added after an Upload is cancelled.
  32. */
  33. cancel(uploadId: string, options?: Core.RequestOptions): Core.APIPromise<Upload>;
  34. /**
  35. * Completes the
  36. * [Upload](https://platform.openai.com/docs/api-reference/uploads/object).
  37. *
  38. * Within the returned Upload object, there is a nested
  39. * [File](https://platform.openai.com/docs/api-reference/files/object) object that
  40. * is ready to use in the rest of the platform.
  41. *
  42. * You can specify the order of the Parts by passing in an ordered list of the Part
  43. * IDs.
  44. *
  45. * The number of bytes uploaded upon completion must match the number of bytes
  46. * initially specified when creating the Upload object. No Parts may be added after
  47. * an Upload is completed.
  48. */
  49. complete(uploadId: string, body: UploadCompleteParams, options?: Core.RequestOptions): Core.APIPromise<Upload>;
  50. }
  51. /**
  52. * The Upload object can accept byte chunks in the form of Parts.
  53. */
  54. export interface Upload {
  55. /**
  56. * The Upload unique identifier, which can be referenced in API endpoints.
  57. */
  58. id: string;
  59. /**
  60. * The intended number of bytes to be uploaded.
  61. */
  62. bytes: number;
  63. /**
  64. * The Unix timestamp (in seconds) for when the Upload was created.
  65. */
  66. created_at: number;
  67. /**
  68. * The Unix timestamp (in seconds) for when the Upload will expire.
  69. */
  70. expires_at: number;
  71. /**
  72. * The name of the file to be uploaded.
  73. */
  74. filename: string;
  75. /**
  76. * The object type, which is always "upload".
  77. */
  78. object: 'upload';
  79. /**
  80. * The intended purpose of the file.
  81. * [Please refer here](https://platform.openai.com/docs/api-reference/files/object#files/object-purpose)
  82. * for acceptable values.
  83. */
  84. purpose: string;
  85. /**
  86. * The status of the Upload.
  87. */
  88. status: 'pending' | 'completed' | 'cancelled' | 'expired';
  89. /**
  90. * The `File` object represents a document that has been uploaded to OpenAI.
  91. */
  92. file?: FilesAPI.FileObject | null;
  93. }
  94. export interface UploadCreateParams {
  95. /**
  96. * The number of bytes in the file you are uploading.
  97. */
  98. bytes: number;
  99. /**
  100. * The name of the file to upload.
  101. */
  102. filename: string;
  103. /**
  104. * The MIME type of the file.
  105. *
  106. * This must fall within the supported MIME types for your file purpose. See the
  107. * supported MIME types for assistants and vision.
  108. */
  109. mime_type: string;
  110. /**
  111. * The intended purpose of the uploaded file.
  112. *
  113. * See the
  114. * [documentation on File purposes](https://platform.openai.com/docs/api-reference/files/create#files-create-purpose).
  115. */
  116. purpose: FilesAPI.FilePurpose;
  117. }
  118. export interface UploadCompleteParams {
  119. /**
  120. * The ordered list of Part IDs.
  121. */
  122. part_ids: Array<string>;
  123. /**
  124. * The optional md5 checksum for the file contents to verify if the bytes uploaded
  125. * matches what you expect.
  126. */
  127. md5?: string;
  128. }
  129. export declare namespace Uploads {
  130. export { type Upload as Upload, type UploadCreateParams as UploadCreateParams, type UploadCompleteParams as UploadCompleteParams, };
  131. export { Parts as Parts, type UploadPart as UploadPart, type PartCreateParams as PartCreateParams };
  132. }
  133. //# sourceMappingURL=uploads.d.ts.map