Complete API reference for ModelForge.
http://localhost:8000
Currently no authentication required for local use. For production deployment, use reverse proxy with authentication.
Get system information including available providers, strategies, and tasks.
Response:
{
"providers": ["huggingface", "unsloth"],
"strategies": ["sft", "qlora", "rlhf", "dpo"],
"tasks": ["text-generation", "summarization", "extractive-question-answering"],
"version": "v2"
}Health check endpoint.
Response:
{
"status": "healthy",
"version": "v2"
}Start a new training job.
Request Body:
{
"task": "text-generation",
"model_name": "meta-llama/Llama-3.2-3B",
"provider": "unsloth",
"strategy": "sft",
"dataset": "/path/to/dataset.jsonl",
"max_seq_length": 2048,
"num_train_epochs": 3,
"per_device_train_batch_size": 4
}Response:
{
"status": "started",
"job_id": "train_123456",
"message": "Training started successfully"
}Get current training status.
Response:
{
"status": "training",
"progress": 45.5,
"current_epoch": 2,
"total_epochs": 3,
"current_step": 500,
"total_steps": 1100,
"loss": 0.234,
"learning_rate": 0.0002
}Stop current training job.
Response:
{
"status": "stopped",
"message": "Training stopped successfully"
}List all trained models.
Response:
{
"models": [
{
"id": 1,
"name": "my-llama-3-2-3b-finetuned",
"base_model": "meta-llama/Llama-3.2-3B",
"task": "text-generation",
"created_at": "2024-01-15T10:30:00Z",
"size_mb": 6240
}
]
}Get details of a specific model.
Response:
{
"id": 1,
"name": "my-llama-3-2-3b-finetuned",
"base_model": "meta-llama/Llama-3.2-3B",
"task": "text-generation",
"provider": "unsloth",
"strategy": "sft",
"training_params": {
"num_epochs": 3,
"batch_size": 4,
"learning_rate": 0.0002
},
"metrics": {
"final_loss": 0.234,
"perplexity": 1.263
},
"created_at": "2024-01-15T10:30:00Z"
}Delete a trained model.
Response:
{
"status": "deleted",
"message": "Model deleted successfully"
}Upload a training dataset.
Request: Multipart form-data
file: JSONL file
Response:
{
"status": "uploaded",
"filename": "dataset.jsonl",
"num_examples": 1000,
"validation": {
"valid": true,
"errors": []
}
}List uploaded datasets.
Response:
{
"datasets": [
{
"filename": "dataset.jsonl",
"num_examples": 1000,
"size_mb": 5.2,
"uploaded_at": "2024-01-15T10:00:00Z"
}
]
}Test a model with inference.
Request Body:
{
"model_id": 1,
"prompt": "What is machine learning?",
"max_new_tokens": 100,
"temperature": 0.7,
"top_p": 0.9
}Response:
{
"generated_text": "Machine learning is a subset of artificial intelligence...",
"tokens_generated": 45,
"generation_time_ms": 1234
}All errors follow this format:
{
"error": "Error message",
"detail": "Detailed error information",
"status_code": 400
}400- Bad Request (invalid parameters)404- Not Found (model/dataset not found)409- Conflict (training already in progress)500- Internal Server Error
No rate limiting for local use. For production, implement via reverse proxy.
Training progress updates available via WebSocket:
const ws = new WebSocket('ws://localhost:8000/ws/training');
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Training progress:', data);
};import requests
# Start training
response = requests.post(
'http://localhost:8000/api/start_training',
json={
'task': 'text-generation',
'model_name': 'meta-llama/Llama-3.2-3B',
'provider': 'unsloth',
'dataset': '/path/to/dataset.jsonl',
'num_train_epochs': 3
}
)
print(response.json())
# Check status
status = requests.get('http://localhost:8000/api/training_status')
print(status.json())- Training Configuration Schema - Detailed config options
- Response Formats - Detailed response structures
API Reference for programmatic access to ModelForge 🔌