Installation
Install the Sinkove Python SDK using pip:
Quick Start
Initialize the Client
import sinkove as sk
# Initialize with your API key
client = sk.client( "your_API_KEY" )
Store your API key securely using environment variables. See our API Keys
guide for best practices.
Basic Dataset Operations
List Available Datasets
# Get all your datasets
datasets = client.list_datasets()
for dataset in datasets:
print ( f "Dataset: { dataset.id } - Status: { dataset.status } " )
Access a Specific Dataset
# Get dataset by ID
dataset = client.dataset( "dataset_id_here" )
# Check dataset status
if dataset.ready():
print ( "Dataset is ready for download" )
else :
print ( f "Dataset status: { dataset.status } " )
Download Dataset
import time
# Get dataset
dataset = client.dataset( "dataset_id_here" )
# Wait for completion
while not dataset.ready():
print ( "Waiting for dataset to be ready..." )
time.sleep( 10 )
# Download to local file
dataset.save( "./my_dataset.zip" )
print ( "Dataset downloaded successfully!" )
Advanced Usage
Dataset Creation
# Create a new dataset
dataset_config = {
"model" : "chest-xray-v2" ,
"prompts" : [
"Severe cardiomegaly" ,
"Normal chest X-ray" ,
"Pneumonia with bilateral infiltrates"
],
"size" : 100
}
new_dataset = client.create_dataset(dataset_config)
print ( f "Created dataset: { new_dataset.id } " )
Monitoring Progress
def wait_for_dataset ( dataset , poll_interval = 30 ):
"""Wait for dataset completion with progress updates"""
while not dataset.ready():
status = dataset.status
progress = getattr (dataset, 'progress' , 'Unknown' )
print ( f "Dataset { dataset.id } : { status } - { progress } " )
time.sleep(poll_interval)
print ( f "Dataset { dataset.id } is ready!" )
return dataset
# Usage
dataset = client.dataset( "your_dataset_id" )
completed_dataset = wait_for_dataset(dataset)
Batch Operations
# Download multiple datasets
dataset_ids = [ "id1" , "id2" , "id3" ]
for dataset_id in dataset_ids:
dataset = client.dataset(dataset_id)
if dataset.ready():
filename = f "./datasets/ { dataset_id } .zip"
dataset.save(filename)
print ( f "Downloaded { dataset_id } " )
else :
print ( f "Dataset { dataset_id } not ready yet" )
Error Handling
Implement robust error handling for production use:
import sinkove as sk
from sinkove.exceptions import SinkovelAuthError, SinkovelAPIError
try :
client = sk.client( "your_API_KEY" )
dataset = client.dataset( "dataset_id" )
if dataset.ready():
dataset.save( "./dataset.zip" )
else :
print ( f "Dataset not ready. Status: { dataset.status } " )
except SinkovelAuthError:
print ( "Authentication failed. Check your API key." )
except SinkovelAPIError as e:
print ( f "API error: { e } " )
except Exception as e:
print ( f "Unexpected error: { e } " )
SDK Reference
Client Methods
Method Description Returns client.list_datasets()
Get all datasets List of Dataset objects client.dataset(id)
Get specific dataset Dataset object client.create_dataset(config)
Create new dataset Dataset object
Dataset Properties
Property Description Type dataset.id
Unique dataset identifier String dataset.status
Current status String dataset.ready()
Check if ready for download Boolean dataset.save(path)
Download dataset None
Dataset Status Values
pending
- Dataset creation queued
processing
- Currently generating images
ready
- Available for download
failed
- Generation failed
expired
- No longer available
Configuration
Environment Variables
Set these environment variables for easier configuration:
export SINKOVE_API_KEY = "your_api_key_here"
export SINKOVE_BASE_URL = "https://api.sinkove.com" # Optional
import os
import sinkove as sk
# SDK will automatically use SINKOVE_API_KEY
client = sk.client()
# Or override with custom settings
client = sk.client(
api_key = os.getenv( "SINKOVE_API_KEY" ),
base_url = os.getenv( "SINKOVE_BASE_URL" , "https://api.sinkove.com" )
)
Examples
Complete Workflow Example
import sinkove as sk
import time
import os
def generate_and_download_dataset ():
"""Complete example: create, monitor, and download dataset"""
# Initialize client
client = sk.client(os.getenv( "SINKOVE_API_KEY" ))
# Create dataset
config = {
"model" : "chest-xray-v2" ,
"prompts" : [
"Severe cardiomegaly" ,
"Bilateral pneumonia" ,
"Normal chest X-ray"
],
"size" : 50
}
print ( "Creating dataset..." )
dataset = client.create_dataset(config)
print ( f "Dataset created: { dataset.id } " )
# Monitor progress
print ( "Waiting for completion..." )
while not dataset.ready():
print ( f "Status: { dataset.status } " )
time.sleep( 30 )
# Download
filename = f "./medical_dataset_ { dataset.id } .zip"
dataset.save(filename)
print ( f "Dataset downloaded to: { filename } " )
if __name__ == "__main__" :
generate_and_download_dataset()
Need Help? Contact our support team for SDK assistance and integration guidance