runpod-sdk 0.2.2

Unofficial Rust SDK for RunPod: deploy and scale GPU workloads with serverless endpoints and on-demand pods
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
use serde::{Deserialize, Serialize};

use super::common::*;

/// A Pod resource representing a containerized compute instance on RunPod.
///
/// Pods are the fundamental compute units in RunPod, providing either GPU or CPU-based
/// computing resources. They can be configured with various specifications including
/// compute type, memory, storage, networking, and environment settings.
///
/// # Examples
///
/// ```rust
/// use runpod_sdk::model::Pod;
///
/// // Pod instances are typically obtained from API responses
/// // when listing, creating, or retrieving pods
/// ```
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Pod {
    /// A unique string identifying the Pod.
    pub id: String,
    /// A user-defined name for the Pod. The name does not need to be unique.
    pub name: Option<String>,
    /// The image tag for the container run on the Pod.
    pub image: String,
    /// A unique string identifying the RunPod user who rents the Pod.
    pub consumer_user_id: String,
    /// A unique string identifying the host machine the Pod is running on.
    pub machine_id: String,
    /// The current expected status of the Pod.
    pub desired_status: PodStatus,
    /// The cost in RunPod credits per hour of running the Pod.
    /// Note that the actual cost may be lower if Savings Plans are applied.
    pub cost_per_hr: f64,
    /// The effective cost in RunPod credits per hour of running the Pod,
    /// adjusted by active Savings Plans.
    pub adjusted_cost_per_hr: f64,
    /// The number of GPUs attached to the Pod (if it's a GPU Pod).
    pub gpu_count: Option<i32>,
    /// The number of virtual CPUs attached to the Pod.
    pub vcpu_count: f64,
    /// The amount of RAM, in gigabytes (GB), attached to the Pod.
    pub memory_in_gb: f64,
    /// The amount of disk space, in gigabytes (GB), allocated on the container disk.
    /// The data on the container disk is wiped when the Pod restarts.
    pub container_disk_in_gb: i32,
    /// The amount of disk space, in gigabytes (GB), allocated on the Pod volume.
    /// The data on the Pod volume is persisted across Pod restarts.
    pub volume_in_gb: Option<i32>,
    /// The absolute path where the network volume is mounted in the filesystem.
    pub volume_mount_path: Option<String>,
    /// Whether the local network volume of the Pod is encrypted.
    /// Can only be set when creating a Pod.
    pub volume_encrypted: bool,
    /// A list of ports exposed on the Pod. Each port is formatted as
    /// `[port number]/[protocol]`. Protocol can be either `http` or `tcp`.
    pub ports: Vec<String>,
    /// A mapping of internal ports to public ports on the Pod.
    /// For example, `{"22": 10341}` means that port 22 on the Pod is mapped
    /// to port 10341 and is publicly accessible at `[public ip]:10341`.
    pub port_mappings: Option<PortMappings>,
    /// The public IP address of the Pod. If the Pod is still initializing,
    /// this IP is not yet determined and will be empty.
    pub public_ip: Option<String>,
    /// Environment variables for the Pod container.
    pub env: EnvVars,
    /// If specified, overrides the ENTRYPOINT for the Docker image run on the Pod.
    /// If empty, uses the ENTRYPOINT defined in the image.
    pub docker_entrypoint: Option<Vec<String>>,
    /// If specified, overrides the start CMD for the Docker image run on the Pod.
    /// If empty, uses the start CMD defined in the image.
    pub docker_start_cmd: Option<Vec<String>>,
    /// Describes how the Pod is rented. An interruptible Pod can be rented at
    /// a lower cost but can be stopped at any time to free up resources for
    /// another Pod. A reserved Pod is rented at a higher cost but runs until
    /// it exits or is manually stopped.
    pub interruptible: bool,
    /// Whether the Pod is locked. Locking a Pod disables stopping or resetting it.
    pub locked: bool,
    /// GPU information if the Pod has GPUs attached.
    pub gpu: Option<GpuInfo>,
    /// If the Pod is a CPU Pod, the unique string identifying the CPU flavor
    /// the Pod is running on.
    pub cpu_flavor_id: Option<String>,
    /// The GPU type ID if the Pod has GPUs attached.
    pub gpu_type_id: Option<String>,
    /// If the Pod is created with a template, the unique string identifying that template.
    pub template_id: Option<String>,
    /// The unique string identifying the network volume attached to the Pod, if any.
    pub network_volume_id: Option<String>,
    /// If the Pod is created with a container registry auth, the unique string
    /// identifying that container registry auth.
    pub container_registry_auth_id: Option<String>,
    /// If the Pod is a Serverless worker, a unique string identifying the
    /// associated endpoint.
    pub endpoint_id: Option<String>,
    /// Synonym for `endpoint_id` (legacy name).
    pub ai_api_id: Option<String>,
    /// If the Pod is a Serverless worker, the version of the associated endpoint.
    pub sls_version: Option<i32>,
    /// The UTC timestamp when the Pod was last started.
    pub last_started_at: Option<String>,
    /// A string describing the last lifecycle event on the Pod.
    pub last_status_change: Option<String>,
    /// Information about the machine the Pod is running on.
    pub machine: Option<Machine>,
    /// If a network volume is attached to the Pod, information about the network volume.
    pub network_volume: Option<NetworkVolume>,
    /// The list of active Savings Plans applied to the Pod. If none are applied, the list is empty.
    pub savings_plans: Option<Vec<SavingsPlan>>,
}

