Skip to main content

Overview

Get started with setting up your RunPod projects using Go. Whether you're building web applications, server-side implementations, or automating tasks, the RunPod Go SDK provides the tools you need. This guide outlines the steps to get your development environment ready and integrate RunPod into your Go projects.

Prerequisites

Before you begin, ensure that you have the following:

  • Go installed on your machine (version 1.16 or later)
  • A RunPod account with an API key and Endpoint Id

Install the RunPod SDK

Before integrating RunPod into your project, you'll need to install the SDK.

To install the RunPod SDK, run the following go get command in your project directory.

go get github.com/runpod/go-sdk

This command installs the runpod-sdk package. Then run the following command to install the dependcies:

go mod tidy

For more details about the package, visit the Go package page or the GitHub repository.

Add your API key

To use the RunPod SDK in your project, you first need to import it and configure it with your API key and endpoint ID. Ensure these values are securely stored, preferably as environment variables.

Below is a basic example of how to initialize and use the RunPod SDK in your Go project.

func main() {
endpoint, err := rpEndpoint.New(
&config.Config{ApiKey: sdk.String(os.Getenv("RUNPOD_API_KEY"))},
&rpEndpoint.Option{EndpointId: sdk.String(os.Getenv("RUNPOD_BASE_URL"))},
)
if err != nil {
panic(err)
}

// Use the endpoint object
// ...
}

This snippet demonstrates how to import the SDK, initialize it with your API key, and reference a specific endpoint using its ID.

Secure your API key

When working with the RunPod SDK, it's essential to secure your API key. Storing the API key in environment variables is recommended, as shown in the initialization example. This method keeps your key out of your source code and reduces the risk of accidental exposure.

note

Use environment variables or secure secrets management solutions to handle sensitive information like API keys.

For more information, see the following: