pub struct ComposioClientBuilder { /* private fields */ }Expand description
Builder for ComposioClient
Provides a fluent API for configuring the Composio client with custom settings. All configuration options are optional and will use sensible defaults if not specified.
§Example
use composio_sdk::client::ComposioClient;
use std::time::Duration;
let client = ComposioClient::builder()
.api_key("your_api_key")
.base_url("https://custom.api.com")
.timeout(Duration::from_secs(60))
.max_retries(5)
.initial_retry_delay(Duration::from_secs(2))
.max_retry_delay(Duration::from_secs(30))
.build()?;Implementations§
Source§impl ComposioClientBuilder
impl ComposioClientBuilder
Sourcepub fn api_key(self, key: impl Into<String>) -> Self
pub fn api_key(self, key: impl Into<String>) -> Self
Set the API key
The API key is required for authenticating with the Composio API. You can obtain your API key from the Composio dashboard.
§Arguments
key- The Composio API key (can beStringor&str)
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;Sourcepub fn base_url(self, url: impl Into<String>) -> Self
pub fn base_url(self, url: impl Into<String>) -> Self
Set the base URL
Override the default Composio API base URL. This is useful for testing or when using a custom Composio deployment.
§Arguments
url- The base URL (must start with http:// or https://)
§Default
https://backend.composio.dev/api/v3
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.base_url("https://custom.api.com")
.build()?;Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Set the request timeout
Configure how long to wait for API requests to complete before timing out.
§Arguments
timeout- The timeout duration
§Default
30 seconds
§Example
use composio_sdk::client::ComposioClient;
use std::time::Duration;
let client = ComposioClient::builder()
.api_key("your_api_key")
.timeout(Duration::from_secs(60))
.build()?;Sourcepub fn max_retries(self, retries: u32) -> Self
pub fn max_retries(self, retries: u32) -> Self
Set the maximum number of retries
Configure how many times to retry failed requests for transient errors (rate limits, server errors, network issues).
§Arguments
retries- Maximum number of retry attempts
§Default
3 retries
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.max_retries(5)
.build()?;Sourcepub fn initial_retry_delay(self, delay: Duration) -> Self
pub fn initial_retry_delay(self, delay: Duration) -> Self
Set the initial retry delay
Configure the delay before the first retry attempt. Subsequent retries use exponential backoff based on this initial delay.
§Arguments
delay- Initial delay duration
§Default
1 second
§Example
use composio_sdk::client::ComposioClient;
use std::time::Duration;
let client = ComposioClient::builder()
.api_key("your_api_key")
.initial_retry_delay(Duration::from_secs(2))
.build()?;Sourcepub fn max_retry_delay(self, delay: Duration) -> Self
pub fn max_retry_delay(self, delay: Duration) -> Self
Set the maximum retry delay
Configure the maximum delay between retry attempts. This caps the exponential backoff to prevent excessively long waits.
§Arguments
delay- Maximum delay duration
§Default
10 seconds
§Example
use composio_sdk::client::ComposioClient;
use std::time::Duration;
let client = ComposioClient::builder()
.api_key("your_api_key")
.max_retry_delay(Duration::from_secs(30))
.build()?;Sourcepub fn build(self) -> Result<ComposioClient, ComposioError>
pub fn build(self) -> Result<ComposioClient, ComposioError>
Build the client
Validates the configuration and constructs a ComposioClient instance.
The reqwest HTTP client is configured with the specified timeout and
default headers (including the API key).
§Errors
Returns an error if:
- API key is not provided or is empty
- Base URL is invalid (doesn’t start with http:// or https://)
- HTTP client construction fails
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;