Python QuickStart
Follow these steps to use the Pieces Python SDK.
Download Pieces OS
You must either have Pieces OS installed on your local machine or have access to a remote instance of Pieces OS to use this SDK.
Download Pieces OS for your operating system:
Install Python SDK
Use pip to install the Pieces Python SDK using the following command:
pip install pieces_os_client
Initialize SDK
After installing the SDK, you must initialize the SDK with your base URL. The base URL will depend on your setup.
If you are using a local instance of Pieces OS:
- On macOS/Windows, use http://localhost:1000
- On Linux, use http://localhost:5323
If you are using a remote instance of Pieces OS, use the URL you have set up for that.
Getting started
Create a Python script to test the connection to the Pieces OS server. Create a main.py
file to test the connection.
from pieces_os_client.wrapper import PiecesClient
import platform
# Defining the port based on the operating system
platform_info = platform.platform()
if 'Linux' in platform_info:
port = 5323
else:
port = 1000
pieces_client = PiecesClient(config={'host': f'http://localhost:{port}'})
In the code snippet above, we use the platform package to determine the base URL based on the operating system.
Run the following command to execute the script:
python3 main.py
Community
If you have created your own SDK or any other technology-specific integration and would like us to list it here under community-maintained SDKs/integrations, please contact us.
If you would like to help us expand Pieces' list of SDKs, you can start a new discussion on our Open Source Discussions, and you can also join our Discord.