syft-hub SDK is in beta. Payments are disabled during beta; enjoy $20 in free credits.

Client API

Core client for connecting to SyftBox and discovering network services

syft_hub.Client

Main client class for interacting with the SyftBox network and managing connections to distributed data and AI services.

Constructor

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.

Parameters

syftbox_path str optional
Path to SyftBox directory.
~/SyftBox
api_url str optional
Custom API endpoint URL. Defaults to SyftBox configuration.
verbose bool optional
Enable verbose logging.
False

Example

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)

Service Discovery Methods

Show Services


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.

Example

# Show all available services in interactive table
client.show_services()

Load Service


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.

Parameters

service_name str required
Service identifier in format "datasite@domain/service-name".

Returns

Service - A service object with chat/search capabilities

Example

# 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


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.

Parameters

service_name str required
Service identifier.
messages List[Dict] required
List of message dictionaries with role and content keys.
**kwargs optional optional
Additional parameters like temperature, max_tokens.

Example

# 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


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.

Parameters

service_name str required
Service identifier.
message str required
Search query.
**kwargs optional optional
Additional parameters like limit, similarity_threshold.

Example

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

Pipeline


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.

Parameters

data_sources List[Service] required
List of data services for search/retrieval.
synthesizer Service required
Chat service for response generation.
context_format str optional
Format for search context.
"simple"

Example

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

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)

Example

# Access accounting features
print(client.accounting_client)

Client Info

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

Example

# Display client status
client  # Shows SyftBox path, cache server, account, services found