Langtrain SDK·Python & TypeScript
Your model,from code.
Python and TypeScript clients for Langtrain. Upload a dataset, fine-tune an open model and follow the run, from a script, a notebook or CI.
from langtrain import LangtrainClient
client = LangtrainClient() # reads LANGTRAIN_API_KEY
dataset = client.datasets.upload("support_chats.jsonl")
job = client.fine_tune(
model="meta-llama/Llama-3.1-8B",
dataset_id=dataset["id"],
method="qlora",
)
for step in job.stream():
print(step) # step=120 loss=0.8421 progress=40%
job.wait()What you can do
The whole loop, scriptable.
The SDK calls the same API as the web app and Studio, so a run started from code shows up everywhere.
Upload and analyse data
Upload a JSONL file and get a report on it: the kind of task, its size, and a suggested model and training setup.
Start fine-tuning runs
Fine-tune an open model on your dataset with supervised fine-tuning, LoRA or QLoRA, or train on preferences with DPO.
Follow each step
Stream a run's progress and loss as it trains, or wait for it to finish before your script carries on.
Keep track of runs
List every run on your account with its status, and pick any one up again by its ID.
Train on your own GPU
Install
langtrain-ai[train]and the same package fine-tunes locally, so your data never leaves the machine.See your GPU options
List the GPUs available to your account before you start a run.
Install
Two packages. Same API.
The Python package also includes Langtune and Langvision, for training on your own GPU. The npm package adds the lt command line.
Python
TypeScript and the lt CLI
The Langtrain family
Four ways in. One model you own.
Use whichever fits how you work. They share one account and one API, so a run started in the cloud from any of them shows up in all of them.
- Langtrain StudioDesktop appManage datasets and fine-tuning runs from a native app for Windows and Linux.
- You're hereLangtrain SDKPython & TypeScriptUpload data, fine-tune and follow runs from code, with the lt command line.
- LangtuneOpen-source libraryFine-tune open text models like Llama, Mistral and Qwen on your own GPU.
- LangvisionOpen-source libraryFine-tune vision-language models like LLaVA and Qwen-VL on your own images.
Train your firstmodel from code.
Create an account, copy an API key, and run the example above.