Upload a file
client.files.create(FileCreateParams { mime_type, size_bytes, expires_at, 3 more } body, RequestOptionsoptions?): CreateFileResponse { id, file, state, upload }
POST/files
Upload a file to your namespace, then reference it from a generation via ImageRef.file_id (as source, image_ref[], video.start_frame, keyframes, and so on). Two upload modes share this endpoint, selected by Content-Type:
multipart/form-data — send the bytes inline in the
filepart. Best for small files (subject to an inline size cap; larger files must use the presigned flow). The returned file is alreadypendingingest.application/json — request a presigned upload. The response
uploadenvelope tells you where to PUT the bytes; afterward call POST /files/{file_id}/complete to start ingest. Use this for larger files.
Upload a file
import Luma from 'luma-agents';
const client = new Luma({
authToken: process.env['LUMA_AGENTS_API_KEY'], // This is the default and can be omitted
});
const createFileResponse = await client.files.create({ mime_type: 'x', size_bytes: 1 });
console.log(createFileResponse.id);{
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"file": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"created_at": "2019-12-27T18:11:19.117Z",
"mime_type": "mime_type",
"purpose": "input",
"size_bytes": 0,
"state": "pending",
"deleted_at": "2019-12-27T18:11:19.117Z",
"expires_at": "2019-12-27T18:11:19.117Z",
"failure_reason": "failure_reason",
"filename": "filename",
"user_id": "user_id"
},
"state": "pending",
"upload": {
"expires_at": "2019-12-27T18:11:19.117Z",
"method": "method",
"url": "https://example.com",
"headers": {
"foo": "string"
}
}
}Returns Examples
{
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"file": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"created_at": "2019-12-27T18:11:19.117Z",
"mime_type": "mime_type",
"purpose": "input",
"size_bytes": 0,
"state": "pending",
"deleted_at": "2019-12-27T18:11:19.117Z",
"expires_at": "2019-12-27T18:11:19.117Z",
"failure_reason": "failure_reason",
"filename": "filename",
"user_id": "user_id"
},
"state": "pending",
"upload": {
"expires_at": "2019-12-27T18:11:19.117Z",
"method": "method",
"url": "https://example.com",
"headers": {
"foo": "string"
}
}
}