/// List of pods.
pub type Pods = Vec<Pod>;

/// Input parameters for creating a new Pod.
///
/// This struct contains all the configuration options available when creating a Pod,
/// including compute specifications, networking, storage, and deployment preferences.
/// Most fields are optional and will use RunPod defaults if not specified.
///
/// # Examples
///
/// ```rust
/// use runpod_sdk::model::{PodCreateInput, ComputeType, CloudType};
///
/// let create_input = PodCreateInput {
///     name: Some("my-pod".to_string()),
///     image_name: Some("runpod/pytorch:latest".to_string()),
///     compute_type: Some(ComputeType::Gpu),
///     cloud_type: Some(CloudType::Secure),
///     ..Default::default()
/// };
/// ```
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PodCreateInput {
    /// If the created Pod is a GPU Pod, a list of acceptable CUDA versions.
    /// If not set, any CUDA version is acceptable.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub allowed_cuda_versions: Option<Vec<CudaVersion>>,
    /// Set to `SECURE` to create the Pod in Secure Cloud. Set to `COMMUNITY`
    /// to create the Pod in Community Cloud.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cloud_type: Option<CloudType>,
    /// Set to `GPU` to create a GPU Pod. Set to `CPU` to create a CPU Pod.
    /// If set to `CPU`, the Pod will not have a GPU attached and GPU-related
    /// properties will be ignored.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub compute_type: Option<ComputeType>,
    /// The amount of disk space, in gigabytes (GB), to allocate on the container disk.
    /// The data on the container disk is wiped when the Pod restarts.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub container_disk_in_gb: Option<i32>,
    /// Registry credentials ID for private container registries.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub container_registry_auth_id: Option<String>,
    /// A list of country codes where the created Pod can be located.
    /// If not set, the Pod can be located in any country.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub country_codes: Option<Vec<String>>,
    /// If the created Pod is a CPU Pod, a list of RunPod CPU flavors which
    /// can be attached to the Pod. The order determines the rental priority.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cpu_flavor_ids: Option<Vec<CpuFlavorId>>,
    /// If the created Pod is a CPU Pod, set to `availability` to respond to
    /// current CPU flavor availability. Set to `custom` to always try to rent
    /// CPU flavors in the order specified in `cpu_flavor_ids`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cpu_flavor_priority: Option<String>,
    /// A list of RunPod data center IDs where the created Pod can be located.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub data_center_ids: Option<Vec<DataCenterId>>,
    /// Set to `availability` to respond to current machine availability.
    /// Set to `custom` to always try to rent machines from data centers
    /// in the order specified in `data_center_ids`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub data_center_priority: Option<String>,
    /// If specified, overrides the ENTRYPOINT for the Docker image.
    /// If empty, uses the ENTRYPOINT defined in the image.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub docker_entrypoint: Option<Vec<String>>,
    /// If specified, overrides the start CMD for the Docker image.
    /// If empty, uses the start CMD defined in the image.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub docker_start_cmd: Option<Vec<String>>,
    /// Environment variables for the Pod container.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub env: Option<EnvVars>,
    /// Set to true to enable global networking for the created Pod.
    /// Currently only available for On-Demand GPU Pods on some Secure Cloud data centers.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub global_networking: Option<bool>,
    /// If the created Pod is a GPU Pod, the number of GPUs attached to the Pod.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub gpu_count: Option<i32>,
    /// If the created Pod is a GPU Pod, a list of RunPod GPU types which
    /// can be attached to the Pod. The order determines the rental priority.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub gpu_type_ids: Option<Vec<GpuTypeId>>,
    /// If the created Pod is a GPU Pod, set to `availability` to respond to
    /// current GPU type availability. Set to `custom` to always try to rent
    /// GPU types in the order specified in `gpu_type_ids`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub gpu_type_priority: Option<String>,
    /// The image tag for the container run on the created Pod.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub image_name: Option<String>,
    /// Set to true to create an interruptible or spot Pod. An interruptible Pod
    /// can be rented at a lower cost but can be stopped at any time to free up
    /// resources for another Pod.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub interruptible: Option<bool>,
    /// Set to true to lock the Pod. Locking a Pod disables stopping or resetting it.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub locked: Option<bool>,
    /// The minimum disk bandwidth, in megabytes per second (MBps), for the created Pod.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub min_disk_bandwidth_m_bps: Option<f64>,
    /// The minimum download speed, in megabits per second (Mbps), for the created Pod.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub min_download_mbps: Option<f64>,
    /// If the created Pod is a GPU Pod, the minimum amount of RAM, in gigabytes (GB),
    /// allocated to the Pod for each GPU attached.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub min_ram_per_gpu: Option<i32>,
    /// The minimum upload speed, in megabits per second (Mbps), for the created Pod.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub min_upload_mbps: Option<f64>,
    /// If the created Pod is a GPU Pod, the minimum number of virtual CPUs
    /// allocated to the Pod for each GPU attached.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub min_vcpu_per_gpu: Option<i32>,
    /// A user-defined name for the created Pod. The name does not need to be unique.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// The unique string identifying the network volume to attach to the created Pod.
    /// If attached, a network volume replaces the Pod network volume.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub network_volume_id: Option<String>,
    /// A list of ports exposed on the created Pod. Each port is formatted as
    /// `[port number]/[protocol]`. Protocol can be either `http` or `tcp`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ports: Option<Vec<String>>,
    /// If the created Pod is on Community Cloud, set to true if you need the Pod
    /// to expose a public IP address. On Secure Cloud, the Pod will always have
    /// a public IP address.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub support_public_ip: Option<bool>,
    /// If the Pod is created with a template, the unique string identifying that template.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub template_id: Option<String>,
    /// If the created Pod is a CPU Pod, the number of vCPUs allocated to the Pod.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub vcpu_count: Option<i32>,
    /// The amount of disk space, in gigabytes (GB), to allocate on the Pod volume.
    /// The data on the Pod volume is persisted across Pod restarts.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub volume_in_gb: Option<i32>,
    /// The absolute path where the network volume will be mounted in the filesystem.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub volume_mount_path: Option<String>,
}

