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 composio_sdk::models::versioning::{ToolkitVersion, ToolkitVersionParam};
use std::time::Duration;
use std::collections::HashMap;
let mut versions = HashMap::new();
versions.insert("github".to_string(), ToolkitVersion::Specific("20250906_01".to_string()));
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))
.toolkit_versions(ToolkitVersionParam::Versions(versions))
.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 toolkit_versions(self, versions: ToolkitVersionParam) -> Self
pub fn toolkit_versions(self, versions: ToolkitVersionParam) -> Self
Set toolkit version configuration
Configure which versions of toolkits to use. This allows you to:
- Use “latest” for all toolkits (default behavior)
- Specify different versions for different toolkits
- Pin specific toolkits to specific versions for stability
Version resolution follows this precedence:
COMPOSIO_TOOLKIT_VERSION_{TOOLKIT}environment variable (highest priority)- User-provided configuration (this method)
COMPOSIO_TOOLKIT_VERSIONglobal environment variable- Default to “latest”
§Arguments
versions- Toolkit version configuration
§Default
None (uses “latest” for all toolkits)
§Example
use composio_sdk::client::ComposioClient;
use composio_sdk::models::versioning::{ToolkitVersion, ToolkitVersionParam};
use std::collections::HashMap;
// Use latest for all toolkits
let client = ComposioClient::builder()
.api_key("your_api_key")
.toolkit_versions(ToolkitVersionParam::Latest)
.build()?;
// Use specific versions for specific toolkits
let mut versions = HashMap::new();
versions.insert("github".to_string(), ToolkitVersion::Specific("20250906_01".to_string()));
versions.insert("gmail".to_string(), ToolkitVersion::Latest);
let client = ComposioClient::builder()
.api_key("your_api_key")
.toolkit_versions(ToolkitVersionParam::Versions(versions))
.build()?;Sourcepub fn file_download_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn file_download_dir(self, dir: impl Into<PathBuf>) -> Self
Set the file download directory
Configure the directory where downloaded files will be saved. If not set, files will be downloaded to the current working directory.
§Arguments
dir- Path to the download directory
§Example
use composio_sdk::ComposioClient;
use std::path::PathBuf;
let client = ComposioClient::builder()
.api_key("your_api_key")
.file_download_dir(PathBuf::from("./downloads"))
.build()?;Sourcepub fn auto_upload_download_files(self, enabled: bool) -> Self
pub fn auto_upload_download_files(self, enabled: bool) -> Self
Enable or disable automatic file upload/download
When enabled (default), the SDK will automatically:
- Upload local file paths to S3 before tool execution
- Download file URLs returned by tools to local paths
§Arguments
enabled- Whether to enable automatic file handling
§Default
true
§Example
use composio_sdk::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.auto_upload_download_files(false)
.build()?;Sourcepub fn telemetry_enabled(self, enabled: bool) -> Self
pub fn telemetry_enabled(self, enabled: bool) -> Self
Enable or disable telemetry tracking
When enabled, the SDK will send anonymous usage telemetry to Composio. This helps improve the SDK but is disabled by default for privacy.
Telemetry is sent asynchronously and does not block operations.
§Arguments
enabled- Whether to enable telemetry
§Default
false (opt-in for privacy)
§Example
use composio_sdk::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.telemetry_enabled(true)
.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()?;