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 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

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 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, 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