/// Input parameters for updating an existing Pod.
///
/// This struct contains the configuration options that can be modified for
/// an existing Pod. Note that updating a Pod will trigger a reset.
///
/// # Examples
///
/// ```rust
/// use runpod_sdk::model::PodUpdateInput;
///
/// let update_input = PodUpdateInput {
///     name: Some("updated-pod-name".to_string()),
///     locked: Some(true),
///     ..Default::default()
/// };
/// ```
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PodUpdateInput {
    /// The amount of disk space, in gigabytes (GB), to allocate on the container disk.
    /// The data on the container disk is wiped when the Pod restarts.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub container_disk_in_gb: Option<i32>,
    /// Registry credentials ID for private container registries.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub container_registry_auth_id: Option<String>,
    /// If specified, overrides the ENTRYPOINT for the Docker image.
    /// If empty, uses the ENTRYPOINT defined in the image.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub docker_entrypoint: Option<Vec<String>>,
    /// If specified, overrides the start CMD for the Docker image.
    /// If empty, uses the start CMD defined in the image.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub docker_start_cmd: Option<Vec<String>>,
    /// Environment variables for the Pod container.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub env: Option<EnvVars>,
    /// Set to true to enable global networking for the Pod.
    /// Currently only available for On-Demand GPU Pods on some Secure Cloud data centers.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub global_networking: Option<bool>,
    /// The image tag for the container run on the Pod.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub image_name: Option<String>,
    /// Set to true to lock the Pod. Locking a Pod disables stopping or resetting it.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub locked: Option<bool>,
    /// A user-defined name for the Pod. The name does not need to be unique.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// A list of ports exposed on the Pod. Each port is formatted as
    /// `[port number]/[protocol]`. Protocol can be either `http` or `tcp`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ports: Option<Vec<String>>,
    /// The amount of disk space, in gigabytes (GB), to allocate on the Pod volume.
    /// The data on the Pod volume is persisted across Pod restarts.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub volume_in_gb: Option<i32>,
    /// The absolute path where the network volume will be mounted in the filesystem.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub volume_mount_path: Option<String>,
}

