RunPod Python SDK

1.7.9 · active · verified Tue Mar 17

Official Python SDK and serverless worker framework for the RunPod cloud GPU platform. Provides tools for creating serverless endpoint workers, managing pods, and interacting with the RunPod API. Used both as a client library and as the runtime framework inside serverless containers.

Warnings

Install

Imports

Quickstart

Minimal serverless handler that processes an input prompt. The API client section (commented) shows pod management.

import runpod
import os

# --- Serverless Handler Example ---
def handler(event):
    """Serverless handler function."""
    prompt = event['input'].get('prompt', 'Hello!')
    return {"output": f"Processed: {prompt}"}

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

# --- API Client Example (run separately) ---
# runpod.api_key = os.environ.get('RUNPOD_API_KEY', '')
# pods = runpod.get_pods()
# print(pods)

view raw JSON →