> For the complete documentation index, see [llms.txt](https://docs.unitlab.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.unitlab.ai/api-sdk-cli/get-started/python-sdk-quickstart.md).

# Python SDK quickstart

{% hint style="info" %}
**Outcome:** Create a project, upload multimodal data, wait for processing, and inspect the resulting Data Units.
{% endhint %}

```python
from unitlab import UnitlabClient

client = UnitlabClient()
project = client.projects.create("Medical review")

batch = project.upload("./multimodal-data")
status = batch.wait(timeout=1800)

print({
    "project_id": project.id,
    "batch_queue_id": batch.batch_queue_id,
    "uploaded": batch.uploaded,
    "failed": status.failed,
})

for unit in project.data_units():
    print(unit.id, unit.kind, unit.name, unit.status)

client.close()
```

A directory may mix images, video, audio, text, PDFs, DICOM, NIfTI, and NRRD. One upload call creates one Batch Queue. `wait()` ends when server-side processing reaches zero active items; completion can still include individual failures, so inspect `status.failed` and the batch data before the next state-changing step.

### Definition of success

* The project ID is recorded.
* The Batch Queue reaches no active processing.
* Failed files are explained or routed for correction.
* Data Units have the intended loose or grouped structure.
* The project workflow and ontology are ready before tasks are assigned.

### Operating contract

| Concern           | Required behavior                                                                |
| ----------------- | -------------------------------------------------------------------------------- |
| Execution surface | Pinned `unitlab==3.0.0` application environment on Python 3.10+.                 |
| Identity          | Least-privilege API key supplied through approved configuration.                 |
| Target resolution | Stable resource IDs and an explicitly bounded target set.                        |
| Success evidence  | Typed return fields, server-side state, and downstream acceptance of the result. |

### Failure and recovery boundary

| Condition                                       | Response                                                                                                     |
| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| Authentication or authorization fails           | Stop, correct the service identity or access model, rotate exposed credentials, and rerun a read-only check. |
| Validation or entitlement rejects the operation | Correct the input or entitlement; do not retry an unchanged request.                                         |
| A request times out                             | Inspect remote state before repeating a mutation because the server may have accepted it.                    |
| Asynchronous processing exceeds its deadline    | Preserve the Batch Queue or release ID, continue bounded monitoring, and inspect item-level failures.        |
| Only part of a batch succeeds                   | Keep successful identifiers, isolate failed rows, and retry only the corrected subset.                       |

{% hint style="warning" %}
Pin and test the production SDK version. Use stable IDs, keep secrets out of logs and command history, and record the correlation ID, target IDs, counts, final state, and redacted error details for material state changes.
{% endhint %}