/// Query parameters for filtering and configuring Pod list operations.
///
/// This struct provides various filters and options for customizing the
/// response when listing Pods.
///
/// # Examples
///
/// ```rust
/// use runpod_sdk::model::{ListPodsQuery, ComputeType, PodStatus};
///
/// let query = ListPodsQuery {
///     compute_type: Some(ComputeType::Gpu),
///     desired_status: Some(PodStatus::Running),
///     include_machine: Some(true),
///     ..Default::default()
/// };
/// ```
#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ListPodsQuery {
    /// Filter to only GPU or only CPU Pods.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub compute_type: Option<ComputeType>,
    /// Filter to CPU Pods with any of the listed CPU flavors.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cpu_flavor_id: Option<Vec<CpuFlavorId>>,
    /// Filter to Pods located in any of the provided RunPod data centers.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub data_center_id: Option<Vec<DataCenterId>>,
    /// Filter to Pods currently in the provided state.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub desired_status: Option<PodStatus>,
    /// Filter to workers on the provided Serverless endpoint.
    /// Note that endpoint workers are not included in the response by default.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub endpoint_id: Option<String>,
    /// Filter to Pods with any of the listed GPU types attached.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub gpu_type_id: Option<Vec<GpuTypeId>>,
    /// Filter to a specific Pod.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
    /// Filter to Pods created with the provided image.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub image_name: Option<String>,
    /// Include information about the machine the Pod is running on.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub include_machine: Option<bool>,
    /// Include information about the network volume attached to the Pod, if any.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub include_network_volume: Option<bool>,
    /// Include information about the savings plans applied to the Pod.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub include_savings_plans: Option<bool>,
    /// Include information about the template the Pod uses, if any.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub include_template: Option<bool>,
    /// Set to true to also list Pods which are Serverless workers.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub include_workers: Option<bool>,
    /// Filter to Pods with the provided name.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Filter to Pods with the provided network volume attached.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub network_volume_id: Option<String>,
    /// Filter to Pods created from the provided template.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub template_id: Option<String>,
}

/// Query parameters for retrieving a single Pod.
///
/// This struct provides options for customizing the response when retrieving
/// a specific Pod by ID.
///
/// # Examples
///
/// ```rust
/// use runpod_sdk::model::GetPodQuery;
///
/// let query = GetPodQuery {
///     include_machine: Some(true),
///     include_network_volume: Some(true),
///     include_savings_plans: Some(true),
///     ..Default::default()
/// };
/// ```
#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct GetPodQuery {
    /// Include information about the machine the Pod is running on.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub include_machine: Option<bool>,
    /// Include information about the network volume attached to the returned Pod, if any.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub include_network_volume: Option<bool>,
    /// Include information about the savings plans applied to the Pod.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub include_savings_plans: Option<bool>,
    /// Include information about the template the Pod uses, if any.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub include_template: Option<bool>,
    /// Set to true to also list Pods which are Serverless workers.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub include_workers: Option<bool>,
}