> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blobrouter.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Python AI / ML

> Store model checkpoints and embeddings with the BlobRouter Python SDK.

<Info>
  **BlobRouter v0.1** · Last updated: August 2026 · Architecture version: **2.0**
</Info>

Use `priority="archive"` for checkpoints (prefer B2 when connected).

## PyTorch checkpoint

```python theme={null}
import io
import os
import torch
from blobrouter import BlobRouter

storage = BlobRouter(api_key=os.environ["BLOBROUTER_API_KEY"])

buffer = io.BytesIO()
torch.save(model.state_dict(), buffer)
buffer.seek(0)

result = storage.upload(
    file=buffer,
    file_name="checkpoint_epoch_10.pt",
    content_type="application/octet-stream",
    file_size_bytes=buffer.getbuffer().nbytes,
    priority="archive",
)
print(result["file_id"], result["provider"], result["saved_vs_aws"])
```

## Background job pattern

```python theme={null}
def persist_artifact(path: str, name: str) -> str:
    storage = BlobRouter(api_key=os.environ["BLOBROUTER_API_KEY"])
    size = os.path.getsize(path)
    with open(path, "rb") as f:
        result = storage.upload(
            file=f,
            file_name=name,
            content_type="application/octet-stream",
            file_size_bytes=size,
            priority="archive",
        )
    return result["file_id"]
```

LangChain / OpenAI / Claude apps should call BlobRouter from **your backend or worker**, same as any other secret-bearing API — not from the model tool loop with a leaked key.

See [Python SDK](/sdk/python).
