Metadata-Version: 2.4
Name: bricqs-sdk
Version: 0.1.0
Summary: BRICQS Python SDK — deploy and manage AI models programmatically
Author-email: BRICQS <hello@bricqsai.com>
License: MIT
Project-URL: Homepage, https://bricqsai.com
Project-URL: Documentation, https://bricqsai.com/docs/api
Project-URL: Repository, https://github.com/bricqs/bricqs
Keywords: ai,deployment,llm,gpu,cloud,sdk
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.27

# bricqs-sdk

Official Python SDK for [BRICQS](https://bricqsai.com) — deploy AI models, manage GPU deployments, and build AI infrastructure programmatically.

## Installation

```bash
pip install bricqs-sdk
```

## Quick start

```python
from bricqs_sdk import BricqsClient

client = BricqsClient(api_key="<your-api-key>")

# Deploy a model (blocks until running)
dep = client.deployments.deploy(
    name="my-llama-api",
    model_id="meta-llama/Llama-3-8B-Instruct",
    environment="production",
)

print(dep.endpoint)  # https://<app>.azurecontainerapps.io
```

## Deployments

```python
# List all deployments
deps = client.deployments.list()
deps = client.deployments.list(environment="preview")

# Get a single deployment
dep = client.deployments.get("deployment-id")

# Deploy without waiting (non-blocking)
dep = client.deployments.deploy(
    name="my-api",
    model_id="mistralai/Mistral-7B-Instruct-v0.3",
    wait=False,
)

# Poll manually (useful for progress bars)
for snapshot in client.deployments.poll(dep.id):
    print(f"Stage: {snapshot.stage}")

# Stop, delete, promote
client.deployments.stop("deployment-id")
client.deployments.delete("deployment-id")
prod = client.deployments.promote("preview-deployment-id")

# Logs and metrics
lines = client.deployments.logs("deployment-id", lines=200)
metrics = client.deployments.metrics("deployment-id", hours=6)
print(metrics.cpu_pct)       # list of {time, avg, total, max}
print(metrics.response_time_ms)

# Summary stats
summary = client.deployments.summary()
print(summary.active_deployments, summary.gpu_hours_30d)
```

## Models

```python
models = client.models.list()
for m in models:
    print(m.id, m.task, m.gpu)
```

## Support

```python
ticket = client.support.create_ticket(
    subject="Deployment stuck in provisioning",
    body="My deployment bricqs-abc123 has been in 'creating_container' for 20 minutes.",
    category="deployments",
    priority="high",
)
print(ticket.id)

tickets = client.support.list_tickets()
```

## Context manager

```python
with BricqsClient(api_key="<token>") as client:
    dep = client.deployments.deploy(name="my-api", model_id="meta-llama/Llama-3-8B-Instruct")
```

## Error handling

```python
from bricqs_sdk import BricqsClient, AuthError, NotFoundError, RateLimitError, BricqsError

try:
    dep = client.deployments.get("nonexistent-id")
except NotFoundError:
    print("Deployment not found")
except AuthError:
    print("Invalid API key")
except RateLimitError:
    print("Rate limited — back off and retry")
except BricqsError as e:
    print(f"API error {e.status_code}: {e}")
```

## Types

All methods return typed dataclasses:

| Type | Fields |
|---|---|
| `Deployment` | `id`, `name`, `status`, `model_id`, `environment`, `endpoint`, `min_replicas`, `max_replicas`, `region`, `stage`, `created_at` |
| `Model` | `id`, `label`, `task`, `gpu`, `cpu`, `memory`, `description` |
| `DeploymentSummary` | `active_deployments`, `gpu_hours_30d`, `active_regions`, `failure_rate`, `requests_per_sec` |
| `Metrics` | `cpu_pct`, `memory_pct`, `requests`, `response_time_ms`, `replicas`, `gpu_pct` |
| `Ticket` | `id`, `subject`, `category`, `status`, `priority`, `created_at` |

Every type also exposes a `.raw` dict with the full API response.

## Links

- [Documentation](https://bricqsai.com/docs)
- [API Reference](https://bricqsai.com/docs/api)
- [CLI (`pip install bricqs`)](https://pypi.org/project/bricqs/)
