Prerequisites
Before you begin, make sure you have:- A Together AI account and API key.
- The Together CLI or the Python / TypeScript SDK installed.
- Python install, with
datasets,transformers, andtqdmif you want to follow the data-prep step verbatim:
Step 1: Prepare your dataset
This quickstart uses the CoQA conversational dataset. Together AI supports four text data formats: conversational, instruction, preference, and generic text. JSONL is the default file format, but you can use Parquet for pre-tokenized data and custom loss masking. Transform CoQA into the conversational shape:Python
files.upload() runs a local structural check by default (check=True), catching basic formatting errors such as non-UTF-8 encoding or malformed JSON lines before the file is sent. To inspect the check report yourself before uploading, run check_file() first (see Data preparation for details):
client.files.list() (tg files list).
If you upload a file whose contents already exist on Together AI,
client.files.upload() doesn’t create a duplicate. It returns the existing file’s metadata, including its id, so you can reuse it directly. To force a re-upload, delete the existing file first with client.files.delete(<file_id>).processing_status reaches COMPLETED before launching the job. If validation rejects the dataset, processing_status becomes INVALID_FORMAT and validation_report.error carries the reason.
Python
processing_status: COMPLETED):
processing_status: INVALID_FORMAT):
id from the upload response. You’ll pass it as training_file in the next step.
Step 2: Launch the job
client.fine_tuning.create() starts a LoRA job by default. The example below tunes Qwen3.5 9B for three epochs. See the API reference for the full list of parameters.
Job parameters
Job parameters
Step 3: Watch the job complete
Jobs move through these states:pending → queued → running → uploading → completed. Queue wait time is typically under an hour. Once running, multiply the first epoch’s duration by n_epochs to estimate the time remaining.
Poll for completion (or error/cancellation), then read the output model name:
Step 4: Deploy and call your model
Fine-tuned models can be run on Together AI using dedicated endpoints. The example below deploys, sends one request, and tears the endpoint down to stop billing:Pass
endpoint.name (not output_model) as the model parameter when calling inference APIs. The endpoint name includes a unique suffix that routes traffic to your deployment.Congrats! You just fine-tuned a model, deployed it to a dedicated endpoint, and ran inference end-to-end.
Step 5: Compare against the base model (optional)
To measure the impact of fine-tuning, run the same prompts through the base model and the fine-tuned model.Many fine-tunable base models aren’t available on serverless. For example, calling
Qwen/Qwen3.5-9B directly returns Unable to access non-serverless model. To compare, deploy the base on its own dedicated endpoint, evaluate against endpoint.name, then tear that endpoint down too. Serverless bases (those with a per-token price listed on the models dashboard) can be called directly without deploying anything.Stop the endpoint
Dedicated model inference bills per minute as long as the endpoint is running. Step 4 deletes the endpoint at the end of the script, but if you skipped that step or want to delete it later, run:tg endpoints list.
Continue from a checkpoint
Resume training from an existing job by passingfrom_checkpoint:
from_checkpoint accepts the output model name, the job ID, or a specific step in the form ft-...:{STEP_NUM}. List available checkpoints with tg fine-tuning list-checkpoints <JOB_ID>.
Next steps
Data preparation
See the full schema for conversational, instruction, preference, and tokenized data.
Supported models
Browse base models with context lengths and batch size limits.
Preference tuning
Align a model with paired preferred and dispreferred responses.
Deploy your model
Hosting, teardown, and local inference for fine-tuned models.