Skip to main content
This tutorial builds a small Runpod SDK app one resource at a time. You’ll create a project, run a function on a GPU, add an HTTP service, stream results, share files between two tasks through a network volume, and deploy the app.

What you’ll learn

  • How to scaffold a project with rp flash init.
  • How to run queue functions on CPUs and GPUs with @app.queue.
  • How to serve a stateful HTTP class with @app.api.
  • How to stream results from a generator function.
  • How to share data between tasks with a network volume.
  • How to deploy the app with rp flash deploy.

Requirements

  • A Runpod account with credits.
  • Python 3.10 to 3.14 on your machine.
  • The runpod package, version 2.0 or later. To use the release candidate, run pip install runpod==2.0.0rc1.
  • Credentials saved with rp login. See Authenticate.

Step 1: Create a project

Scaffold a new project:
This creates three files:
  • main.py: An app with one queue function and a local entrypoint.
  • requirements.txt: Packages your workers need. They’re also installed locally for dev sessions.
  • .runpodignore: Files to leave out of deployments. See Ignore rules.
Open main.py. It contains a complete app:
main.py
@app.queue turns hello into a queue-based Serverless endpoint running on a small CPU worker. main is marked with @runpod.local_entrypoint, so it runs on your machine and calls hello remotely.

Step 2: Run it in a dev session

Start a dev session:
The SDK creates a temporary endpoint for hello, runs main, and streams the worker’s print output to your terminal. Leave the session running. Change the greeting in hello, save the file, and press Enter to re-run. Workers pick up the new code automatically. Press Ctrl-C when you’re done. The session deletes its temporary endpoints. To learn more, see Dev sessions.

Step 3: Run a function on a GPU

Add a GPU function to main.py:
main.py
Then call it from main:
main.py
A few things to notice:
  • gpu="4090" requests an RTX 4090. See GPU types for other options.
  • Packages are imported inside the function, so your machine doesn’t need them. torch is already installed on the built-in GPU images, so it doesn’t need to be listed in dependencies.

Step 4: Add an HTTP service

Use @app.api to serve a class over HTTP. Mark routes with @runpod.get and @runpod.post, and setup code with @runpod.init:
main.py
Call the routes through the class:
main.py
Counter runs on a load-balanced endpoint. Each worker keeps its own state in memory between requests.

Step 5: Stream results

A generator function streams its output. Call .stream() to receive each chunk as the worker yields it:
main.py
Calling .remote() on a generator returns every chunk at once. You can also call .spawn() and stream the job later with job.stream().

Step 6: Share data between tasks

Tasks run on a dedicated Pod that terminates when the function returns. To pass files between tasks, mount the same network volume on both:
main.py
The volume is created the first time you use it, and both tasks are placed in its data center. checkpoints.path returns the mount path on each Pod. See Storage.
The network volume keeps incurring storage charges after the session ends. Delete it from the Storage page in the console when you no longer need it.

Step 7: Deploy the app

When the app works in a dev session, deploy it:
This builds your code and dependencies into an artifact and creates long-running endpoints in the app’s default environment. To deploy to another environment, add --env, for example rp flash deploy --env production. See Deploy an app. To remove the deployed endpoints:

Next steps

Last modified on October 15, 2026