Metadata-Version: 2.4
Name: runpod-llm-starter
Version: 0.1.0
Summary: Deploy a private LLM on RunPod and manage it from a desktop console.
Author: Kevin Cherry
License-Expression: MIT
Project-URL: Homepage, https://github.com/kcherry497/runpod-llm-starter
Project-URL: Issues, https://github.com/kcherry497/runpod-llm-starter/issues
Project-URL: Changelog, https://github.com/kcherry497/runpod-llm-starter/blob/main/CHANGELOG.md
Keywords: runpod,tailscale,ollama,llm,gpu,pyside6
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: X11 Applications :: Qt
Classifier: Intended Audience :: Developers
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: PySide6-Essentials>=6.6
Requires-Dist: keyring>=24
Requires-Dist: runpodkit>=0.3
Requires-Dist: tailscalekit>=0.1
Dynamic: license-file

<p align="center">
  <img src="https://raw.githubusercontent.com/kcherry497/runpod-llm-starter/main/docs/screenshots/home.png" alt="The LLM Starter console" width="100%">
</p>

<h1 align="center">LLM Starter: your own model on RunPod, reachable only by you</h1>

<p align="center">
  <img src="https://img.shields.io/badge/python-3.10%2B-3776AB?logo=python&logoColor=white" alt="Python 3.10+">
  <img src="https://img.shields.io/badge/Qt-PySide6-41CD52?logo=qt&logoColor=white" alt="PySide6">
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT license"></a>
  <a href="https://pypi.org/project/runpod-llm-starter/"><img src="https://img.shields.io/pypi/v/runpod-llm-starter" alt="PyPI"></a>
</p>

A desktop console that takes you from nothing to chatting with an open model on a rented GPU, in a
few clicks, without exposing the model to the internet or pasting API keys into an app.

