Metadata-Version: 2.4
Name: machine-sdk
Version: 0.2.1
Summary: Python SDK for the Machine AI platform - projects, agent sessions, and Machine Apps
Author-email: Machine <rcohen@mytsi.org>
License: MIT
Project-URL: Homepage, https://github.com/rossman22590/machine-sdk
Project-URL: Documentation, https://github.com/rossman22590/machine-sdk#readme
Project-URL: Bug_Tracker, https://github.com/rossman22590/machine-sdk/issues
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
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: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.24
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"

# machine-sdk

Python SDK for the [Machine](https://machine.myapps.ai) AI platform — projects,
agent sessions, and Machine Apps, driven from Python or the bundled
`machine-cli`.

```bash
pip install machine-sdk
```

## Authentication

Create a personal access token in the Machine app (Settings → API keys), then:

```bash
export MACHINE_API_KEY=kortix_pat_...
# self-hosted deployments only:
export MACHINE_API_URL=https://your-machine-api.example.com
```

## Python

```python
from machine import MachineClient

client = MachineClient()  # reads MACHINE_API_KEY / MACHINE_API_URL

for project in client.list_projects():
    print(project["project_id"], project.get("name"))

# Start an agent working on a prompt
session = client.create_session(project_id, prompt="Audit the repo's README files")
print(session["session_id"], session["status"])

# Poll it
session = client.get_session(project_id, session["session_id"])

# Stop it
client.stop_session(project_id, session["session_id"])
```

## CLI

```bash
machine-cli projects
machine-cli sessions <project-id>
machine-cli new <project-id> "Fix the failing tests" --model anthropic/claude-sonnet-5
machine-cli session <project-id> <session-id>
machine-cli stop <project-id> <session-id>
machine-cli apps <project-id>
```

Output is JSON, so it pipes cleanly into `jq`.

## Surface

| Python | CLI | Route |
| --- | --- | --- |
| `list_projects()` | `projects` | `GET /v1/projects` |
| `get_project(id)` | — | `GET /v1/projects/{id}` |
| `list_sessions(id)` | `sessions` | `GET /v1/projects/{id}/sessions` |
| `create_session(id, prompt)` | `new` | `POST /v1/projects/{id}/sessions` |
| `get_session(id, sid)` | `session` | `GET /v1/projects/{id}/sessions/{sid}` |
| `stop_session(id, sid)` | `stop` | `POST /v1/projects/{id}/sessions/{sid}/stop` |
| `restart_session(id, sid)` | `restart` | `POST /v1/projects/{id}/sessions/{sid}/restart` |
| `delete_session(id, sid)` | — | `DELETE /v1/projects/{id}/sessions/{sid}` |
| `list_apps(id)` | `apps` | `GET /v1/projects/{id}/apps` |

## Versioning

`0.2.x` is a ground-up rewrite against the current Machine API. The `0.1.x`
releases targeted a retired API surface and additionally shipped without any
Python code due to a packaging defect — do not use them.
