Models in Mixtrain can be your own code or external models from external providers (Runway, Luma, Fal, Black Forest Labs, Google, etc.). Use them for training, fine-tuning, image generation, video generation, and other multimodal tasks.
Quick Start
from mixtrain import Model
model = Model("hunyuan-video")
result = model.run({"prompt": "A cat playing piano"})
print(result.video.url)Key Concepts
Model Types
- Your models: Your own code deployed using
MixModel - External models: Models from Runway, Fal, Black Forest Labs, Google, etc.
Running Models
model = Model("flux-pro")
# Synchronous - blocks until complete
result = model.run({"prompt": "A sunset over mountains"})
print(result.image.url)
# Asynchronous - returns immediately
run_info = model.submit({"prompt": "A dog running"})
print(f"Started run #{run_info['run_number']}")Batch Processing
Run models on multiple inputs with Model.batch():
from mixtrain import Model
# Single model batch
results = Model.batch(
models=["flux-pro"],
inputs=[{"prompt": "A sunset"}, {"prompt": "A mountain"}]
)
for r in results.to_dict()["flux-pro"]:
print(r.image.url)
# Multiple models on same inputs
results = Model.batch(
models=["flux-pro", "stable-diffusion-xl"],
inputs=[{"prompt": "a cat"}, {"prompt": "a dog"}],
max_in_flight=50
)
# Access as dict
for model_name, model_results in results.to_dict().items():
print(f"{model_name}:")
for r in model_results:
print(f" {r.image.url}")
# Or convert to DataFrame
df = results.to_pandas()Result Types
Model outputs use Mixtrain Types for rich UI rendering:
result = model.run({"prompt": "Generate something"})
result.video # Video output - .url, .width, .height, .duration_seconds
result.image # Image output - .url, .width, .height
result.audio # Audio output - .url, .duration_seconds
result.text # Text output
result.status # "completed", "failed", etc.See Types for all available types.
Building Models
Create your own models with MixModel. Define inputs in the run() method signature:
from mixtrain import MixModel
class ImageClassifier(MixModel):
def setup(self):
self.model = self._load_model()
def run(self, image_url: str, threshold: float = 0.5):
"""Classify an image.
Args:
image_url: Image to classify
threshold: Confidence threshold
"""
result = self.model.classify(image_url)
return {"label": result, "confidence": 0.95}Both calling styles work:
model = ImageClassifier()
# Keyword arguments
result = model.run(image_url="http://...", threshold=0.7)
# Dict input
result = model.run({"image_url": "http://...", "threshold": 0.7})Open Source Models
Fine-tune and run open-source models for specialized domains:
- Robotics - GR00T N1.6, pi0.5, SmolVLA
- Vision - SmolVLM 2, SigLIP 2, SAM 2.1, PaliGemma 2
- Audio & Speech - Parakeet TDT v3, Canary Qwen, Whisper
Next Steps
- Types - Available input/output types
- Model API Reference - Complete SDK documentation
- CLI Reference - Command-line interface
- MixModel Reference - Building models