Metadata-Version: 2.5
Name: runpod-vllm-deployer
Version: 0.2.0
Summary: A safe Python CLI for deploying OpenAI-compatible vLLM servers on RunPod GPUs.
Project-URL: Homepage, https://github.com/1solomonwakhungu/runpod-vllm-deployer
Project-URL: Repository, https://github.com/1solomonwakhungu/runpod-vllm-deployer
Project-URL: Issues, https://github.com/1solomonwakhungu/runpod-vllm-deployer/issues
Project-URL: Changelog, https://github.com/1solomonwakhungu/runpod-vllm-deployer/blob/main/CHANGELOG.md
Author: Solomon Wakhungu
License: Copyright 2026 Solomon Wakhungu
        
                                         Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           APPENDIX: How to apply the Apache License to your work.
        
              To apply the Apache License to your work, attach the following
              boilerplate notice, with the fields enclosed by brackets "[]"
              replaced with your own identifying information. (Don't include
              the brackets!)  The text should be enclosed in the appropriate
              comment syntax for the file format. We also recommend that a
              file or class name and description of purpose be included on the
              same "printed page" as the copyright notice for easier
              identification within third-party archives.
        
           Copyright [yyyy] [name of copyright owner]
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: System :: Systems Administration
Requires-Python: >=3.11
Requires-Dist: httpx<1,>=0.27
Requires-Dist: typer<1,>=0.16
Provides-Extra: dev
Requires-Dist: build<2,>=1.2; extra == 'dev'
Requires-Dist: mypy<3,>=1.15; extra == 'dev'
Requires-Dist: pytest-cov<8,>=6; extra == 'dev'
Requires-Dist: pytest<10,>=8.3; extra == 'dev'
Requires-Dist: python-semantic-release<11,>=10.5; extra == 'dev'
Requires-Dist: respx<1,>=0.22; extra == 'dev'
Requires-Dist: ruff<1,>=0.11; extra == 'dev'
Description-Content-Type: text/markdown

# RunPod vLLM Deployer

