Multipart Upload
Automatically upload large files in parallel chunks using the SDK's built-in multipart upload support for upload and uploadAndPoll.
Both upload and uploadAndPoll / upload_and_poll automatically use multipart upload for large files. The file is split into chunks and uploaded in parallel, improving reliability and speed. No extra configuration is needed — it just works.
Default Behavior
Files over 100MB automatically use multipart upload. The existing upload calls work without any changes:
file = mxbai.stores.files.upload(
store_identifier="my-knowledge-base",
file=Path("./large-document.pdf"),
)Custom Threshold
Lower the threshold to trigger multipart upload for smaller files:
from mixedbread.lib.multipart_upload import MultipartUploadOptions
file = mxbai.stores.files.upload(
store_identifier="my-knowledge-base",
file=Path("./document.pdf"),
multipart_upload=MultipartUploadOptions(
threshold=50 * 1024 * 1024, # 50MB instead of default 100MB
),
)Custom Concurrency
Control how many parts upload in parallel. The default is 5 concurrent uploads:
from mixedbread.lib.multipart_upload import MultipartUploadOptions
file = mxbai.stores.files.upload(
store_identifier="my-knowledge-base",
file=Path("./large-document.pdf"),
multipart_upload=MultipartUploadOptions(
concurrency=10,
),
)Custom Part Size
Control the size of each chunk. The default part size is 100MB. Every part except the last must be at least 5MB, and an upload has at most 10,000 parts, so the default covers files up to about 1TB:
from mixedbread.lib.multipart_upload import MultipartUploadOptions
file = mxbai.stores.files.upload(
store_identifier="my-knowledge-base",
file=Path("./large-document.pdf"),
multipart_upload=MultipartUploadOptions(
part_size=50 * 1024 * 1024, # 50MB parts
),
)Progress Tracking
Get notified after each part finishes uploading. Works with both upload and uploadAndPoll / upload_and_poll:
from pathlib import Path
from mixedbread import Mixedbread
from mixedbread.lib.multipart_upload import MultipartUploadOptions
mxbai = Mixedbread(api_key="YOUR_API_KEY")
def on_part_upload(event):
pct = round((event.uploaded_bytes / event.total_bytes) * 100)
print(f"Part {event.part_number}/{event.total_parts} done — {pct}%")
file = mxbai.stores.files.upload_and_poll(
store_identifier="my-knowledge-base",
file=Path("./large-document.pdf"),
multipart_upload=MultipartUploadOptions(
on_part_upload=on_part_upload,
),
)
print(file)
The callback receives a PartUploadEvent with the following fields:
| Field | Description |
|---|---|
partNumber / part_number | 1-based part number that completed |
totalParts / total_parts | Total number of parts in this upload |
partSize / part_size | Size of this part in bytes |
uploadedBytes / uploaded_bytes | Cumulative bytes uploaded so far |
totalBytes / total_bytes | Total file size in bytes |
- Upload
- Multipart (1 GB > 100 MB)
- Parts
- ceil(1 GB / 100 MB) = 11, last part 24 MB
- At once
- min(5, 11) = 5
Each row uploads one part at a time and takes the next part when its current one finishes.
- partNumber
- –
- totalParts
- 11
- partSize
- –
- uploadedBytes
- –
- totalBytes
- 10737418241 GB
All Options Together
Combine threshold, part size, concurrency, and progress tracking:
from pathlib import Path
from mixedbread import Mixedbread
from mixedbread.lib.multipart_upload import MultipartUploadOptions
mxbai = Mixedbread(api_key="YOUR_API_KEY")
def on_part_upload(event):
pct = round((event.uploaded_bytes / event.total_bytes) * 100)
print(f"Part {event.part_number}/{event.total_parts} — {pct}%")
file = mxbai.stores.files.upload(
store_identifier="my-knowledge-base",
file=Path("./large-document.pdf"),
multipart_upload=MultipartUploadOptions(
threshold=50 * 1024 * 1024, # 50MB threshold
part_size=25 * 1024 * 1024, # 25MB parts
concurrency=10,
on_part_upload=on_part_upload,
),
)
print(file)
Options Reference
| Option | Default | Description |
|---|---|---|
threshold | 100MB | Minimum file size to trigger multipart upload |
partSize / part_size | 100MB | Size of each upload chunk, at least 5MB |
concurrency | 5 | Number of parts uploaded in parallel |
onPartUpload / on_part_upload | — | Callback invoked after each part completes |