L
000

Initializing Studio...

LangtrainLangtrain
DocsAPI ReferenceSDK Reference
ModelsChat
  • Introduction
  • Quick Start
  • Installation
GitHubDiscord

Quick Start

Train your first custom AI model in under 5 minutes using the Langtrain SDK.

5 min setup
Python 3.9+
GPU optional
100+ models

Install the SDK

Install the Langtrain SDK using pip. We recommend Python 3.9 or higher.
1pip install langtrain-ai

Prepare Your Data

Create a JSONL file with your training examples. Each line should be a JSON object with a messages array in OpenAI format.
1# training_data.jsonl
2{"messages": [{"role": "user", "content": "What is Langtrain?"}, {"role": "assistant", "content": "Langtrain is a platform for fine-tuning LLMs."}]}
3{"messages": [{"role": "user", "content": "How do I train a model?"}, {"role": "assistant", "content": "Use the LoRATrainer class with your dataset."}]}

Train with LoRA

Use the LoRATrainer to fine-tune a model. LoRA trains only 0.1-1% of parameters, making it fast and memory-efficient.
1from langtrain import LoRATrainer
2
3trainer = LoRATrainer(
4 model="meta-llama/Llama-3.3-8B",
5 output_dir="./my-model"
6)
7
8trainer.train("training_data.jsonl")

Run Inference

After training completes, use your fine-tuned model for inference.
1# Generate a response
2response = trainer.generate("What is Langtrain?")
3print(response)
4
5# Or use the chat interface
6messages = [{"role": "user", "content": "Hello!"}]
7response = trainer.chat(messages)
8print(response)

Deploy to Cloud

Push your trained model to Langtrain Cloud for production inference with a single command.
1# Deploy to Langtrain Cloud
2trainer.push("my-custom-model")
3
4# Your model is now available via API
5# curl -X POST https://api.langtrain.xyz/v1/chat/completions \
6# -H "Authorization: Bearer YOUR_API_KEY" \
7# -d '{"model": "my-custom-model", "messages": [...]}'

Next Steps

Explore more features:
  • •LoRA Fine-tuning - Advanced training options
  • •API Reference - REST API documentation
  • •Cloud Deployment - Production scaling
Previous
Introduction
Next
Installation