pub struct RunpodConfig { /* private fields */ }Expand description
Configuration for the Runpod API client.
This struct holds all the necessary configuration parameters for creating and using a Runpod API client, including authentication credentials, API endpoint information, and HTTP client settings.
§Examples
Creating a config with defaults:
let config = RunpodConfig::builder()
.with_api_key("your-api-key")
.build()
.unwrap();Creating a config from environment:
// Requires RUNPOD_API_KEY environment variable
let config = RunpodConfig::from_env().unwrap();Custom configuration:
let config = RunpodConfig::builder()
.with_api_key("your-api-key")
.with_rest_url("https://custom.api.com")
.with_timeout(Duration::from_secs(60))
.build()
.unwrap();Implementations§
Source§impl RunpodConfig
impl RunpodConfig
Sourcepub fn builder() -> RunpodBuilder
pub fn builder() -> RunpodBuilder
Creates a new configuration builder.
This is the recommended way to construct a RunpodConfig.
§Examples
let config = RunpodConfig::builder()
.with_api_key("your-api-key")
.build()
.unwrap();Sourcepub fn build_client(self) -> Result<RunpodClient>
pub fn build_client(self) -> Result<RunpodClient>
Creates a new RunPod API client using this configuration.
§Examples
let config = RunpodConfig::builder()
.with_api_key("your-api-key")
.build()
.unwrap();
let client = config.build_client().unwrap();Sourcepub fn masked_api_key(&self) -> String
pub fn masked_api_key(&self) -> String
Returns a masked version of the API key for safe display/logging.
Shows the first 4 characters followed by “”, or just “” if the key is shorter than 4 characters.
Sourcepub fn api_url(&self) -> &str
Available on crate feature serverless only.
pub fn api_url(&self) -> &str
serverless only.Returns the API URL for serverless endpoints.
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Creates a configuration from environment variables.
Reads the API key from the RUNPOD_API_KEY environment variable.
Optionally reads RUNPOD_REST_URL, RUNPOD_API_URL (with serverless feature),
and RUNPOD_TIMEOUT_SECS if set.
§Errors
Returns an error if:
- The
RUNPOD_API_KEYenvironment variable is not set - Any environment variable contains an invalid value
§Examples
// Set environment variable first:
// export RUNPOD_API_KEY=your-api-key
let config = RunpodConfig::from_env().unwrap();Trait Implementations§
Source§impl Clone for RunpodConfig
impl Clone for RunpodConfig
Source§fn clone(&self) -> RunpodConfig
fn clone(&self) -> RunpodConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more