Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Togethercomputer Together python File Upload For Batch

From Leeroopedia
Attribute Value
Type Principle
Domains Batch_Processing, Inference, API_Client
Repository togethercomputer/together-python
Last Updated 2026-02-15 16:00 GMT

Overview

Mechanism for uploading batch inference input files to Together AI's storage with batch-api purpose designation.

Description

Uploading files for batch inference uses the same Files.upload() API as fine-tuning but with a different purpose parameter. Setting purpose="batch-api" tells the server that the file contains batch inference requests rather than training data.

A critical behavioral distinction exists: file validation (check_file) is only invoked for fine-tune uploads. When the purpose is anything other than "fine-tune", the validation step is skipped entirely, regardless of the check parameter value. This means batch-api files bypass the client-side schema and format checks that fine-tuning files undergo.

The upload mechanism supports both standard and multipart uploads. Files exceeding a configurable size threshold are automatically routed through the MultipartUploadManager for chunked transfer.

Usage

Use this principle after preparing a batch JSONL input file. The workflow is:

  • Construct the JSONL file following the Batch Input Preparation schema.
  • Call Files.upload() with purpose="batch-api".
  • Extract the id field from the returned FileResponse to use as the file_id when creating a batch job.

The purpose parameter accepts either the string "batch-api" or the enum value FilePurpose.BatchAPI.

Theoretical Basis

Separating file upload from batch job creation follows a two-phase submission pattern:

  • Phase 1 (Upload): Transfer data to server storage, receive a file identifier.
  • Phase 2 (Submit): Reference the uploaded file by ID when creating the processing job.

This decoupling allows the same file to be reused across multiple batch jobs and enables the server to pre-stage data before scheduling compute resources. The purpose field acts as a routing tag, ensuring files are handled by the correct processing pipeline.

Related

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment