Requirements
Before you begin, make sure you have:- Created an account and generated an API key.
- Set
TOGETHER_API_KEYas an environment variable: - Installed the Python or TypeScript SDK. Python examples require
together>=2.0.0. - Installed the Together CLI, version 2.32.0 or later (check with
tg --version), to follow the CLI examples.
Step 1: Prepare a JSONL input file
Each line of the JSONL file is one request with two fields: a uniquecustom_id you choose (up to 64 characters), and a body matching the schema of the endpoint you’re calling. Every line runs independently, and its output carries the same custom_id, which is how you’ll match results to inputs at the end.
Save the following as batch_input.jsonl:
batch_input.jsonl
method. See Run an audio transcription batch.
Step 2: Upload the file
Upload the JSONL file withpurpose="batch-api". The response includes the file id you’ll pass to the batch job in the next step. CLI users can skip this step: tg batches submit accepts a local file path and uploads it for you (see the next step).
The SDK examples infer the file name from the local path. When calling the REST API directly,
include
file_name in the multipart form. See the file upload reference
for the full request shape.Step 3: Create the batch
Create the batch by passing the fileid from step 2 and the endpoint each request runs against: /v1/chat/completions for chat completions, or --api chat.completions in the CLI. For audio, see Run an audio transcription batch.
In the SDKs,
batches.create() returns a wrapper with the batch object at .job. batches.retrieve() (used in the next step) returns the batch object directly.Step 4: Poll for completion
The job moves throughVALIDATING and IN_PROGRESS, and finally to a terminal state: COMPLETED, FAILED, EXPIRED, or CANCELLED. Poll every 30 to 60 seconds (tighter loops will likely cause you to hit rate limits).
progress tracks the percentage of requests completed, from 0 to 100. It may stay at 0 while the job is in VALIDATING.Step 5: Retrieve the results
When the job reachesCOMPLETED, the batch object includes an output_file_id. Download that file to get one JSON result per line. Results aren’t guaranteed to be in input order, so match them to inputs using the custom_id field.
error_file_id. Always check it: a batch can be COMPLETED and still contain failures. The CLI’s download saves the error file automatically (here as batch_output.errors.jsonl). See retrieve results and error files.
Run an audio transcription batch
The batch API also supports/v1/audio/transcriptions and /v1/audio/translations (for example, with openai/whisper-large-v3). Upload, poll, and retrieve work exactly as above. Two things change:
1. Each JSONL line must include "method": "FILE". This tells the worker to send the request as multipart/form-data, which the audio endpoints require. Without it, every line fails with Content-Type must be multipart/form-data in the error file.
audio_batch.jsonl
body.file is a publicly reachable URL for the audio clip. The worker fetches it at run time. Optional fields such as response_format, language, and prompt pass through to the underlying API. See the audio transcriptions reference for the full schema.
2. Pass the audio endpoint when creating the batch.
/v1/audio/translations, swap the endpoint and use a translation-capable model. The JSONL line shape is the same.
Complete script
The full flow as a CLI session or a Python program:Next steps
- Manage batch jobs: cancel, list, and download error files.
- Batches CLI: the full
tg batchescommand reference. - Batch processing overview: rate limits, discounted models, best practices, and FAQ.