Metadata-Version: 2.4
Name: runtm-api
Version: 0.1.0
Summary: FastAPI control plane for Runtm
Project-URL: Homepage, https://runtm.com
Project-URL: Documentation, https://docs.runtm.com
Project-URL: Repository, https://github.com/runtm-ai/runtm
Project-URL: Issues, https://github.com/runtm-ai/runtm/issues
Author-email: Gustavo Trigos <gus@runtm.com>
Maintainer-email: Gustavo Trigos <gus@runtm.com>
License: AGPL-3.0-or-later
License-File: LICENSE
Keywords: api,control-plane,deployment,fastapi
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Requires-Python: >=3.9
Requires-Dist: alembic<2.0,>=1.10
Requires-Dist: asyncpg<1.0,>=0.27
Requires-Dist: fastapi<1.0,>=0.100.0
Requires-Dist: psycopg2-binary<3.0,>=2.9
Requires-Dist: pydantic-settings<3.0,>=2.0
Requires-Dist: python-multipart<1.0,>=0.0.6
Requires-Dist: redis<6.0,>=4.5
Requires-Dist: rq<3.0,>=2.3.2
Requires-Dist: runtm-shared>=0.1.0
Requires-Dist: sqlalchemy<3.0,>=2.0
Requires-Dist: uvicorn[standard]<1.0,>=0.20.0
Provides-Extra: dev
Requires-Dist: httpx<1.0,>=0.24; extra == 'dev'
Requires-Dist: mypy<2.0,>=1.0; extra == 'dev'
Requires-Dist: pytest-asyncio<1.0,>=0.21; extra == 'dev'
Requires-Dist: pytest-cov<6.0,>=4.0; extra == 'dev'
Requires-Dist: pytest<9.0,>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Description-Content-Type: text/markdown

# runtm-api

FastAPI control plane for Runtm. See the [API docs](https://docs.runtm.com/api/overview) for endpoint reference.

**Hosted API:** [app.runtm.com](https://app.runtm.com)

## Endpoints

| Method | Path | Description |
|--------|------|-------------|
| POST | `/v0/deployments` | Create deployment (multipart: manifest + artifact.zip) |
| GET | `/v0/deployments/:id` | Get deployment status, URL, timestamps, error |
| GET | `/v0/deployments/:id/logs` | Get build/deploy logs |

### Creating Deployments

**POST `/v0/deployments`**

Creates a new deployment or redeploys an existing one (based on manifest name).

**Query Parameters:**
- `new=true` - Force creation of new deployment instead of redeploying existing
- `tier=starter|standard|performance` - Override machine tier from manifest

**Request:**
- `manifest` (file) - `runtm.yaml` manifest file
- `artifact` (file) - `artifact.zip` containing project files

**Headers:**
- `Authorization: Bearer <token>` - API authentication token
- `Idempotency-Key: <key>` - Optional idempotency key for retries

**Example:**
```bash
curl -X POST "http://localhost:8000/v0/deployments?tier=performance" \
  -H "Authorization: Bearer $RUNTM_API_KEY" \
  -F "manifest=@runtm.yaml" \
  -F "artifact=@artifact.zip"
```

**Machine Tiers:**

All deployments use **auto-stop** for cost savings (machines stop when idle and start automatically on traffic).

| Tier | CPUs | Memory | Est. Cost |
|------|------|--------|-----------|
| `starter` (default) | 1 shared | 256MB | ~$2/month* |
| `standard` | 1 shared | 512MB | ~$5/month* |
| `performance` | 2 shared | 1GB | ~$10/month* |

*Costs are estimates for 24/7 operation. With auto-stop, costs are much lower for low-traffic services.

## Development

```bash
# Install dependencies
pip install -e ".[dev]"

# Run migrations
alembic upgrade head

# Start server
uvicorn runtm_api.main:app --reload --host 0.0.0.0 --port 8000

# Run tests
pytest
```

## Environment Variables

| Variable | Description | Default |
|----------|-------------|---------|
| `DATABASE_URL` | PostgreSQL connection string | Required |
| `REDIS_URL` | Redis connection string | Required |
| `RUNTM_API_SECRET` | API authentication secret (what server validates against) | Required |
| `ARTIFACT_STORAGE_PATH` | Local artifact storage path | `/artifacts` |
| `ARTIFACT_STORAGE_BACKEND` | Storage backend: `local` or `s3` | `local` |
| `BUCKET_NAME` | S3/Tigris bucket name (when backend=s3) | - |
| `AWS_ENDPOINT_URL_S3` | S3 endpoint URL (e.g. `https://fly.storage.tigris.dev`) | - |
| `AUTH_MODE` | Auth mode: `single_tenant` or `multi_tenant` | `single_tenant` |

