Skip to main content

Runpod Python

Define GPU functions in Python. Run them in the cloud with one decorator.

PyPI Package Downloads CI | Unit Tests License

Documentation • Examples • Discord

Using an AI agent? Point it to https://docs.runpod.io/agent-setup.md to install the Runpod skills and MCP server.

Installation

pip install runpod    # or: uv add runpod
rp login              # authenticate once

Requires Python 3.10+. Installing the package also installs the rp CLI.

Example

import runpod
from runpod import App, Model, NetworkVolume, Secret

app = App("inference")

models = NetworkVolume("models", size=100)
llama = Model("meta-llama/Llama-3.1-8B-Instruct")


# 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"],
    mounts={"/runpod-volume": models},
    model=llama,
    env={"HF_TOKEN": Secret("hf-token")},
)
def chat(prompt: str):
    import vllm

    llm = vllm.LLM(model=str(llama.path))   # weights already on disk
    return llm.generate(prompt)


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


@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
rp flash dev main.py    # live dev session: edit, re-run, logs stream back
rp flash deploy         # deploy production endpoints

Contributing

Pull requests and issues are welcome — see the contributing guide to get started.

git clone https://github.com/runpod/runpod-python.git
cd runpod-python
make setup
make test

Remote values

Queue and task calls use finite JSON-compatible arguments, return values, and stream chunks. JSON conversion turns tuples into lists and supported dictionary keys into strings, including in same-worker remote calls. Bytes, custom objects, circular references, and non-finite numbers produce explicit errors. .local() remains a direct Python call.

Successful function responses contain json_result, including for a null return value. SDK and worker runtimes share the JSON protocol validators; use compatible package releases when building worker images.

⚡ | 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.

Quick Start

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:

# 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 or by setting it as the default command in your Dockerfile.

See our blog post for creating a basic Serverless API, or view the details docs for more information.

Local Test Worker

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

python my_worker.py --rp_serve_api

📁 | Directory

.
├── docs               # Documentation
├── examples           # Examples
├── runpod             # Package source code
│   ├── api            # rest api v2 wrapper
│   ├── cli            # Command Line Interface Functions
│   ├── endpoint       # Language library - Endpoints
│   └── serverless     # SDK - Serverless Worker
└── tests              # Package tests

Discord

Metadata

Release files for runpod 2.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for runpod 2.2.1
File Size Uploaded Provenance Actions
runpod-2.2.1.tar.gz 962.3 kB With provenance Details for runpod-2.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for runpod 2.2.1
File Interpreter ABI Platform Actions
runpod-2.2.1-py3-none-any.whl Python 3 none any Details for runpod-2.2.1-py3-none-any.whl

Total release size: 1.5 MB

Release files / runpod-2.2.1.tar.gz

Download URL runpod-2.2.1.tar.gz
Size 962.3 kB
Tags Source
SHA-256 checksum
How to use checksums
140b473d040ee8f3286a25e9955efd3a1563c6829af73a2fe658fc4a093540c6
BLAKE2b-256 checksum
How to use checksums
ae163622c2f6d04e98bf6990ec3f79ccc29070ad31de042e9acc9dbad0eaa2fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Release files / runpod-2.2.1-py3-none-any.whl

Download URL runpod-2.2.1-py3-none-any.whl
Size 532.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4c4e38ed2c4977b7f7d39c1e0bdc021bdbb12fcf9e9f6ddcb2342122f49ef6d2
BLAKE2b-256 checksum
How to use checksums
384133086696db4d0322e4f95c0b802fbb923233a732dbc26a8a909915ea4caa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Security for runpod 2.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for runpod-2.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.2.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page