Crate runpod_sdk

Crate runpod_sdk 

Source
Expand description

§Runpod SDK

Crates.io Documentation Build

A Rust client library for the Runpod API. This SDK provides a type-safe, ergonomic interface for managing Pods, Serverless endpoints, templates, network volumes, and more.

This crate is a fork of the original runpod.rs developed by Patrick Barker.

§Features

  • Serverless Endpoints: Full endpoint management with configuration
  • Type Safety: Strongly typed models with comprehensive validation
  • Async/Await: Built on modern async Rust with tokio and reqwest

§Installation

Add this to your Cargo.toml:

[dependencies]
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
runpod-sdk = { version = "0.2", features = ["serverless"] }

§Quick Start

§Builder Configuration

use runpod_sdk::{RunpodClient, Result};
use runpod_sdk::service::PodsService;
use std::time::Duration;

#[tokio::main]
async fn main() -> Result<()> {
    let client = RunpodClient::builder()
        .with_api_key("your-api-key")
        .with_timeout(Duration::from_secs(60))
        .build_client()?;

    let pods = client.list_pods(Default::default()).await?;
    println!("Found {} pods", pods.len());

    Ok(())
}

§Environment Variables

The SDK can be configured using environment variables:

VariableRequiredDefaultDescription
RUNPOD_API_KEYYes-Your RunPod API key from console settings
RUNPOD_REST_URLNohttps://rest.runpod.io/v1Custom REST API base URL
RUNPOD_API_URLNohttps://api.runpod.io/v2Custom API URL for serverless endpoints (requires serverless feature)
RUNPOD_TIMEOUT_SECSNo30Request timeout in seconds (max: 300)
use runpod_sdk::{RunpodClient, Result};

#[tokio::main]
async fn main() -> Result<()> {
    let client: RunpodClient = RunpodClient::from_env()?;
    Ok(())
}

§Optional Features

§TLS Backend

Choose between two TLS implementations:

# Default: rustls-tls (recommended)
runpod-sdk = { version = "0.2", features = [] }

# Alternative: native-tls
runpod-sdk = { version = "0.2", features = ["native-tls"], default-features = false }

§Tracing Support

Enable comprehensive logging and tracing via the tracing crate. Tracing targets are defined in lib.rs for fine-grained control over log output:

runpod-sdk = { version = "0.2", features = ["tracing"] }

§Examples

The examples/ directory contains comprehensive usage examples:

# Set your API key
export RUNPOD_API_KEY="your-api-key"

# Run the basic usage example
cargo run --example basic_usage

# Run the endpoint lifecycle management example
cargo run --example manage_endpoint

# Run the serverless endpoint example (requires serverless feature)
export RUNPOD_ENDPOINT_ID="your-endpoint-id"
cargo run --example run_endpoint --features serverless

§Contributing

Contributions are welcome! Please read our Contributing Guide for details on how to submit pull requests, report issues, and contribute to the project.

§License

This project is licensed under the MIT License - see the LICENSE.txt file for details.

§Resources

Modules§

builder
Configuration builder types for RunPod clients.
model
Type-safe data models for RunPod API resources.
serverlessserverless
Serverless endpoint execution and job management.
service
Service traits for RunPod API resource management.

Structs§

RunpodClient
Main RunPod API client for interacting with all RunPod services.
RunpodConfig
Configuration for the Runpod API client.

Enums§

Error
Error type for RunPod API operations.

Constants§

TRACING_TARGET_CLIENTtracing
Tracing target for client-level operations (HTTP requests, client creation).
TRACING_TARGET_CONFIGtracing
Tracing target for configuration operations (config creation, validation).
TRACING_TARGET_SERVICEtracing
Tracing target for service-level operations (API calls, business logic).

Type Aliases§

Result
Result type for RunPod API operations.