Skip to content

Commit 05f3cef

Browse files
authored
Merge pull request #134 from togethercomputer/add-multipart-upload
Add multipart upload for large files
2 parents 7928ab0 + facb2f0 commit 05f3cef

File tree

1 file changed

+274
-0
lines changed

1 file changed

+274
-0
lines changed

openapi.yaml

Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,159 @@ paths:
10751075
schema:
10761076
$ref: '#/components/schemas/ErrorData'
10771077

1078+
/files/multipart/initiate:
1079+
post:
1080+
tags: ['Files']
1081+
summary: Initiate multipart upload
1082+
description: Initiate a multipart upload for large files (>5GB) with presigned URLs for each part.
1083+
x-codeSamples:
1084+
- lang: Python
1085+
label: Together AI SDK (Python)
1086+
source: |
1087+
from together import Together
1088+
import os
1089+
1090+
client = Together(
1091+
api_key=os.environ.get("TOGETHER_API_KEY"),
1092+
)
1093+
1094+
response = client.files.multipart.initiate(
1095+
filename="large_dataset.jsonl",
1096+
file_size=7516192768, # 7GB
1097+
num_parts=75,
1098+
purpose="fine-tune",
1099+
file_type="jsonl"
1100+
)
1101+
1102+
print(response.upload_id)
1103+
requestBody:
1104+
required: true
1105+
content:
1106+
application/json:
1107+
schema:
1108+
$ref: '#/components/schemas/MultipartInitiateRequest'
1109+
responses:
1110+
'200':
1111+
description: Multipart upload initiated successfully
1112+
content:
1113+
application/json:
1114+
schema:
1115+
$ref: '#/components/schemas/MultipartInitiateResponse'
1116+
'400':
1117+
description: Bad Request
1118+
content:
1119+
application/json:
1120+
schema:
1121+
$ref: '#/components/schemas/ErrorData'
1122+
'401':
1123+
description: Unauthorized
1124+
content:
1125+
application/json:
1126+
schema:
1127+
$ref: '#/components/schemas/ErrorData'
1128+
1129+
/files/multipart/complete:
1130+
post:
1131+
tags: ['Files']
1132+
summary: Complete multipart upload
1133+
description: Complete a multipart upload by providing ETags for all uploaded parts.
1134+
x-codeSamples:
1135+
- lang: Python
1136+
label: Together AI SDK (Python)
1137+
source: |
1138+
from together import Together
1139+
import os
1140+
1141+
client = Together(
1142+
api_key=os.environ.get("TOGETHER_API_KEY"),
1143+
)
1144+
1145+
response = client.files.multipart.complete(
1146+
upload_id="upload-123",
1147+
file_id="file-456",
1148+
parts=[
1149+
{"PartNumber": 1, "ETag": "etag1"},
1150+
{"PartNumber": 2, "ETag": "etag2"}
1151+
]
1152+
)
1153+
1154+
print(response.id)
1155+
requestBody:
1156+
required: true
1157+
content:
1158+
application/json:
1159+
schema:
1160+
$ref: '#/components/schemas/MultipartCompleteRequest'
1161+
responses:
1162+
'200':
1163+
description: Multipart upload completed successfully
1164+
content:
1165+
application/json:
1166+
schema:
1167+
$ref: '#/components/schemas/FileResponse'
1168+
'400':
1169+
description: Bad Request
1170+
content:
1171+
application/json:
1172+
schema:
1173+
$ref: '#/components/schemas/ErrorData'
1174+
'401':
1175+
description: Unauthorized
1176+
content:
1177+
application/json:
1178+
schema:
1179+
$ref: '#/components/schemas/ErrorData'
1180+
1181+
/files/multipart/abort:
1182+
post:
1183+
tags: ['Files']
1184+
summary: Abort multipart upload
1185+
description: Abort a multipart upload and clean up any uploaded parts.
1186+
x-codeSamples:
1187+
- lang: Python
1188+
label: Together AI SDK (Python)
1189+
source: |
1190+
from together import Together
1191+
import os
1192+
1193+
client = Together(
1194+
api_key=os.environ.get("TOGETHER_API_KEY"),
1195+
)
1196+
1197+
client.files.multipart.abort(
1198+
upload_id="upload-123",
1199+
file_id="file-456"
1200+
)
1201+
requestBody:
1202+
required: true
1203+
content:
1204+
application/json:
1205+
schema:
1206+
$ref: '#/components/schemas/MultipartAbortRequest'
1207+
responses:
1208+
'200':
1209+
description: Multipart upload aborted successfully
1210+
content:
1211+
application/json:
1212+
schema:
1213+
type: object
1214+
properties:
1215+
success:
1216+
type: boolean
1217+
example: true
1218+
'400':
1219+
description: Bad Request
1220+
content:
1221+
application/json:
1222+
schema:
1223+
$ref: '#/components/schemas/ErrorData'
1224+
'401':
1225+
description: Unauthorized
1226+
content:
1227+
application/json:
1228+
schema:
1229+
$ref: '#/components/schemas/ErrorData'
1230+
10781231
/fine-tunes:
10791232
post:
10801233
tags: ['Fine-tuning']
@@ -5437,6 +5590,127 @@ components:
54375590
type: string
54385591
deleted:
54395592
type: boolean
5593+
5594+
MultipartInitiateRequest:
5595+
type: object
5596+
required:
5597+
- filename
5598+
- file_size
5599+
- num_parts
5600+
- purpose
5601+
- file_type
5602+
properties:
5603+
filename:
5604+
type: string
5605+
description: The name of the file being uploaded
5606+
example: 'large_dataset.jsonl'
5607+
file_size:
5608+
type: integer
5609+
format: int64
5610+
description: Total size of the file in bytes
5611+
example: 7516192768
5612+
num_parts:
5613+
type: integer
5614+
description: Number of parts to split the file into (1-250)
5615+
minimum: 1
5616+
maximum: 250
5617+
example: 75
5618+
purpose:
5619+
$ref: '#/components/schemas/FilePurpose'
5620+
file_type:
5621+
$ref: '#/components/schemas/FileType'
5622+
5623+
MultipartInitiateResponse:
5624+
type: object
5625+
required:
5626+
- upload_id
5627+
- file_id
5628+
- parts
5629+
properties:
5630+
upload_id:
5631+
type: string
5632+
description: Unique identifier for this multipart upload session
5633+
example: 'upload-abc123'
5634+
file_id:
5635+
type: string
5636+
description: File ID for the upload
5637+
example: 'file-def456'
5638+
parts:
5639+
type: array
5640+
description: Presigned URLs and headers for each part
5641+
items:
5642+
$ref: '#/components/schemas/PartInfo'
5643+
5644+
PartInfo:
5645+
type: object
5646+
required:
5647+
- PartNumber
5648+
- URL
5649+
properties:
5650+
PartNumber:
5651+
type: integer
5652+
description: Part number (1-based)
5653+
example: 1
5654+
URL:
5655+
type: string
5656+
description: Presigned URL for uploading this part
5657+
example: 'https://s3.amazonaws.com/...'
5658+
Headers:
5659+
type: object
5660+
additionalProperties:
5661+
type: string
5662+
description: Headers to include with the upload request
5663+
example:
5664+
Authorization: 'Bearer token'
5665+
5666+
MultipartCompleteRequest:
5667+
type: object
5668+
required:
5669+
- upload_id
5670+
- file_id
5671+
- parts
5672+
properties:
5673+
upload_id:
5674+
type: string
5675+
description: Upload session ID from initiate response
5676+
example: 'upload-abc123'
5677+
file_id:
5678+
type: string
5679+
description: File ID from initiate response
5680+
example: 'file-def456'
5681+
parts:
5682+
type: array
5683+
description: ETags for each successfully uploaded part
5684+
items:
5685+
type: object
5686+
required:
5687+
- PartNumber
5688+
- ETag
5689+
properties:
5690+
PartNumber:
5691+
type: integer
5692+
description: Part number (1-based)
5693+
example: 1
5694+
ETag:
5695+
type: string
5696+
description: ETag returned from S3 part upload
5697+
example: '"abc123def456"'
5698+
5699+
MultipartAbortRequest:
5700+
type: object
5701+
required:
5702+
- upload_id
5703+
- file_id
5704+
properties:
5705+
upload_id:
5706+
type: string
5707+
description: Upload session ID from initiate response
5708+
example: 'upload-abc123'
5709+
file_id:
5710+
type: string
5711+
description: File ID from initiate response
5712+
example: 'file-def456'
5713+
54405714
FinetuneResponse:
54415715
type: object
54425716
required:

0 commit comments

Comments
 (0)