Setup#
See also
Please refer to the Python SDK quickstart for a full example of working with the Python SDK.
First install the SDK.
pip install --upgrade segments-ai
Import the segments
package in your python file and and set up a client with an API key. An API key can be created on your user account page.
from segments import SegmentsClient
api_key = "YOUR_API_KEY"
client = SegmentsClient(api_key)
Or store your Segments API key in your environment (SEGMENTS_API_KEY = YOUR_API_KEY
):
from segments import SegmentsClient
client = SegmentsClient()
You can also use the client as a context manager:
with SegmentsClient() as client:
client.get_datasets()