Skip to main content

ComposioClientBuilder

Struct ComposioClientBuilder 

Source
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

Source

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 be String or &str)
§Example
use composio_sdk::client::ComposioClient;

let client = ComposioClient::builder()
    .api_key("your_api_key")
    .build()?;
Source

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()?;
Source

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()?;
Source

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()?;
Source

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()?;
Source

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()?;
Source

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:

  1. COMPOSIO_TOOLKIT_VERSION_{TOOLKIT} environment variable (highest priority)
  2. User-provided configuration (this method)
  3. COMPOSIO_TOOLKIT_VERSION global environment variable
  4. 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()?;
Source

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()?;
Source

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()?;
Source

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()?;
Source

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()?;

Trait Implementations§

Source§

impl Debug for ComposioClientBuilder

Source§

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

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

impl Default for ComposioClientBuilder

Source§

fn default() -> ComposioClientBuilder

Returns the “default value” for a type. 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> 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> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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