Core client for connecting to SyftBox and discovering network services
Main client class for interacting with the SyftBox network and managing connections to distributed data and AI services.
Client(syftbox_path: str = None, api_url: str = None, verbose: bool = False)
Initialize a new syft-hub client to connect to the SyftBox network and discover available services.
The client automatically detects your SyftBox installation and configuration settings.
from syft_hub import Client
# Auto-detect SyftBox installation
client = Client()
# Custom SyftBox path
client = Client(syftbox_path="/custom/path/SyftBox")
# Enable verbose mode for debugging
client = Client(verbose=True)
show_services() -> None
Display all available services on the network in an interactive table that shows service details, capabilities, and costs. This method is optimized for Jupyter notebook environments where it renders as a sortable, filterable table.
# Show all available services in interactive table
client.show_services()
load_service(service_name: str) -> Service
Get a quick handle to a specific service using its unique network identifier, returning a Service object that provides direct access to chat or search capabilities.
Service - A service object with chat/search capabilities
# Load a data service
openmined_data = client.load_service("irina@openmined.org/openmined-about")
# Load a model service
claude_llm = client.load_service("aggregator@openmined.org/claude-sonnet-3.5")
chat_sync(service_name: str, messages: List[Dict[str, str]], **kwargs) -> ChatResponse
Send chat messages to an AI model service and receive responses synchronously, blocking until the response is complete.
This method is ideal for interactive applications where you need immediate responses, such as chatbots or real-time assistance features.
# Chat with a model service
response = client.chat_sync(
service_name="aggregator@openmined.org/claude-sonnet-3.5",
messages=[
{"role": "user", "content": "What's up bro?"}
]
)
print(response.content)
search_sync(service_name: str, message: str, **kwargs) -> SearchResponse
Perform a search against a data service's knowledge base and receive results synchronously. This method queries the service's indexed documents and returns N (limit=N) most relevant matches based on similarity scoring.
# Search a data service
results = client.search_sync(
service_name="irina@openmined.org/openmined-about",
message="attribution-based control",
limit=10
)
for result in results.results:
print(result.content, result.score)
pipeline(data_sources: List[Service], synthesizer: Service, context_format: str = "simple") -> Pipeline
Create your first Federated Retrieval-Augmented Generation (RAG) pipeline that combines multiple data sources with a synthesizer model wih ease. This method initiates the search in parallel across sources and aggregates them in the context of the model.
# Create pipeline with data sources and synthesizer
openmined_data = client.load_service("irina@openmined.org/openmined-about")
claude_llm = client.load_service("aggregator@openmined.org/claude-sonnet-3.5")
pipeline = client.pipeline(
data_sources=[openmined_data],
synthesizer=claude_llm
)
accounting_client: AccountingClient
Accounting Client is important to authenticate and use paid services on the network. As of today, everyone receives $20 in free credits upon login and automatically registered for accounting. To disable, use Client(set_accounting=False)
# Access accounting features
print(client.accounting_client)
__repr__() -> str
Display comprehensive client status and configuration information in an interactive widget for Jupyter notebooks or formatted text for terminal environments. This method shows your SyftBox path, connected services, account status, and network health. Use this for debugging connection issues or verifying your setup.
# Display client status
client # Shows SyftBox path, cache server, account, services found