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 os
from luma_agents import Luma
client = Luma(
auth_token=os.environ.get("LUMA_AGENTS_API_KEY"), # This is the default and can be omitted
)
create_file_response = client.files.create(
mime_type="x",
size_bytes=1,
)
print(create_file_response.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"
}
}
}