# Podstack Python SDK

Client for https://podstack.ai/api/v1. Package `podstack` on PyPI.

Auth: `Authorization: Bearer`. Key from `Podstack(api_key=)`, `PODSTACK_API_KEY`, or `~/.config/podstack/credentials.json`. Prefixes `ps_live_` and `psk_`. Base override `PODSTACK_API_BASE`. Do not call api.podstack.ai.

Billable and destructive methods need `confirm=True`. `dry_run=True` previews the JSON and sends nothing. Reads do not need confirm.

Do not invent GPU specs or prices. Read `client.gpus.list()`, `client.rates.list()` (`price_per_hour`), `client.job_gpus.list()`, `client.models.list()`.

No instance stop/start. No dataset upload. No instance exec HTTP API. SSH and SCP use the command string on the instance. Terminate to stop billing.

Functions: `@podstack.function(gpu, image="", requirements=, name=, timeout=3600, confirm=False)`. `deploy`, `invoke`, `ainvoke`, `local`, `logs`, `delete`. POST `/functions` then POST `/functions/{name}/invoke`. CLI only lists functions.

Wallet: `client.wallet.balance()`, `client.wallet.transactions()`. 404 is `NotAvailableYet`. `credit_cents` converts to USD only when `balance` is absent. Debits are negative.

Inference: `client.chat.completions`, `client.chat.stream`, `client.embeddings.create`, `client.images.generate`. OpenAI-shaped bodies on the same API base. Model ids are URL-encoded as one path segment.

Agents: `podstack.tools()` keys `openai`, `anthropic`, `mcp`. MCP entrypoint `python -m podstack.mcp`. Tool names match the CLI, including `stop_instance` and `start_instance`, which report not available.

Async: `AsyncPodstack` with the same method names.

Errors: `PodstackError`, `AuthenticationError`, `PermissionDenied`, `NotFoundError`, `ValidationError`, `RateLimitError`, `InsufficientBalance`, `GPUNotAvailableError`, `NotAvailableYet`, `ConfirmationRequired`, `CommandFailed`.

Docs in this repo: `README.md`, `AGENTS.md`, `docs/functions.md`, `docs/audit.md`, `examples/`.