[![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-3776AB.svg)](https://www.python.org/)
[![Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
[![skills.sh](https://skills.sh/b/1solomonwakhungu/runpod-vllm-deployer)](https://skills.sh/1solomonwakhungu/runpod-vllm-deployer)

**Spin up and tear down OpenAI-compatible vLLM servers on RunPod GPU Pods without leaking GPU bills or debugging 502 startup errors.**

A lightweight Python CLI (`httpx` + `typer`, zero daemon, zero SSH) and portable AI Agent Skill built for RunPod REST API v2. Plan offline, confirm before anything billable, verify `/health` + `/v1/models` + a deterministic chat smoke test, and confirm the Pod is actually gone before local state is removed.

[Project Site](https://runpod-vllm-deployer.vercel.app) | [Quickstart](docs/quickstart.md) | [Configuration](docs/configuration.md) | [Security Model](docs/security.md) | [Agent Skill](https://skills.sh/1solomonwakhungu/runpod-vllm-deployer)

> **Billing note:** RunPod GPU Pods are billable until terminated. Review [RunPod's live GPU pricing](https://www.runpod.io/pricing) before confirming a deploy.

---

## Why this exists

Deploying vLLM on RunPod Pods by hand or letting an AI coding agent run raw API calls usually breaks in two ways:

1. **You spin up a Pod you did not mean to, or lose track of one that is still billing.**
2. **RunPod reports `RUNNING` while vLLM is still downloading weights**, so requests hit HTTP 502 on `.proxy.runpod.net` or fail later on bad vLLM flags.

`runpod-vllm` closes both gaps with a strict five-step lifecycle (`plan -> deploy -> wait -> smoke-test -> destroy`):

- **Offline planning first:** `plan` validates every flag (model ID, GPU profile, tensor-parallel divisibility, disk/RAM/context bounds, non-`latest` image tag) and prints the exact redacted RunPod REST payload with **no API key and no network call**.
- **Approval gates before spend or teardown:** Only `deploy` creates a billable Pod and only `destroy` deletes one. Both prompt interactively unless you explicitly pass `--yes`.
- **Teardown-first atomic state:** Immediately after `POST /pods` returns a Pod ID, the CLI writes `.runpod-vllm-state.json` atomically with mode `0600` (never storing credentials). If creation times out, returns 5xx, or state saving fails, it never blindly retries the billable `POST` and prints an explicit recovery command.
- **Verified readiness and teardown:** `wait` polls both `/health` and `/v1/models`, `smoke-test` sends a deterministic 4-token `/v1/chat/completions` request, and `destroy` polls RunPod until HTTP 404 or `TERMINATED` before deleting local state.
- **RunPod REST v2 native + 429 retries:** Automatically targets RunPod REST API v2 (`https://api.runpod.io/v2`) following the 2026-11-15 v1 retirement, migrates older v1 state files on `status`/`destroy`, and retries HTTP 429 responses with `Retry-After` / jittered exponential backoff.
- **Built for humans and AI agents:** Ships a portable [Agent Skill](skills/runpod-vllm-gpu-deploy/SKILL.md) and Claude Code project skill with hard safety boundaries and stable exit codes (`0` OK, `2` Usage, `3` Config, `4` Auth, `5` Network, `6` API, `7` Timeout, `8` State).

## Try it offline in 30 seconds

No `RUNPOD_API_KEY` required. Validate a config and inspect the exact RunPod REST v2 payload before spending a cent:

```bash
runpod-vllm plan \
  --model Qwen/Qwen3-8B \
  --gpu A40 \
  --max-model-len 8192
```

Example output (offline; no API call):

```json
{
  "cloud": "SECURE",
  "disk": 50,
  "entrypoint": [
    "vllm",
    "serve",
    "Qwen/Qwen3-8B",
    "--host",
    "0.0.0.0",
    "--port",
    "8000",
    "--tensor-parallel-size",
    "1",
    "--max-model-len",
    "8192",
    "--gpu-memory-utilization",
    "0.9",
    "--dtype",
    "auto",
    "--kv-cache-dtype",
    "auto"
  ],
  "env": {},
  "gpu": {
    "count": 1,
    "id": "NVIDIA A40",
    "minRamPerGpu": 16,
    "minVcpuCountPerGpu": 4
  },
  "image": "vllm/vllm-openai:v0.19.1",
  "mounts": {
    "persistent": {
      "path": "/workspace",
      "size": 40
    }
  },
  "name": "vllm-server",
  "ports": [
    "8000/http"
  ]
}
```

## Installation

Python 3.11 or newer is required.

### Release wheel (v0.1.0)

Each release on the [Releases page](https://github.com/1solomonwakhungu/runpod-vllm-deployer/releases) includes a wheel and source distribution:

```bash
python -m pip install https://github.com/1solomonwakhungu/runpod-vllm-deployer/releases/download/v0.1.0/runpod_vllm_deployer-0.1.0-py3-none-any.whl
runpod-vllm --help
```

<!-- Move this block above "Release wheel" once v0.1.0 is published to PyPI via RELEASING.md -->
### PyPI (once published)

```bash
python -m pip install runpod-vllm-deployer
# Or run offline planning with uvx without creating a virtualenv:
uvx --from runpod-vllm-deployer runpod-vllm plan --model Qwen/Qwen3-8B --gpu A40
```

### From source

```bash
git clone https://github.com/1solomonwakhungu/runpod-vllm-deployer.git
cd runpod-vllm-deployer
python3 -m venv .venv
source .venv/bin/activate
python -m pip install .
runpod-vllm --help
```

For development, run `make setup` instead of `python -m pip install .`.

## Five-minute quickstart

1. **Create a local `.env` file** (ignored by Git):

   ```bash
   cp .env.example .env
   # Set RUNPOD_API_KEY in .env (and optional HF_TOKEN for gated models).
   ```

2. **Plan offline** (no API key, no network request):

   ```bash
   runpod-vllm plan \
     --model Qwen/Qwen3-8B \
     --gpu A40 \
     --max-model-len 8192
   ```

3. **Deploy** (billable; prompts for confirmation):

   ```bash
   runpod-vllm --env-file .env deploy \
     --model Qwen/Qwen3-8B \
     --gpu A40 \
     --max-model-len 8192
   ```

4. **Wait for vLLM readiness and run the smoke test:**

   ```bash
   runpod-vllm --env-file .env status
   runpod-vllm wait --timeout 900
   runpod-vllm smoke-test
   ```

5. **Call your OpenAI-compatible endpoint** using the `Base URL` printed by `status` (`https://<POD_ID>-8000.proxy.runpod.net`):

   With `curl`:

   ```bash
   curl https://<POD_ID>-8000.proxy.runpod.net/v1/chat/completions \
     -H "Content-Type: application/json" \
     -d '{
       "model": "Qwen/Qwen3-8B",
       "messages": [{"role": "user", "content": "Hello from RunPod vLLM!"}]
     }'
   ```

   Or with the Python `openai` SDK:

   ```python
   from openai import OpenAI

   client = OpenAI(base_url="https://<POD_ID>-8000.proxy.runpod.net/v1", api_key="EMPTY")
   response = client.chat.completions.create(
       model="Qwen/Qwen3-8B", messages=[{"role": "user", "content": "Hello from RunPod vLLM!"}]
   )
   print(response.choices[0].message.content)
   ```

6. **Tear down and verify the Pod is gone:**

   ```bash
   runpod-vllm --env-file .env destroy
   ```

For unattended runs after reviewing the plan, pass `--yes` (`-y`) to `deploy` or `destroy`.

## How it compares

| Approach | Setup footprint | Offline plan + secret redaction | vLLM readiness + smoke test | Verified teardown | AI Agent Skill |
| --- | --- | --- | --- | --- | --- |
| **`runpod-vllm-deployer`** | 2 Python deps (`httpx`, `typer`), zero daemon | Yes | Yes (`/health`, `/v1/models`, chat completion) | Yes (polls until 404 or `TERMINATED`) | Yes (`skills.sh` + Claude Code) |
| **RunPod Web UI / `runpodctl`** | Browser or Go CLI | No | Manual | Manual | No |
| **SkyPilot / dstack** | Multi-cloud stack or control-plane server | YAML config | Custom script | Orchestrator-managed | No |

Use `runpod-vllm-deployer` when you want a fast, auditable, RunPod-native CLI for ephemeral OpenAI-compatible vLLM Pods without standing up a multi-cloud orchestrator.

## Commands

Global options (`--state-path`, `--env-file`, `--api-url`, `--api-version`) must appear **before** the subcommand.

| Command | Network | Mutates RunPod | Purpose |
| --- | --- | --- | --- |
| `plan` | No | No | Validate configuration and print a redacted payload |
| `deploy` | Yes | Yes, billable | Create a GPU Pod and immediately save teardown state |
| `status` | Yes | No | Inspect the recorded Pod and display access URLs |
| `wait` | Yes | No | Poll `/health` and `/v1/models` until ready |
| `smoke-test` | Yes | No | Send a four-token deterministic chat request |
| `list` | Yes | No | List active GPU Pods |
| `destroy` | Yes | Yes | Delete, verify absence, then remove matching state |

The default state file is `.runpod-vllm-state.json`. Pass `--state-path PATH` before the command to manage multiple Pods from the same directory.

## Supported GPUs and configuration

Supported `--gpu` profiles: `A40`, `L40S`, `A100` (SXM4 80GB), `H100` (80GB HBM3), `H200`, and `B200` (1 to 8 GPUs with validated `--tensor-parallel-size`).

- **Pinned default image:** `vllm/vllm-openai:v0.19.1`. Override with `--image REPOSITORY:TAG` (`:latest` is rejected).
- **vLLM & placement options:** `--revision`, `--max-model-len`, `--gpu-memory-utilization`, `--dtype`, `--quantization`, `--kv-cache-dtype`, `--trust-remote-code`, `--reasoning-parser`, `--container-disk-gb`, `--volume-gb`, `--min-vcpu-per-gpu`, `--min-ram-per-gpu`, `--cloud-type` (`SECURE` or `COMMUNITY`), repeatable `--data-center`, `--port`, and repeatable `--env KEY=VALUE`.
- **Sizing note:** GPU profiles map to RunPod GPU type IDs and do not guarantee a checkpoint fits. Verify checkpoint VRAM, quantization, KV cache, and tensor-parallel requirements against model and vLLM documentation.

See [docs/configuration.md](docs/configuration.md) for all flags and [examples/](examples/) for single-GPU and multi-GPU commands.

### RunPod REST API v2

RunPod retired REST API v1 (`https://rest.runpod.io/v1`) on **2026-11-15**. The CLI automatically defaults to REST API v2 (`https://api.runpod.io/v2`) from that date onward and automatically moves older v1 state files to v2 on `status` and `destroy` using the same Pod ID. You can still set `--api-version` or `RUNPOD_API_VERSION` explicitly when needed. See [docs/configuration.md#runpod-rest-api-version](docs/configuration.md#runpod-rest-api-version) for field mappings.

## AI agent skills

Give Claude Code or any Agent Skills-compatible coding agent safe RunPod GPU operations with built-in approval gates:

```bash
npx skills add 1solomonwakhungu/runpod-vllm-deployer --skill runpod-vllm-gpu-deploy
```

- Portable skill: [skills/runpod-vllm-gpu-deploy/SKILL.md](skills/runpod-vllm-gpu-deploy/SKILL.md)
- Claude Code project skill: [.claude/skills/runpod-vllm-gpu-deploy/SKILL.md](.claude/skills/runpod-vllm-gpu-deploy/SKILL.md) (kept byte-identical by automated tests)

This installs the agent instructions, not the Python package. Install `runpod-vllm` first so the agent can invoke the CLI.

## Architecture and security

```mermaid
flowchart LR
    CLI[Typer CLI] --> CFG[Validation and configuration]
    CFG --> PAYLOAD[Payload builder v1/v2]
    CLI --> API[RunPod REST client + 429 retry]
    API --> RUNPOD[RunPod Pods API]
    CLI --> STATE[Atomic 0600 teardown state]
    CLI --> READY[Readiness and smoke checks]
    READY --> VLLM[OpenAI-compatible vLLM endpoint]
```

- Credentials are read only from `RUNPOD_API_KEY`, optional `HF_TOKEN`, optional `VLLM_API_KEY` (or `--bearer-token-env`), or an explicit `--env-file`.
- Secrets are never written to state files; plans and network diagnostics redact sensitive keys, bearer tokens, and URL credentials on a best-effort basis.
- Deep dives: [Architecture](docs/architecture.md) | [Lifecycle Safety](docs/lifecycle.md) | [Security](docs/security.md) | [Troubleshooting](docs/troubleshooting.md)

## Development and testing

No test contacts RunPod. The offline suite exercises mocked HTTP responses, REST v2 cutover, agent skill parity, and lifecycle fault injection (`429`, `502`/`503`/`504`, timeouts, and state-save failures).

```bash
make setup
make check
```

Individual targets: `make test`, `make lint`, `make format`, `make typecheck`. Releases are automated; see [RELEASING.md](RELEASING.md) and [CHANGELOG.md](CHANGELOG.md).

## Contributing & License

Contributions are welcome. Read [CONTRIBUTING.md](CONTRIBUTING.md) and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md), then run `make check` before opening a pull request. Report vulnerabilities via [SECURITY.md](SECURITY.md).

Licensed under the [Apache License 2.0](LICENSE). Copyright 2026 Solomon Wakhungu.
