Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
92f0188
feat: add app-centric sdk surface with queue/api/task decorators
KAJdev Jul 1, 2026
a51a633
feat: add deploy pipeline, dev sessions, and rp cli
KAJdev Jul 1, 2026
7f0a45a
feat: bind dev templates to endpoints and verify live execution e2e
KAJdev Jul 1, 2026
f97280b
feat: add dev session refresh with file watching and storage-supporte…
KAJdev Jul 1, 2026
cce0176
feat: add pod task execution with runtime images and single-shot runner
KAJdev Jul 2, 2026
a5a3a75
feat: add custom image support for queue endpoints via bootstrap shim
KAJdev Jul 2, 2026
32dea10
feat: add queue runtime image and dev tag channel for runtime images
KAJdev Jul 2, 2026
948e49f
fix: install full package deps in runtimes test job
KAJdev Jul 2, 2026
eccea06
fix: filter lazy socket resource warnings in runner http tests
KAJdev Jul 2, 2026
f1814dd
fix: disable unraisable plugin in runtimes test job
KAJdev Jul 2, 2026
ad98a6d
feat: add api runtime server and unified bootstrap entrypoint
KAJdev Jul 2, 2026
3716886
fix: upgrade stale runpod installs in bootstrap and forward package spec
KAJdev Jul 2, 2026
62cc621
feat: probe interpreters and fetch standalone python in image shim
KAJdev Jul 2, 2026
b51a03a
fix: pretend scm version for tarball installs in bootstrap
KAJdev Jul 2, 2026
e74b604
fix: fail loudly on pythonless custom images instead of fetching an i…
KAJdev Jul 2, 2026
fe7a492
feat: vendor full runtime environment into artifacts at deploy time
KAJdev Jul 2, 2026
55dd9d4
feat: support python 3.10-3.14 with per-version gpu runtime images
KAJdev Jul 2, 2026
9538f6e
fix: use tarfile data filter for artifact extraction
KAJdev Jul 2, 2026
f2e0da5
feat: reconcile flash-bound endpoints during deploy
KAJdev Jul 2, 2026
7818704
feat: retry transient http failures and harden discovery scans
KAJdev Jul 2, 2026
dd2f0fd
fix: gpu driver injection, pool id expansion for pods, and job results
KAJdev Jul 2, 2026
c9872cb
fix: import List in tasks module
KAJdev Jul 2, 2026
4290a02
fix: fall back to RUNPOD_API_KEY env for module api key
KAJdev Jul 2, 2026
d3274ee
feat: pod log access via hapi and storage-dc pinning for gpu deploys
KAJdev Jul 2, 2026
5feb566
fix: pin cu128 torch wheels in gpu base image
KAJdev Jul 2, 2026
9c222ff
fix: pin cp310 torch stack on cu128 index
KAJdev Jul 2, 2026
a5f89f2
fix: pin cu128 torch stack via extra index across all python versions
KAJdev Jul 2, 2026
5d0f47c
fix: retry proxy 404 propagation races on task execute
KAJdev Jul 2, 2026
e847a0f
feat: pretty cli console with dev lifecycle events and deploy phases
KAJdev Jul 2, 2026
264b984
feat: unify runpod and rp entry points with grouped help panels
KAJdev Jul 3, 2026
db7d26f
feat: rich help rendering for legacy click subcommands
KAJdev Jul 3, 2026
fcd4a6a
fix: render click usage errors instead of tracebacks
KAJdev Jul 3, 2026
0be0f2f
refactor: single plain-click command tree without help panels
KAJdev Jul 3, 2026
abc0024
fix: expand gpu any to pool ids and quiet the dev loop ui
KAJdev Jul 3, 2026
b70f898
fix: async-safe awaitable driving, console links, quieter dev ui
KAJdev Jul 3, 2026
51d7ca5
feat: full console urls in deploy and dev summaries
KAJdev Jul 3, 2026
dc06b01
feat: live vendor package feed, upload bar, and upload retries in deploy
KAJdev Jul 4, 2026
1191bdf
feat: ship full module source in dev, worker monitor feed, sleeker de…
KAJdev Jul 4, 2026
142d03b
fix: tee function stdout to container logs and name interleaved dev f…
KAJdev Jul 4, 2026
6ebd36a
feat: stream worker stdout into rp dev with request-style lifecycle l…
KAJdev Jul 6, 2026
07e7fee
feat: nested dev calls, realtime log attach, refresh diffs
KAJdev Jul 6, 2026
789e471
fix: install runpod package in task runtime images
KAJdev Jul 6, 2026
8d350c1
fix: keyless dev payload construction
KAJdev Jul 6, 2026
ab4c10c
ci: disable fail-fast on runtime image matrix
KAJdev Jul 6, 2026
e1dfc83
ci: build runtime images even when gpu-base rebuild fails
KAJdev Jul 6, 2026
ff7c1b3
fix: make shipped module source inspectable for nested remote calls
KAJdev Jul 6, 2026
03c6cb3
fix: re-ship materialized module source on nested dev hops
KAJdev Jul 6, 2026
16ff3e8
feat: live api routes via source sync endpoint
KAJdev Jul 6, 2026
2d1bc64
fix: cancellable entrypoint with spinner-based session cleanup
KAJdev Jul 6, 2026
c2a25ae
feat: app and environment management, undeploy, and browser login
KAJdev Jul 6, 2026
c028747
feat: task lifecycle streaming in dev, long tasks via submit-poll
KAJdev Jul 6, 2026
a52577f
feat: task pod self-termination watchdog for abandoned clients
KAJdev Jul 6, 2026
54919bf
fix: keep task event sink attached across dev reloads
KAJdev Jul 6, 2026
4dcf329
fix: bind entrypoint exception before marshalling to the loop
KAJdev Jul 6, 2026
51f3317
feat: resolve gpu shorthand strings to device names and pools
KAJdev Jul 6, 2026
85f17db
feat: network volumes with app-wide placement solve
KAJdev Jul 7, 2026
5b46d61
feat: platform secrets with env rendering and rp secret cli
KAJdev Jul 7, 2026
5430107
feat: wrangler-style prompting for rp secret add
KAJdev Jul 7, 2026
a418531
feat: registry credentials with name resolution and rp registry cli
KAJdev Jul 7, 2026
be5d7e9
feat: platform-cached model references
KAJdev Jul 7, 2026
245e2d6
docs: apps-first readme and example suite doubling as e2e tests
KAJdev Jul 7, 2026
aefc85b
style: refine dev cli output
KAJdev Jul 8, 2026
db500aa
style: restore log stream pipe
KAJdev Jul 8, 2026
b9d5ef8
feat: add endpoint config params, rp init, rp update, and build-only …
KAJdev Jul 8, 2026
0f5ca89
docs: simplify readme
KAJdev Jul 8, 2026
d0ef53c
refactor: split showcase examples from the e2e example suite
KAJdev Jul 8, 2026
5a301bd
fix: anonymous login polling and local-python deploy default
KAJdev Jul 8, 2026
c657720
fix: retry proxy propagation 404s when polling task results
KAJdev Jul 8, 2026
3c6e9a7
fix: install resource dependencies on live api sync
KAJdev Jul 9, 2026
389dfa5
perf: cache dependency layers and skip gpu-base rebuilds for code-onl…
KAJdev Jul 9, 2026
5b5e96a
refactor: drop the config wizard and exec command group
KAJdev Jul 9, 2026
08d4ab9
refactor: standardize cli verbs to add/list/get/delete
KAJdev Jul 9, 2026
5372f90
feat: rp ssh POD_ID opens a pod terminal
KAJdev Jul 9, 2026
b3c5fd7
fix: clean errors for unknown pods and hide the ssh connect alias
KAJdev Jul 9, 2026
90ce271
fix: reject platform-cached models on task resources
KAJdev Jul 9, 2026
6c85a6c
fix: ignore fastapi testclient deprecation warning in pytest
KAJdev Jul 9, 2026
08017fb
test: cover the apps api client, targets, monitor, logs, and queue wo…
KAJdev Jul 9, 2026
c79afbc
test: cover console rendering
KAJdev Jul 9, 2026
5c423b0
test: cover deploy and dev command wiring
KAJdev Jul 9, 2026
6bbbe6b
test: cover bootstrap error surface, task lifecycle, and update inter…
KAJdev Jul 9, 2026
e795635
test: cover task runner self-termination and install helpers
KAJdev Jul 9, 2026
b031fb1
Merge remote-tracking branch 'origin/main' into feat/apps-sdk
KAJdev Jul 9, 2026
3397a3e
fix: address codeql alerts on raises, tar links, and duplicate tests
KAJdev Jul 9, 2026
1e145e8
ci: skip duplicate runtime image builds on same-repo prs
KAJdev Jul 9, 2026
43b5956
ci: publish runtime images on release instead of per pr
KAJdev Jul 9, 2026
7c3cc21
feat: job parity, streaming, and unified execution engine
KAJdev Jul 10, 2026
e5fea5e
refactor: extract apps graphql documents into api query and mutation …
KAJdev Jul 10, 2026
6ed7ca2
refactor: consolidate shared apps helpers into utils package
KAJdev Jul 10, 2026
68df2ce
feat: lazy top-level imports and curated runtime vendoring
KAJdev Jul 10, 2026
2a47e0e
feat: per-job queue options via with_options
KAJdev Jul 10, 2026
e8521ed
test: shell example runner with dev, deploy, and local modes
KAJdev Jul 10, 2026
8adc6c2
fix: address codeql and review findings across apps and runtimes
KAJdev Jul 10, 2026
3df2237
fix: address remaining apps sdk review findings
KAJdev Jul 13, 2026
ae6182d
fix: clean up apps sdk imports
KAJdev Jul 13, 2026
1ad2a48
fix: resolve apps sdk codeql findings
KAJdev Jul 13, 2026
08c8c83
refactor: consume independently released sdk runtimes
KAJdev Jul 27, 2026
938eb6f
fix: support sdk source archives in runtime launcher
KAJdev Jul 27, 2026
f8377e3
feat: group apps commands under flash
KAJdev Jul 27, 2026
3b015ab
chore: merge main into apps sdk
KAJdev Jul 27, 2026
eef269e
fix: stabilize apps production execution
KAJdev Jul 28, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# keep the runtime image build context to what pip install needs:
# package source, metadata, and the files setup.py/MANIFEST.in read
.git
.github
.venv
build
benchmark_results
docs
examples
job_files
scripts
tests
uv.lock
**/__pycache__
**/*.pyc
*.egg-info
326 changes: 50 additions & 276 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,315 +1,89 @@
<div align="center">
<h1>Runpod | Python Library </h1>

[![PyPI Package](https://badge.fury.io/py/runpod.svg)](https://badge.fury.io/py/runpod)
&nbsp;
[![Downloads](https://static.pepy.tech/personalized-badge/runpod?period=total&units=international_system&left_color=grey&right_color=blue&left_text=Downloads)](https://pepy.tech/project/runpod)
<h1>Runpod Python</h1>

[![CI | End-to-End Runpod Python Tests](https://github.com/runpod/runpod-python/actions/workflows/CI-e2e.yml/badge.svg)](https://github.com/runpod/runpod-python/actions/workflows/CI-e2e.yml)
**Define GPU functions in Python. Run them in the cloud with one decorator.**

[![PyPI Package](https://badge.fury.io/py/runpod.svg)](https://badge.fury.io/py/runpod)
[![Downloads](https://static.pepy.tech/personalized-badge/runpod?period=total&units=international_system&left_color=grey&right_color=blue&left_text=downloads)](https://pepy.tech/project/runpod)
[![CI | Unit Tests](https://github.com/runpod/runpod-python/actions/workflows/CI-pytests.yml/badge.svg)](https://github.com/runpod/runpod-python/actions/workflows/CI-pytests.yml)
&nbsp;
[![CI | CodeQL](https://github.com/runpod/runpod-python/actions/workflows/CI-codeql.yml/badge.svg)](https://github.com/runpod/runpod-python/actions/workflows/CI-codeql.yml)

</div>

Welcome to the official Python library for Runpod API &amp; SDK.

## Table of Contents

- [Table of Contents](#table-of-contents)
- [💻 | Installation](#--installation)
- [⚡ | Serverless Worker (SDK)](#--serverless-worker-sdk)
- [Quick Start](#quick-start)
- [Local Test Worker](#local-test-worker)
- [📚 | API Language Library (GraphQL Wrapper)](#--api-language-library-graphql-wrapper)
- [Endpoints](#endpoints)
- [GPU Cloud (Pods)](#gpu-cloud-pods)
- [📁 | Directory](#--directory)
- [🤝 | Community and Contributing](#--community-and-contributing)

## 💻 | Installation

### Install from PyPI (Stable Release)

```bash
# Install with pip
pip install runpod

# Install with uv (faster alternative)
uv add runpod
```

### Install from GitHub (Latest Changes)

To get the latest changes that haven't been released to PyPI yet:

```bash
# Install latest development version from main branch with pip
pip install git+https://github.com/runpod/runpod-python.git

# Install with uv
uv add git+https://github.com/runpod/runpod-python.git

# Install a specific branch
pip install git+https://github.com/runpod/runpod-python.git@branch-name

# Install a specific tag/release
pip install git+https://github.com/runpod/runpod-python.git@v1.0.0

# Install in editable mode for development
git clone https://github.com/runpod/runpod-python.git
cd runpod-python
pip install -e .
```

*Python 3.10 or higher is required to use the latest version of this package.*

## ⚡ | Serverless Worker (SDK)

This python package can also be used to create a serverless worker that can be deployed to Runpod as a custom endpoint API.
[![License](https://img.shields.io/badge/License-MIT-blue)](LICENSE)

### Quick Start
[Documentation](https://docs.runpod.io) • [Examples](examples/apps) • [Discord](https://discord.gg/pJ3P2DbUUq)

Create a python script in your project that contains your model definition and the Runpod worker start code. Run this python code as your default container start command:

```python
# my_worker.py

import runpod

def is_even(job):

job_input = job["input"]
the_number = job_input["number"]

if not isinstance(the_number, int):
return {"error": "Silly human, you need to pass an integer."}

if the_number % 2 == 0:
return True

return False

runpod.serverless.start({"handler": is_even})
```

Make sure that this file is ran when your container starts. This can be accomplished by calling it in the docker command when you set up a template at [console.runpod.io/serverless/user/templates](https://console.runpod.io/serverless/user/templates) or by setting it as the default command in your Dockerfile.

See our [blog post](https://www.runpod.io/blog/build-basic-serverless-api) for creating a basic Serverless API, or view the [details docs](https://docs.runpod.io/serverless-ai/custom-apis) for more information.

### Local Test Worker
</div>

You can also test your worker locally before deploying it to Runpod. This is useful for debugging and testing.
## Installation

```bash
python my_worker.py --rp_serve_api
pip install runpod # or: uv add runpod
rp login # authenticate once
```

### Worker Fitness Checks
Requires Python 3.10+. Installing the package also installs the `rp` CLI.

Fitness checks allow you to validate your worker environment at startup before processing jobs. If any check fails, the worker exits immediately, allowing your orchestrator to restart it.
## Example

```python
# my_worker.py

import runpod
import torch

# Register fitness checks using the decorator
@runpod.serverless.register_fitness_check
def check_gpu_available():
"""Verify GPU is available."""
if not torch.cuda.is_available():
raise RuntimeError("GPU not available")

@runpod.serverless.register_fitness_check
def check_disk_space():
"""Verify sufficient disk space."""
import shutil
stat = shutil.disk_usage("/")
free_gb = stat.free / (1024**3)
if free_gb < 10:
raise RuntimeError(f"Insufficient disk space: {free_gb:.2f}GB free")

def handler(job):
job_input = job["input"]
# Your handler code here
return {"output": "success"}

# Fitness checks run before handler initialization (production only)
runpod.serverless.start({"handler": handler})
```
from runpod import App, Model, Secret, Volume

**Key Features:**
- Supports both synchronous and asynchronous check functions
- Checks run only once at worker startup (production mode)
- Runs before handler initialization and job processing begins
- Any check failure exits with code 1 (worker marked unhealthy)
app = App("inference")

See [Worker Fitness Checks](https://github.com/runpod/runpod-python/blob/main/docs/serverless/worker_fitness_checks.md) documentation for more examples and best practices.
models = Volume("models", size=100)
llama = Model("meta-llama/Llama-3.1-8B-Instruct")

## 📚 | API Language Library (GraphQL Wrapper)

When interacting with the Runpod API you can use this library to make requests to the API.

```python
import runpod

runpod.api_key = "your_runpod_api_key_found_under_settings"
```

### Endpoints

You can interact with Runpod endpoints via a `run` or `run_sync` method.

#### Basic Usage

```python
endpoint = runpod.Endpoint("ENDPOINT_ID")

run_request = endpoint.run(
{"your_model_input_key": "your_model_input_value"}
# an autoscaling job queue on cloud H100s: weights pre-cached,
# dependencies vendored at deploy time, scale-to-zero when idle
@app.queue(
gpu="H100",
workers=(0, 3),
dependencies=["vllm"],
volume=models,
model=llama,
env={"HF_TOKEN": Secret("hf-token")},
)
def chat(prompt: str):
import vllm

# Check the status of the endpoint run request
print(run_request.status())
llm = vllm.LLM(model=str(llama.path)) # weights already on disk
return llm.generate(prompt)

# Get the output of the endpoint run request, blocking until the endpoint run is complete.
print(run_request.output())
```

```python
endpoint = runpod.Endpoint("ENDPOINT_ID")
# one ephemeral pod per call: provisions, runs to completion, terminates
@app.task(gpu="H100", gpu_count=2, volume=models)
def finetune(steps: int = 1000):
...
return {"loss": final_loss}

run_request = endpoint.run_sync(
{"your_model_input_key": "your_model_input_value"}
)

# Returns the job results if completed within 90 seconds, otherwise, returns the job status.
print(run_request )
@runpod.local_entrypoint
def main():
print(chat.remote("why is the sky blue?")) # blocks for the result
job = finetune.spawn(steps=500) # fire and forget -> Job
```

#### API Key Management

The SDK supports multiple ways to set API keys:

**1. Global API Key** (Default)
```python
import runpod

# Set global API key
runpod.api_key = "your_runpod_api_key"

# All endpoints will use this key by default
endpoint = runpod.Endpoint("ENDPOINT_ID")
result = endpoint.run_sync({"input": "data"})
```

**2. Endpoint-Specific API Key**
```python
# Create endpoint with its own API key
endpoint = runpod.Endpoint("ENDPOINT_ID", api_key="specific_api_key")

# This endpoint will always use the provided API key
result = endpoint.run_sync({"input": "data"})
```

#### API Key Precedence

The SDK uses this precedence order (highest to lowest):
1. Endpoint instance API key (if provided to `Endpoint()`)
2. Global API key (set via `runpod.api_key`)

```python
import runpod

# Example showing precedence
runpod.api_key = "GLOBAL_KEY"

# This endpoint uses GLOBAL_KEY
endpoint1 = runpod.Endpoint("ENDPOINT_ID")

# This endpoint uses ENDPOINT_KEY (overrides global)
endpoint2 = runpod.Endpoint("ENDPOINT_ID", api_key="ENDPOINT_KEY")

# All requests from endpoint2 will use ENDPOINT_KEY
result = endpoint2.run_sync({"input": "data"})
```

#### Thread-Safe Operations

Each `Endpoint` instance maintains its own API key, making concurrent operations safe:

```python
import threading
import runpod

def process_request(api_key, endpoint_id, input_data):
# Each thread gets its own Endpoint instance
endpoint = runpod.Endpoint(endpoint_id, api_key=api_key)
return endpoint.run_sync(input_data)

# Safe concurrent usage with different API keys
threads = []
for customer in customers:
t = threading.Thread(
target=process_request,
args=(customer["api_key"], customer["endpoint_id"], customer["input"])
)
threads.append(t)
t.start()
```bash
rp flash dev main.py # live dev session: edit, re-run, logs stream back
rp flash deploy # deploy production endpoints
```

### GPU Cloud (Pods)

```python
import runpod

runpod.api_key = "your_runpod_api_key_found_under_settings"

# Get all my pods
pods = runpod.get_pods()

# Get a specific pod
pod = runpod.get_pod(pod.id)

# Create a pod with GPU
pod = runpod.create_pod("test", "runpod/stack", "NVIDIA GeForce RTX 3070")
Functions keep their Python identity: `chat.remote(...)` runs in the cloud, `await chat.remote.aio(...)` is the async form, `chat.local(...)` runs in-process. See [`examples/apps`](examples/apps) for runnable examples and [docs.runpod.io](https://docs.runpod.io) for the full guide.

# Create a pod with CPU
pod = runpod.create_pod("test", "runpod/stack", instance_id="cpu3c-2-4")
## Contributing

# Stop the pod
runpod.stop_pod(pod.id)

# Resume the pod
runpod.resume_pod(pod.id)

# Terminate the pod
runpod.terminate_pod(pod.id)
```
Pull requests and issues are welcome — see the [contributing guide](CONTRIBUTING.md) to get started.

## 📁 | Directory

```BASH
.
├── docs # Documentation
├── examples # Examples
├── runpod # Package source code
│ ├── api_wrapper # Language library - API (GraphQL)
│ ├── cli # Command Line Interface Functions
│ ├── endpoint # Language library - Endpoints
│ └── serverless # SDK - Serverless Worker
└── tests # Package tests
```bash
git clone https://github.com/runpod/runpod-python.git
cd runpod-python
make setup
make test
```

## 🤝 | Community and Contributing

We welcome both pull requests and issues on [GitHub](https://github.com/runpod/runpod-python). Bug fixes and new features are encouraged, but please read our [contributing guide](CONTRIBUTING.md) first.

<div align="center">

<a target="_blank" href="https://discord.gg/pJ3P2DbUUq">![Discord Banner 2](https://discordapp.com/api/guilds/912829806415085598/widget.png?style=banner2)</a>
<a target="_blank" href="https://discord.gg/pJ3P2DbUUq">![Discord](https://discordapp.com/api/guilds/912829806415085598/widget.png?style=banner2)</a>

</div>
Loading