Skip to main content
For an even faster start, clone or download the worker-basic repository for a pre-configured template for building and deploying Serverless workers. After cloning the repository, skip to step 6 of this tutorial to deploy and test the endpoint.

Requirements

Step 1: Create project files

Create a new directory with empty files for your project:

Step 2: Install the Serverless SDK

Create a virtual environment and install the Serverless SDK

Step 3: Create a handler function

Add the following code to handler.py:
handler.py
This is a bare-bones handler that processes a JSON object and outputs a prompt string contained in the input object.
You can replace the time.sleep(seconds) call with your own Python code for generating images, text, or running any AI/ML workload.

Step 4: Create a test input file

Add the following code to test_input.json to properly test your handler locally:
test_input.json

Step 5: Test your handler function locally

Run your handler function using your local terminal:
You should see output similar to this:

Step 6: Create a Dockerfile

Add the following content to Dockerfile:
New to Dockerfiles? Learn the fundamentals with our introduction to containers tutorial series.
Dockerfile

Step 7: Build and push your worker image

Instead of building and pushing your image via Docker Hub, you can also deploy your worker from a GitHub repository.
Before you can deploy your worker on Runpod Serverless, you need to push it to Docker Hub:
1

Build your Docker image

Build your Docker image, specifying the platform for Runpod deployment, replacing [YOUR_USERNAME] with your Docker username:
2

Push the image to your container registry

Step 8: Deploy your worker using the Runpod console

To deploy your worker to a Serverless endpoint:
  1. Go to the Serverless section of the Runpod console.
  2. Click New Endpoint.
  3. Click Import from Docker Registry
  4. In the Container Image field, enter your Docker image URL: docker.io/yourusername/serverless-test:latest.
  5. Click Next to proceed to endpoint configuration.
  6. Configure your endpoint settings:
    • (Optional) Enter a custom name for your endpoint, or use the randomly generated name.
    • Make sure the Endpoint Type is set to Queue.
    • Under GPU Configuration, check the box for 16 GB GPUs.
    • Leave the rest of the settings at their defaults.
  7. Click Deploy Endpoint.
The system will redirect you to a dedicated detail page for your new endpoint.

Step 9: Test your endpoint

To test your endpoint, click the Requests tab in the endpoint detail page:
Runpod serverless endpoint details page
On the left you should see the default test request:
Leave the default input as is and click Run. The system will take a few minutes to initialize your workers. When the workers finish processing your request, you should see output on the right side of the page similar to this:
Congratulations! You’ve successfully deployed and tested your first Serverless endpoint.

Next steps

Handler functions

Create more advanced handler functions.

Create a Dockerfile

Add AI/ML models and other dependencies to your worker.

Send requests

Learn how to structure and send requests to your endpoint.

Manage endpoints

Configure and manage your Serverless endpoints.
Last modified on August 14, 2026