RunpodClient

Struct RunpodClient 

Source
pub struct RunpodClient { /* private fields */ }
Expand description

Main RunPod API client for interacting with all RunPod services.

The RunpodClient provides access to all RunPod API endpoints through specialized service interfaces. It handles authentication, request/response serialization, and provides a consistent async interface for all operations.

§Features

  • Thread-safe: Safe to use across multiple threads
  • Cheap to clone: Uses Arc internally for efficient cloning
  • Automatic authentication: Handles API key authentication automatically
  • Comprehensive coverage: Access to all RunPod services (Pods, Endpoints, Templates, etc.)

§Services

The client implements V1 API service traits that provide direct access to API methods:

§Examples

§Basic usage with environment configuration

use runpod_sdk::{RunpodClient, Result};
use runpod_sdk::model::ListPodsQuery;
use runpod_sdk::service::PodsService;

let client = RunpodClient::from_env()?;

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

§Custom configuration with builder pattern

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

let client = RunpodConfig::builder()
    .with_api_key("your-api-key")
    .with_rest_url("https://rest.runpod.io/v1")
    .with_timeout(Duration::from_secs(30))
    .build_client()?;

// Use different services
let pods = client.list_pods(Default::default()).await?;
let endpoints = client.list_endpoints(Default::default()).await?;
let templates = client.list_templates(Default::default()).await?;

§Multi-threaded usage

The client is cheap to clone (uses Arc internally):

use runpod_sdk::{RunpodClient, Result};
use runpod_sdk::service::PodsService;
use tokio::task;

let client = RunpodClient::from_env()?;

let handles: Vec<_> = (0..3).map(|i| {
    let client = client.clone();
    task::spawn(async move {
        let pods = client.list_pods(Default::default()).await?;
        println!("Thread {}: Found {} pods", i, pods.len());
        Ok::<(), runpod_sdk::Error>(())
    })
}).collect();

for handle in handles {
    handle.await.unwrap()?;
}

Implementations§

Source§

impl RunpodClient

Source

pub fn new(config: RunpodConfig) -> Result<Self>

Creates a new Runpod API client.

Source

pub fn builder() -> RunpodBuilder

Creates a new configuration builder for constructing a RunPod client.

This is a convenience method that returns a RunpodConfigBuilder for building a custom client configuration.

§Example
let client = RunpodClient::builder()
    .with_api_key("your-api-key")
    .with_timeout(Duration::from_secs(60))
    .build_client()?;
Source

pub fn from_env() -> Result<Self>

Creates a new Runpod API client from environment variables.

This is a convenience method that creates a RunpodConfig from environment variables and then creates a client from that config.

