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.
pip install runpodVerified import paths — ran on the pinned version, not inferred.
Minimal serverless handler that processes an input prompt. The API client section (commented) shows pod management.
Always return a dict like {"output": result} from your handler.Access user data via event['input'], not event directly.
yield {"output": chunk} in generator handlers, not yield chunk.Place all initialization (model loading, etc.) before runpod.serverless.start().
runpod.api_key = os.environ.get('RUNPOD_API_KEY', '') before making API calls.Set 'refresh_worker': False (or omit it) in production to keep the worker warm between jobs.
It is recommended to use virtual environments for dependency management or run pip with a non-root user. If building a Docker image, consider adding a non-root user and switching to it before installing dependencies (e.g., `RUN useradd -m appuser && su appuser`). Alternatively, use the `--user` flag with pip to install packages to the user's home directory.
Upgrade 'runpod' to the latest version: `pip install --upgrade runpod`
Ensure the 'RUNPOD_API_KEY' environment variable is set with a valid API key from your RunPod account, or pass it directly when interacting with the API (e.g., `runpod.api_key = "your_api_key"`).
Debug the 'handler' function for unhandled exceptions during startup. Ensure 'runpod.serverless.start()' is called and the worker is configured to listen on port 8000. For local testing, verify the client connects to `http://localhost:8000`.
Install 'runpod' using `pip install runpod` and ensure it is included in your 'requirements.txt' for containerized deployments.