Module client

Module client 

Source
Expand description

High-level client implementations for interacting with Claude.

This module provides two client types for different use cases:

  • AsyncClient - Asynchronous client using Tokio (recommended for most applications)
  • SyncClient - Synchronous client using standard library threads

Both clients handle:

  • Process lifecycle management
  • Message serialization/deserialization
  • Response streaming
  • Error handling
  • Automatic version compatibility checking

§Choosing a Client

Use AsyncClient when:

  • Building async applications with Tokio
  • You need concurrent operations
  • Working with web frameworks like Axum or Actix

Use SyncClient when:

  • Building CLI tools without async runtime
  • Integrating with synchronous codebases
  • Simplicity is more important than performance

§Example

use claude_codes::AsyncClient;

let mut client = AsyncClient::with_defaults().await?;
let responses = client.query("Hello, Claude!").await?;

use claude_codes::{SyncClient, ClaudeInput};

let mut client = SyncClient::with_defaults()?;
let input = ClaudeInput::user_message("Hello!", uuid::Uuid::new_v4());
let responses = client.query(input)?;

Re-exports§

pub use async::AsyncClient;
pub use sync::SyncClient;

Modules§

async
Asynchronous client for Claude communication
sync
Synchronous client for Claude communication