from mixtrain import ModelConstructor
Model(name: str)Creates a reference to an existing model. This is a lazy operation - no API call is made until you access properties or call methods.
| Parameter | Type | Description |
|---|---|---|
name | str | Model name or ID |
model = Model("hunyuan-video")Properties
| Property | Type | Description |
|---|---|---|
name | str | Model name |
source | str | Model source for external models |
description | str | Model description |
metadata | dict | Full metadata dictionary (cached) |
runs | list | Recent runs (cached) |
Methods
run()
Run synchronously. Blocks until completion.
model.run(inputs: dict, config: dict = None) -> ModelResult| Parameter | Type | Description |
|---|---|---|
inputs | dict | Input data |
config | dict | Optional configuration overrides |
Returns: ModelResult
result = model.run({"prompt": "A cat playing piano"})
print(result.video.url)
print(result.status) # "completed"submit()
Run asynchronously. Returns immediately.
model.submit(inputs: dict, config: dict = None) -> dict| Parameter | Type | Description |
|---|---|---|
inputs | dict | Input data |
config | dict | Optional configuration overrides |
Returns: dict with run_number and metadata
run_info = model.submit({"prompt": "A dog running"})
print(f"Started run #{run_info['run_number']}")get_runs()
Get run history with optional limit.
model.get_runs(limit: int = 10) -> list[dict]| Parameter | Type | Description |
|---|---|---|
limit | int | Maximum number of runs to return |
Returns: list[dict]
get_run()
Get a specific run by number.
model.get_run(run_number: int) -> dict| Parameter | Type | Description |
|---|---|---|
run_number | int | Run number |
Returns: dict with run details
get_logs()
Get logs for a run.
model.get_logs(run_number: int = None) -> str| Parameter | Type | Description |
|---|---|---|
run_number | int | Run number (defaults to latest) |
Returns: str log output
list_files()
List all files in the model.
model.list_files() -> list[dict]Returns: list[dict] file information (path, size, modified)
get_file()
Get content of a specific model file.
model.get_file(file_path: str) -> str| Parameter | Type | Description |
|---|---|---|
file_path | str | Path to file within model |
Returns: str file content
update()
Update model metadata.
model.update(description: str = None, **kwargs) -> None| Parameter | Type | Description |
|---|---|---|
description | str | New description |
delete()
Delete the model.
model.delete() -> Nonerefresh()
Clear cached data.
model.refresh() -> NoneClass Methods
Model.exists()
Check if a model exists.
Model.exists(name: str) -> bool| Parameter | Type | Description |
|---|---|---|
name | str | Model name to check |
Returns: bool - True if the model exists, False otherwise
if not Model.exists("my-model"):
Model.create("my-model", file_paths=["model.py"])Model.batch()
Run multiple models on multiple inputs.
Model.batch(
models: list[str],
inputs_list: list[dict],
max_in_flight: int = 50,
filter_failures: bool = False
) -> BatchResult| Parameter | Type | Description |
|---|---|---|
models | list[str] | List of model names |
inputs_list | list[dict] | List of input dictionaries |
max_in_flight | int | Maximum concurrent pending requests (default: 50) |
filter_failures | bool | If True, only include results where all models succeeded |
Returns: BatchResult
results = Model.batch(
models=["flux-pro", "stable-diffusion-xl"],
inputs_list=[{"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()BatchResult
Return type from Model.batch().
Methods
| Method | Returns | Description |
|---|---|---|
to_dict() | dict[str, list[ModelResult]] | Results as dict mapping model names to result lists |
to_pandas() | DataFrame | Auto-converts to DataFrame, detects output type |
to_pandas(extractor=fn) | DataFrame | Use custom extractor function |
Properties
| Property | Type | Description |
|---|---|---|
inputs | list[dict] | List of input dicts for successful results |
ModelResult
Return type from model.run().
Properties
| Property | Type | Description |
|---|---|---|
status | str | "completed", "failed", "pending" |
run_number | int | Run number |
outputs | dict | Raw outputs dictionary |
error | str | None | Error message if failed |
Typed Accessors
| Accessor | Type | Description |
|---|---|---|
video | Video | None | Video output with .url, .width, .height, .duration_seconds |
image | Image | None | Image output with .url, .width, .height |
audio | Audio | None | Audio output with .url, .duration_seconds |
text | str | None | Text output |
result = model.run({"prompt": "Generate a video"})
if result.video:
print(result.video.url)
print(result.video.duration_seconds)
if result.image:
print(result.image.url)
print(result.image.width, result.image.height)Dict-like Access
ModelResult supports dictionary-style access for backward compatibility:
result["status"]
result.get("outputs", {})list_models()
List all models in the workspace.
from mixtrain import list_models
models = list_models()
for m in models:
print(f"{m.name}: {m.source}")