§Environment Variables
  • RUNPOD_API_KEY - Your RunPod API key (required)
  • RUNPOD_BASE_URL - Base URL for the API (optional, defaults to https://rest.runpod.io/v1)
  • RUNPOD_TIMEOUT_SECS - Request timeout in seconds (optional, defaults to 30)
§Example
let client = RunpodClient::from_env()?;

Trait Implementations§

Source§

impl BillingService for RunpodClient

Source§

async fn get_pod_billing( &self, query: PodBillingQuery, ) -> Result<BillingRecords>

Retrieves detailed Pod billing history and usage data. Read more
Source§

async fn get_endpoint_billing( &self, query: EndpointBillingQuery, ) -> Result<BillingRecords>

Retrieves comprehensive Serverless endpoint billing history and metrics. Read more
Source§

async fn get_volume_billing( &self, query: NetworkVolumeBillingQuery, ) -> Result<BillingRecords>

Retrieves Network Volume billing history and storage usage metrics. Read more
Source§

impl Clone for RunpodClient

Source§

fn clone(&self) -> RunpodClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RunpodClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl EndpointsService for RunpodClient

Source§

async fn create_endpoint(&self, input: EndpointCreateInput) -> Result<Endpoint>

Creates a new serverless endpoint. Read more
Source§

async fn list_endpoints(&self, query: ListEndpointsQuery) -> Result<Endpoints>

Lists serverless endpoints with optional filtering. Read more
Source§

async fn get_endpoint( &self, endpoint_id: &str, query: GetEndpointQuery, ) -> Result<Endpoint>

Gets a specific endpoint by ID. Read more
Source§

async fn update_endpoint( &self, endpoint_id: &str, input: EndpointUpdateInput, ) -> Result<Endpoint>

Updates an existing endpoint. Read more
Source§

async fn delete_endpoint(&self, endpoint_id: &str) -> Result<()>

Deletes an endpoint. Read more
Source§

impl PodsService for RunpodClient

Source§

async fn create_pod(&self, input: PodCreateInput) -> Result<Pod>

Creates a new pod. Read more
Source§

async fn list_pods(&self, query: ListPodsQuery) -> Result<Pods>

Lists pods with optional filtering. Read more
Source§

async fn get_pod(&self, pod_id: &str, query: GetPodQuery) -> Result<Pod>

Gets a specific pod by ID. Read more
Source§

async fn update_pod(&self, pod_id: &str, input: PodUpdateInput) -> Result<Pod>

Updates an existing pod. Read more
Source§

async fn delete_pod(&self, pod_id: &str) -> Result<()>

Deletes a pod. Read more
Source§

async fn start_pod(&self, pod_id: &str) -> Result<()>

Starts or resumes a pod. Read more
Source§

async fn stop_pod(&self, pod_id: &str) -> Result<()>

Stops a pod. Read more
Source§

async fn reset_pod(&self, pod_id: &str) -> Result<()>

Resets a pod. Read more
Source§

async fn restart_pod(&self, pod_id: &str) -> Result<()>

Restarts a pod. Read more
Source§

impl RegistryService for RunpodClient

Source§

async fn create_registry_auth( &self, input: ContainerRegistryAuthCreateInput, ) -> Result<ContainerRegistryAuth>

Creates a new container registry authentication. Read more
Source§

async fn list_registry_auths(&self) -> Result<ContainerRegistryAuths>

Lists all container registry authentications. Read more
Source§

async fn get_registry_auth( &self, auth_id: &str, ) -> Result<ContainerRegistryAuth>

Gets a specific container registry authentication by ID. Read more
Source§

async fn delete_registry_auth(&self, auth_id: &str) -> Result<()>

Deletes a container registry authentication. Read more
Source§

impl TemplatesService for RunpodClient

Source§

async fn create_template(&self, input: TemplateCreateInput) -> Result<Template>

Creates a new template. Read more
Source§

async fn list_templates(&self, query: ListTemplatesQuery) -> Result<Templates>

Lists templates with optional filtering. Read more
Source§

async fn get_template( &self, template_id: &str, query: GetTemplateQuery, ) -> Result<Template>

Gets a specific template by ID. Read more
Source§

async fn update_template( &self, template_id: &str, input: TemplateUpdateInput, ) -> Result<Template>

Updates an existing template. Read more
Source§

async fn delete_template(&self, template_id: &str) -> Result<()>

Deletes a template. Read more
Source§

impl VolumesService for RunpodClient

Source§

async fn create_volume( &self, input: NetworkVolumeCreateInput, ) -> Result<NetworkVolume>

Creates a new network volume. Read more
Source§

async fn list_volumes(&self) -> Result<NetworkVolumes>

Lists all network volumes. Read more
Source§

async fn get_volume(&self, volume_id: &str) -> Result<NetworkVolume>

Gets a specific network volume by ID. Read more
Source§

async fn update_volume( &self, volume_id: &str, input: NetworkVolumeUpdateInput, ) -> Result<NetworkVolume>

Updates an existing network volume. Read more
Source§

async fn delete_volume(&self, volume_id: &str) -> Result<()>

Deletes a network volume. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more