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

# Python SDK

> Official Python client library for the Chamber GPU platform

![Build](https://github.com/ChamberOrg/python-sdk/actions/workflows/ci.yml/badge.svg?branch=main)
![Coverage](https://codecov.io/gh/ChamberOrg/python-sdk/branch/main/graph/badge.svg)

The Chamber Python SDK provides a simple, intuitive interface for submitting and managing GPU workloads programmatically.

## Features

<CardGroup cols={2}>
  <Card title="One-Liner Submissions" icon="wand-magic-sparkles" href="/sdk/python/run">
    Auto-containerize and submit workloads without Docker or Kubernetes expertise
  </Card>

  <Card title="Workload Submission" icon="rocket">
    Submit GPU workloads with full control over resources, priority, and scheduling
  </Card>

  <Card title="Monitoring" icon="chart-line">
    Track workload status, retrieve GPU metrics, and get workload statistics
  </Card>

  <Card title="Capacity Management" icon="server">
    Query available GPU capacity, budgets, and manage allocations
  </Card>

  <Card title="Distributed Training" icon="network-wired">
    Support for multi-node distributed training with gang and elastic scheduling
  </Card>

  <Card title="Teams & Templates" icon="users">
    Manage teams and use workload templates for consistent configurations
  </Card>
</CardGroup>

## Quick Examples

### One-Liner: Auto-Containerize & Submit

The fastest way to get your training code running on GPUs. No Dockerfile or Kubernetes knowledge required:

```python theme={null}
from chamber_sdk import ChamberClient

client = ChamberClient.from_config()

# Configure registries once (persisted to ~/.chamber/config.json)
ChamberClient.add_registry("prod", "us-east1-docker.pkg.dev/my-project/prod", set_default=True)
ChamberClient.add_registry("dev", "us-east1-docker.pkg.dev/my-project/dev")

# Submit to default registry
job = client.run("./my-project", gpus=4, team="ml-research")

# Or specify a registry by name
job = client.run("./my-project", gpus=4, team="ml-research", registry="dev")
print(f"Submitted: {job.id}")
```

<Info>
  Install with `pip install chamber-sdk[run]` to use this feature. See the [Auto-Containerize & Run guide](/sdk/python/run) for details.
</Info>

### Standard: Full Control

For production workloads where you need complete control:

```python theme={null}
from chamber_sdk import ChamberClient, JobClass

# Initialize client
client = ChamberClient.from_config()

# Submit a training workload
job = client.submit_job(
    name="llm-fine-tuning",
    initiative_id="team-ml",
    gpu_type="H100",
    requested_gpus=8,
    job_class=JobClass.RESERVED,
    tags={"experiment": "gpt-finetune-v1"}
)

print(f"Submitted workload: {job.id}")

# Wait for completion
result = client.wait_for_completion(job.id, timeout=3600)
print(f"Workload finished with status: {result.status}")

# Get metrics
if result.status.value == "COMPLETED":
    metrics = client.get_workload_metrics(job.id)
    print(f"GPU utilization: {metrics.gpu_utilization.avg:.1f}%")
```

## API Endpoint

The SDK connects to the Chamber API at `https://api.usechamber.io/v1` by default. You can override this for custom deployments:

```python theme={null}
client = ChamberClient(
    token="ch.your-token",
    api_url="https://custom.api.example.com/v1"
)
```

## Requirements

* Python 3.8 or higher
* `requests` library (installed automatically)

## Security

The SDK is designed with security as a priority:

* **Input Validation** - All user inputs are validated before being passed to external commands or APIs
* **Credential Protection** - Tokens and credentials are never logged or exposed in error messages
* **Safe Command Execution** - Shell injection is prevented through strict input sanitization
* **Path Traversal Protection** - File operations are restricted to intended directories

<Tip>
  Credentials loaded from `~/.chamber/token.json` or environment variables are handled securely and never included in debug output or exception messages.
</Tip>

## Supported Container Registries

Push container images to your preferred registry with automatic authentication:

| Registry                     | Auto-Auth        | Auto-Create Repo |
| ---------------------------- | ---------------- | ---------------- |
| **Google Artifact Registry** | ✅ via gcloud CLI | ✅                |
| **AWS ECR**                  | ✅ via AWS CLI    | ✅                |

<Tip>
  Just provide your registry URL—the SDK automatically detects the type and handles authentication. No manual `docker login` required.
</Tip>

## What's New

* **Seamless Multi-Cloud Registries** - Full support for Google Artifact Registry and AWS ECR with auto-authentication
* **Named Registries** - Configure registries once, use by name (e.g., `registry="prod"`)
* **Auto-Containerize & Run** - Submit workloads in one line without Docker/K8s expertise
* **Framework Detection** - Auto-detect PyTorch, TensorFlow, JAX and select optimal base images
* **Distributed Training** - Auto-detect DeepSpeed, Accelerate, Ray and configure appropriately
* **Workload Search** - Advanced filtering with full-text search
* **Aggregations** - Get workload counts by status, GPU type, team, and more
* **Teams API** - List, create, and manage teams
* **Templates** - Use predefined workload templates

## Next Steps

<CardGroup cols={2}>
  <Card title="Installation" icon="download" href="/sdk/python/installation">
    Install the SDK via pip
  </Card>

  <Card title="Auto-Containerize & Run" icon="wand-magic-sparkles" href="/sdk/python/run">
    One-liner workload submission
  </Card>

  <Card title="Authentication" icon="key" href="/sdk/python/authentication">
    Configure your API credentials
  </Card>

  <Card title="API Reference" icon="code" href="/sdk/python/api-reference">
    Complete method and class documentation
  </Card>
</CardGroup>
