pub struct ComposioClient { /* private fields */ }Expand description
Main client for interacting with Composio API
The client manages HTTP connections and configuration for all API requests. It includes automatic retry logic for transient failures and proper error handling.
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;Implementations§
Source§impl ComposioClient
impl ComposioClient
Sourcepub fn builder() -> ComposioClientBuilder
pub fn builder() -> ComposioClientBuilder
Create a new client builder
Returns a ComposioClientBuilder that can be used to configure and build
a ComposioClient instance.
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;Sourcepub fn http_client(&self) -> &Client
pub fn http_client(&self) -> &Client
Get a reference to the HTTP client
This is useful for advanced use cases where you need direct access to the underlying reqwest client.
Sourcepub fn config(&self) -> &ComposioConfig
pub fn config(&self) -> &ComposioConfig
Get a reference to the configuration
Returns the configuration used by this client.
Sourcepub fn create_session(&self, user_id: impl Into<String>) -> SessionBuilder<'_>
pub fn create_session(&self, user_id: impl Into<String>) -> SessionBuilder<'_>
Create a new session for a user
Returns a SessionBuilder that can be used to configure and create
a Tool Router session for the specified user.
§Arguments
user_id- User identifier for session isolation
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
let session = client
.create_session("user_123")
.toolkits(vec!["github", "gmail"])
.send()
.await?;Sourcepub async fn get_session(
&self,
session_id: impl Into<String>,
) -> Result<Session, ComposioError>
pub async fn get_session( &self, session_id: impl Into<String>, ) -> Result<Session, ComposioError>
Get an existing session by ID
Retrieves session details for a previously created Tool Router session. This is useful for inspecting session configuration and available tools.
§Arguments
session_id- The session ID to retrieve
§Errors
Returns an error if:
- Session not found (404)
- Network error occurs
- API returns an error response
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
let session = client.get_session("sess_abc123").await?;
println!("Session ID: {}", session.session_id());Trait Implementations§
Source§impl Clone for ComposioClient
impl Clone for ComposioClient
Source§fn clone(&self) -> ComposioClient
fn clone(&self) -> ComposioClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more