Skip to main content

Overview

Get started with setting up your RunPod projects using Python. Depending on the specific needs of your project, there are various ways to interact with the RunPod platform. This guide provides an approach to get you up and running.

Install the RunPod SDK

Create a Python virtual environment to install the RunPod SDK library. Virtual environments allow you to manage dependencies for different projects separately, avoiding conflicts between project requirements.

To get started, install setup a virtual environment then install the RunPod SDK library.

Create a Python virtual environment with venv:


python3 -m venv env
source env/bin/activate

To install the SDK, run the following command from the terminal.


python -m pip install runpod

You should have the RunPod SDK installed and ready to use.

Get RunPod SDK version

To ensure you've setup your RunPod SDK in Python, choose from one of the following methods to print the RunPod Python SDK version to your terminal.

Run the following command using pip to get the RunPod SDK version.


pip show runpod

You should see something similar to the following output.


runpod==1.6.1

You can find the latest version of the RunPod Python SDK on GitHub.

Now that you've installed the RunPod SDK, add your API key.

Add your API key

Set api_key and reference its variable in your Python application. This authenticates your requests to the RunPod platform and allows you to access the RunPod API.


import runpod
import os
runpod.api_key = os.getenv("RUNPOD_API_KEY")

note

It's recommended to use environment variables to set your API key. You shouldn't load your API key directly into your code.

For these examples, the API key loads from an environment variable called RUNPOD_API_KEY.

Now that you've have the RunPod Python SDK installed and configured, you can start using the RunPod platform.

For more information, see: