Metadata-Version: 2.4
Name: podstack
Version: 1.9.0
Summary: Python SDK for the Podstack platform API
Author-email: Podstack <support@podstack.ai>
License-Expression: MIT
Project-URL: Homepage, https://podstack.ai
Project-URL: Documentation, https://docs.podstack.ai
Project-URL: Repository, https://github.com/Podstack-ai/podstack-python
Keywords: podstack,gpu,inference,sdk
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
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: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cloudpickle<4,>=3.0
Requires-Dist: httpx>=0.24
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == "dev"
Requires-Dist: mypy<2,>=1.8; extra == "dev"
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
Requires-Dist: ruff>=0.4; extra == "dev"
Requires-Dist: twine>=5; extra == "dev"
Dynamic: license-file

# podstack

Python SDK for the [Podstack](https://podstack.ai) platform API.

```bash
pip install podstack
```

The client talks to `https://podstack.ai/api/v1`. Set `PODSTACK_API_KEY` to a
`ps_live_` key, or run `podstack auth login` so the CLI credentials file is
present. The API does not accept a `psk_` key. `api.podstack.ai` does not resolve.
Public reads such as `client.job_gpus.list()` work with no key.

```python
from podstack import Podstack

with Podstack() as client:
    for gpu in client.gpus.list():
        print(gpu.gpu_type, gpu.vram_gb)
    for rate in client.rates.list():
        print(rate.gpu_type, rate.region, rate.price_per_hour)
```

`price_per_hour` and every other spec are copied from the API. The SDK does
not ship a price table or a GPU catalogue.

## Billable calls

Create, terminate, submit, cancel, chat, embeddings, image generation, and
function deploy or invoke require `confirm=True`. `dry_run=True` returns the
request and does not send it. `dry_run` is checked first.

```python
preview = client.instances.create(gpu_type=gpu.gpu_type, dry_run=True)
operation = client.instances.create(gpu_type=gpu.gpu_type, confirm=True)
```

There is no stop or start that keeps an instance disk. Terminate the instance
to stop the per-second charge. Commands and file copies use the SSH command
the API returns and the local `ssh` / `scp` binaries.

## Functions

Creating a function is this package. The CLI only lists functions.

```python
import podstack

@podstack.function(gpu="a100_80gb", requirements=["torch"])
def device_name():
    import torch
    return torch.cuda.get_device_name(0)

print(device_name.deploy(dry_run=True))
print(device_name.invoke(confirm=True))
```

The function has to live in a file. Arguments must be JSON-serializable.
Calling it like a normal function raises `ConfirmationRequired` unless the
decorator was created with `confirm=True`.

## Agents

`podstack.tools()` returns OpenAI, Anthropic, and MCP schemas. Names match
the Podstack CLI. `python -m podstack.mcp` serves those tools on stdio.
`stop_instance` and `start_instance` are listed because the CLI lists them,
and they report that the platform does not keep a stopped machine.

See `examples/` and `AGENTS.md`.

## Version 1.9.0

`deploy` registers a function by name, uploads a cloudpickle version, and
activates it. `invoke` starts `POST /functions/{id}/runs` and unpickles the
result. See `CHANGELOG.md`.

1.8.0 removed the previous notebook SDK. There are no deprecated shims for
routes the platform does not serve. The removed modules are listed in
`docs/audit.md`.

Async code uses `AsyncPodstack`. The method names match the sync client.

```python
import asyncio
from podstack import AsyncPodstack

async def main():
    async with AsyncPodstack() as client:
        print(await client.gpus.list())

asyncio.run(main())
```

## Development

```bash
python -m pip install -e ".[dev]"
python -m ruff check src tests examples
python -m mypy
python -m pytest
python -m build
twine check dist/*
```

This directory is the root of the standalone package. The release workflow is
`.github/workflows/release.yml`. It runs on a `v*` tag and on manual dispatch.
It does not publish from a pull request. Tag publish uses PyPI Trusted
Publishing (environment `pypi`, `id-token: write`) and falls back to the
`PYPI_API_TOKEN` secret when that secret is set. Manual dispatch also uploads
the built distributions to TestPyPI.