1. **Connect your accounts once.** RunPod and Tailscale (Docker optional). Keys are stored on your
   computer only, encrypted with [cred-broker](https://github.com/kcherry497/cred-broker) or your OS
   keyring. A separate worker process uses them; the console never stores, shows or logs them.
2. **Pick a model.** A curated list of [Ollama](https://ollama.com/library) models, or any tag you like.
   The console shows how much VRAM it needs and the cheapest GPUs in stock that fit, with live prices.
3. **Deploy.** The pod joins your private [Tailscale](https://tailscale.com/) network with a
   single-use key that is revoked the moment it has joined. Ollama listens on the pod's loopback
   only; no port is opened to the internet.
4. **Chat.** Straight from the console, or point any Ollama client at the URL it shows you.
5. **Stop paying.** My Pods shows what's running and what it costs; terminate cleans up the pod and
   its tailnet device. Optional auto-stop catches the pod you forgot.

![Architecture](https://raw.githubusercontent.com/kcherry497/runpod-llm-starter/main/docs/architecture.svg)

## Quick start

You need accounts at **RunPod** (with credit) and **Tailscale** (free), with Tailscale installed and
signed in on this computer.

```bash
pipx install runpod-llm-starter
llmstarter
```

On Linux, Qt needs a few system libraries that most desktops already have (on a bare Debian or
Ubuntu: `sudo apt install libegl1 libxkbcommon0 libfontconfig1`).

Then, in the console:

1. **Credentials.** Choose cred-broker (recommended if an AI agent works on this machine) or the OS
   keyring, and add a [RunPod API key](https://www.runpod.io/console/user/settings) and a
   [Tailscale API key](https://login.tailscale.com/admin/settings/keys).
2. **Deploy LLM on RunPod.** Start with *Qwen 2.5 0.5B*: it costs a few cents to try the whole chain.
3. **Chat now.**

> [!IMPORTANT]
> **Lock down your tailnet first.** Ollama has no authentication. Tailscale's default policy lets
> every device reach every other device, and the console warns you when yours still does. Add this to
> your [tailnet policy](https://login.tailscale.com/admin/acls):
>
> ```jsonc
> "tagOwners": { "tag:llm-starter": ["autogroup:admin"] },
> "grants": [ { "src": ["autogroup:member"], "dst": ["tag:llm-starter"], "ip": ["tcp:11434"] } ]
> ```
>
> Allow rules add up: this grant isolates the pod **only once you remove or narrow the broad
> allow-all rule** (`"src": ["*"], "dst": ["*"]` in the default policy). Then your devices can reach
> the model on port 11434 and the pod can reach nothing of yours. With the tag owned, deploys also
> survive stop/start; without it, the console falls back to ephemeral nodes and warns you.

## What's in the box

| Piece | What it is | Reuse it on its own |
| --- | --- | --- |
| Console (`llmstarter`) | PySide6 app: Deploy, Credentials, My Pods, Chat, Tailnet | `pipx install …`, then `llmstarter` |
| Worker (`llmstarter.worker`) | The process that holds keys and does the work; JSON lines ([protocol](docs/PROTOCOL.md)) | drive it from any language |
| [`image/`](image/) | `llm-starter-ollama`: Ollama + Tailscale, loopback-only, key never in env or argv | any RunPod pod or container host |
| [runpodkit](https://github.com/kcherry497/runpod-kit) | RunPod control: GPU prices, money-safe create, stale-port-safe SSH | `pipx install runpodkit` |
| [tailscalekit](https://github.com/kcherry497/tailscale-kit) | Tailscale control: single-use keys, device cleanup, policy check | `pip install tailscalekit` |
| [cred-broker](https://github.com/kcherry497/cred-broker) | Let a program (or an AI agent) use a key without ever seeing it | standalone |

## Security model

- **The console never holds a key.** With cred-broker it never sees one at all; with the OS keyring
  it hands what you paste straight to the keyring. It launches a worker under `cred exec` (or a keyring shim) and
  talks to it over JSON; every line the worker writes is redacted.
- **The pod gets one single-use Tailscale auth key**, which the image hands to Tailscale
  through a private file (never the command line) and removes from its environment before Ollama
  starts. The console revokes it as soon as the pod has joined.
- **No public ports** (in the default Tailscale mode; the optional RunPod-proxy mode is
  unauthenticated and for quick tests only). Ollama binds `127.0.0.1` in the pod; Tailscale delivers your traffic to it.
  You reach it at the pod's IPv6 tailnet address (`http://[fd7a:…]:11434`), which Ollama's
  DNS-rebinding guard accepts (it refuses `100.x` Host headers on a loopback bind).
- **Money safety.** A create that times out is never retried (it may have made a pod); a failed or
  cancelled deploy terminates what it created; a deploy journal flags pods left behind if the console
  was killed mid-deploy; stopped pods are flagged because their volume still bills. Auto-stop stops
  compute only, and only while the console is running: terminate to stop all billing.

More in [docs/architecture.md](docs/architecture.md).

## Troubleshooting

| Symptom | What to do |
| --- | --- |
| "No GPU of the chosen types was available" | RunPod is out of that GPU right now. Go back to the GPU step and pick another, or try later. |
| The first deploy sits on "Waiting for the pod to start" | The pod is pulling the image (about 9 GB). Measured: about 2 minutes cold, under 30 s cached. The console gives up after 30 minutes and cleans up. |
| "tag:llm-starter is not owned" warning | Add the `tagOwners` line above. Until then the pod joins as an ephemeral node and leaves the tailnet when stopped. |
| `403` from `http://100.x.y.z:11434` | Use the IPv6 URL the console shows (`http://[fd7a:…]:11434`). Ollama's DNS-rebinding guard refuses `100.x` Host headers on a loopback bind. |
| A red banner in My Pods about a leftover pod | A deploy was interrupted (the console was killed or the machine slept). Terminate the pod from the banner. |
| A stopped pod still costs money | Its volume bills while it exists. Terminate it when you're done. |

## Development

```bash
python3 -m venv .venv && .venv/bin/pip install -e .
QT_QPA_PLATFORM=offscreen .venv/bin/python -m unittest discover -s tests -v
```

Two live tests deploy a real pod on the cheapest fitting GPU, chat with it, and terminate it. They **bill
your RunPod account** (a few cents) and refuse to run without `LLMSTARTER_E2E_BILLS=1`. Both read
`RUNPOD_API_KEY` and `TS_API_KEY` from the environment.

```bash
LLMSTARTER_E2E_BILLS=1 .venv/bin/python scripts/e2e.py                   # through the worker protocol
LLMSTARTER_E2E_BILLS=1 .venv/bin/python scripts/gui_e2e.py /tmp/shots    # clicks through the real GUI
GUI_E2E_DRY=1 .venv/bin/python scripts/gui_e2e.py /tmp/shots             # free rehearsal: cancels at billing
```

## License

MIT. Not affiliated with or endorsed by RunPod, Tailscale or Ollama.
