pip install runpod
rp loginrp login stores your API key, and every example picks it up from there. If
RUNPOD_API_KEY is set in your environment, the examples use that key
instead.
| Folder | What it shows | Needs |
|---|---|---|
apps/ |
Python functions that run on cloud GPUs and CPUs, started with rp flash dev |
An account. Start here if you are new. |
serverless/ |
Handlers for your own serverless worker image | Nothing. They run locally. |
endpoints/ |
Sending jobs to an existing serverless endpoint | An endpoint id |
api/ |
Creating templates, endpoints, and registry credentials | An account |
rest_wrapper.py |
Pod lifecycle: create, stop, resume, terminate | An account. Creates a billable GPU pod. |
cd examples/serverless
python simple_handler.py --test_input '{"input": {"name": "world"}}'Or start a local API server and call it:
python simple_handler.py --rp_serve_api
curl -X POST http://localhost:8000/runsync \
-H "Content-Type: application/json" \
-d '{"input": {"name": "world"}}'Run with no arguments, a handler looks for a test_input.json file in the
current directory.
Each endpoints/ example has a YOUR_ENDPOINT_ID placeholder. To use an
endpoint you already have, list them with rp endpoint list. To create one
for trying the examples, run api/create_endpoint.py,
which deploys runpod/mock-worker and prints the new id.
endpoints/streaming.py needs a worker that streams: a generator handler, or
runpod/mock-worker started with --generator.
- Endpoints with
workers_min=0cost nothing while idle. Delete them withrp endpoint delete ENDPOINT_ID. - Templates stay on your account. Delete them from the Templates page in the console.
rest_wrapper.pyterminates its pod at the end, including when a step fails.rp flash devdeletes the endpoints it created when the session ends. Network volumes created byapps/examples are not deleted; list them withrp volume listand remove them withrp volume delete.