/v1/distillation/* endpoints.
Requires the self-hosted stack running — see the
self-host guide.
Constructor
| Name | Type | Description |
|---|---|---|
base_url | str | REST API base. Default assumes local self-host on :8000. |
api_key | str? | Bearer token if the API is behind auth. |
timeout | float | HTTP timeout in seconds. |
Methods
.create(...) → dict
Create a new distillation job.
.estimate(...) → dict
Dry-run cost estimation — no job is created.
.get(job_id) → dict
Fetch current state of a job.
.wait(job_id, timeout=3600, poll_interval=5.0, on_update=None) → dict
Block until the job reaches a terminal state (completed or failed).
.stream_progress(job_id, poll_interval=5.0) → Iterable[dict]
Generator yielding status updates as they change.
.metrics(job_id, limit=5000) → list[dict]
Per-step training metrics (loss, ot, memory) — the series you’d plot.
.candidates(job_id, limit=100) → list[dict]
Teacher-generated candidates (before curation), with judge scores.
.logs(job_id) → str
Full text logs from the training subprocess.
.artifacts(job_id) → dict
Paths to the trained artifacts on the engine side.
.cancel(job_id) → dict
Cancel a running job. Safe at any phase; partial artifacts are kept.
.delete(job_id) → dict
Delete the job record and all its artifacts from disk.
.list(status=None, limit=50, offset=0) → list[dict]
List jobs, optionally filtered by status.
.teacher_models() → list[dict]
Available teachers (populated from the engine’s model registry).
.student_models() → list[dict]
Available students (populated from the engine’s HF whitelist + local
models). Typical entries include llama-3.2-1b, llama-3.2-3b,
qwen3-0.6b, qwen3-1.7b, qwen3-4b, mistral-small, phi-3.5-mini.
TrainingClient (lower-level)
Distiller wraps TrainingClient — the raw HTTP layer. Use
TrainingClient directly only if you need fine control over retries,
custom endpoints, or headers.
Errors
All network / server errors raiseDistillerError with the HTTP status
and response body attached. Wrap .create and .wait in try/except if
you need graceful degradation.

