(uploads)
Use Uploads to upload large files in multiple parts.
- createUpload - Creates an intermediate Upload object that you can add Parts to. Currently, an Upload can accept at most 8 GB in total and expires after an hour after you create it.
Once you complete the Upload, we will create a File object that contains all the parts you uploaded. This File is usable in the rest of our platform as a regular File object.
For certain purpose
s, the correct mime_type
must be specified. Please refer to documentation for the supported MIME types for your use case:
For guidance on the proper filename extensions for each purpose, please follow the documentation on creating a File.
- addUploadPart - Adds a Part to an Upload object. A Part represents a chunk of bytes from the file you are trying to upload.
Each Part can be at most 64 MB, and you can add Parts until you hit the Upload maximum of 8 GB.
It is possible to add multiple Parts in parallel. You can decide the intended order of the Parts when you complete the Upload.
- completeUpload - Completes the Upload.
Within the returned Upload object, there is a nested File object that is ready to use in the rest of the platform.
You can specify the order of the Parts by passing in an ordered list of the Part IDs.
The number of bytes uploaded upon completion must match the number of bytes initially specified when creating the Upload object. No Parts may be added after an Upload is completed.
- cancelUpload - Cancels the Upload. No Parts may be added after an Upload is cancelled.
Creates an intermediate Upload object that you can add Parts to. Currently, an Upload can accept at most 8 GB in total and expires after an hour after you create it.
Once you complete the Upload, we will create a File object that contains all the parts you uploaded. This File is usable in the rest of our platform as a regular File object.
For certain purpose
s, the correct mime_type
must be specified. Please refer to documentation for the supported MIME types for your use case:
For guidance on the proper filename extensions for each purpose, please follow the documentation on creating a File.
import { ArgotOpenAi } from "argot-open-ai";
const argotOpenAi = new ArgotOpenAi({
apiKeyAuth: process.env["ARGOTOPENAI_API_KEY_AUTH"] ?? "",
});
async function run() {
const result = await argotOpenAi.uploads.createUpload({
filename: "example.file",
purpose: "assistants",
bytes: 272980,
mimeType: "<value>",
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { ArgotOpenAiCore } from "argot-open-ai/core.js";
import { uploadsCreateUpload } from "argot-open-ai/funcs/uploadsCreateUpload.js";
// Use `ArgotOpenAiCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const argotOpenAi = new ArgotOpenAiCore({
apiKeyAuth: process.env["ARGOTOPENAI_API_KEY_AUTH"] ?? "",
});
async function run() {
const res = await uploadsCreateUpload(argotOpenAi, {
filename: "example.file",
purpose: "assistants",
bytes: 272980,
mimeType: "<value>",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
components.CreateUploadRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.Upload>
Error Type | Status Code | Content Type |
---|---|---|
errors.SDKError | 4XX, 5XX | */* |
Adds a Part to an Upload object. A Part represents a chunk of bytes from the file you are trying to upload.
Each Part can be at most 64 MB, and you can add Parts until you hit the Upload maximum of 8 GB.
It is possible to add multiple Parts in parallel. You can decide the intended order of the Parts when you complete the Upload.
import { ArgotOpenAi } from "argot-open-ai";
import { openAsBlob } from "node:fs";
const argotOpenAi = new ArgotOpenAi({
apiKeyAuth: process.env["ARGOTOPENAI_API_KEY_AUTH"] ?? "",
});
async function run() {
const result = await argotOpenAi.uploads.addUploadPart({
uploadId: "upload_abc123",
addUploadPartRequest: {
data: await openAsBlob("example.file"),
},
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { ArgotOpenAiCore } from "argot-open-ai/core.js";
import { uploadsAddUploadPart } from "argot-open-ai/funcs/uploadsAddUploadPart.js";
import { openAsBlob } from "node:fs";
// Use `ArgotOpenAiCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const argotOpenAi = new ArgotOpenAiCore({
apiKeyAuth: process.env["ARGOTOPENAI_API_KEY_AUTH"] ?? "",
});
async function run() {
const res = await uploadsAddUploadPart(argotOpenAi, {
uploadId: "upload_abc123",
addUploadPartRequest: {
data: await openAsBlob("example.file"),
},
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.AddUploadPartRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.UploadPart>
Error Type | Status Code | Content Type |
---|---|---|
errors.SDKError | 4XX, 5XX | */* |
Completes the Upload.
Within the returned Upload object, there is a nested File object that is ready to use in the rest of the platform.
You can specify the order of the Parts by passing in an ordered list of the Part IDs.
The number of bytes uploaded upon completion must match the number of bytes initially specified when creating the Upload object. No Parts may be added after an Upload is completed.
import { ArgotOpenAi } from "argot-open-ai";
const argotOpenAi = new ArgotOpenAi({
apiKeyAuth: process.env["ARGOTOPENAI_API_KEY_AUTH"] ?? "",
});
async function run() {
const result = await argotOpenAi.uploads.completeUpload({
uploadId: "upload_abc123",
completeUploadRequest: {
partIds: [
"<value>",
],
},
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { ArgotOpenAiCore } from "argot-open-ai/core.js";
import { uploadsCompleteUpload } from "argot-open-ai/funcs/uploadsCompleteUpload.js";
// Use `ArgotOpenAiCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const argotOpenAi = new ArgotOpenAiCore({
apiKeyAuth: process.env["ARGOTOPENAI_API_KEY_AUTH"] ?? "",
});
async function run() {
const res = await uploadsCompleteUpload(argotOpenAi, {
uploadId: "upload_abc123",
completeUploadRequest: {
partIds: [
"<value>",
],
},
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.CompleteUploadRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.Upload>
Error Type | Status Code | Content Type |
---|---|---|
errors.SDKError | 4XX, 5XX | */* |
Cancels the Upload. No Parts may be added after an Upload is cancelled.
import { ArgotOpenAi } from "argot-open-ai";
const argotOpenAi = new ArgotOpenAi({
apiKeyAuth: process.env["ARGOTOPENAI_API_KEY_AUTH"] ?? "",
});
async function run() {
const result = await argotOpenAi.uploads.cancelUpload({
uploadId: "upload_abc123",
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { ArgotOpenAiCore } from "argot-open-ai/core.js";
import { uploadsCancelUpload } from "argot-open-ai/funcs/uploadsCancelUpload.js";
// Use `ArgotOpenAiCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const argotOpenAi = new ArgotOpenAiCore({
apiKeyAuth: process.env["ARGOTOPENAI_API_KEY_AUTH"] ?? "",
});
async function run() {
const res = await uploadsCancelUpload(argotOpenAi, {
uploadId: "upload_abc123",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.CancelUploadRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.Upload>
Error Type | Status Code | Content Type |
---|---|---|
errors.SDKError | 4XX, 5XX | */* |