HubAI SDK
Overview
hubai-sdk package provides programmatic access to the AI & Models area of Luxonis Hub. Use it to manage models, variants, and instances, or to trigger online conversion from Python or the command line.Key capabilities:- Manage models, variants, and instances in Hub AI
- Run online conversion for RVC2, RVC3, RVC4, and Hailo targets
- Use the same workflows from Python scripts or the
hubaiCLI - Access advanced conversion options that are not exposed in the Hub UI
If you only need the conversion workflow, see the HubAI online conversion guide.
Installation
Command Line
1pip install hubai-sdkCommand Line
1git clone https://github.com/luxonis/hubai-sdk.git
2cd hubai-sdk
3pip install -e .Authentication
Command Line
1export HUBAI_API_KEY="your-api-key"Python
1import os
2
3from hubai_sdk import HubAIClient
4
5client = HubAIClient(api_key=os.getenv("HUBAI_API_KEY"))hubai CLI. Start by logging in:Command Line
1hubai loginQuick Start
Python
1models = client.models.list_models(limit=5)
2print(f"Found {len(models)} models")
3
4response = client.convert.RVC4(
5 path="path/to/model.onnx",
6 name="my-converted-model",
7)
8
9print(f"Converted model downloaded to: {response.downloaded_path}")Model Management
HubAIClient.models namespace. You can list the models, retrieve information about a specific model, create a new model, update an existing model, and delete a model.Python
1# Listing the models
2models = client.models.list_models(
3 tasks=["OBJECT_DETECTION"],
4 is_public=True,
5 limit=10
6)
7
8# Get model Info
9model = client.models.get_model("model-id-or-slug")
10
11# Create a new model
12new_model = client.models.create_model(
13 name="my-model",
14 license_type="MIT",
15 is_public=False,
16 description="My awesome model",
17 tasks=["OBJECT_DETECTION"]
18)
19
20# Update an existing model (pass only the fields you want to update)
21updated_model = client.models.update_model(
22 new_model.id,
23 license_type="Apache 2.0",
24 description="Updated description"
25)
26
27# Delete a model
28client.models.delete_model(new_model.id)Variant Management
Python
1# Listing the variants
2variants = client.variants.list_variants(model_id="model-id")
3
4# Get variant info
5variant = client.variants.get_variant("variant-id")
6
7new_variant = client.variants.create_variant(
8 name="my-variant",
9 model_id="model-id",
10 variant_version="1.0.0",
11 description="My first variant."
12)
13
14# Delete a variant
15client.variants.delete_variant("variant-id")New Verison of the Variant
Python
1variant = client.variants.get_variant("variant-id")
2
3new_version_of_variant = client.variants.create_variant(
4 name=variant.name,
5 model_id=variant.model_id,
6 variant_version="new-version-number",
7)Instance Management
Python
1# Listing the instances
2instances = client.instances.list_instances(model_id="model-id", variant_id="variant-id")
3
4# Get instance info
5instance = client.instances.get_instance("instance-id")
6
7# Download the instance
8downloaded_path = client.instances.download_instance("instance-id", output_dir="/path/to/output/directory")
9
10# Create a new instance
11from hubai_sdk.utils.types import ModelType
12
13instance = client.instances.create_instance(
14 name="my-instance",
15 variant_id="variant-id",
16 model_type=ModelType.ONNX,
17 input_shape=[1, 3, 288, 512]
18)
19
20# Retrieve the config of the instance
21config = client.instances.get_config("instance-id")
22
23# Retrieve the files of the instance
24files = client.instances.get_files("instance-id")
25
26# Upload a file to the instance
27client.instances.upload_file("path/to/nn_archive.tar.xz", "instance-id")
28
29# Delete an instance
30client.instances.delete_instance("instance-id")Conversion
HubAIClient.convert namespace.Python
1# Convert a model to RVC4 format
2response = client.convert.RVC4(
3 path="/path/to/your/nn_archive.tar.xz",
4 name="my-converted-model",
5 quantization_mode="INT8_STANDARD",
6 quantization_data="GENERAL",
7)
8
9downloaded_path = response.downloaded_path
10instance = response.instancemy-converted-model. When conversion is finished, the converted model is downloaded to the downloaded_path and the Model Instance is returned in the instance variable.Python
1# Convert YOLO model to RVC4 format
2response = client.convert.RVC4(
3 path="path/to/your/yolo-model.pt",
4 name="my-converted-yolo-model",
5 quantization_mode="INT8_STANDARD",
6 quantization_data="GENERAL",
7 yolo_input_shape=[512, 288],
8 yolo_class_names=["list", "of", "class", "names"],
9 yolo_version="yolov8", # optional override
10)yolo_version explicitly. If it is omitted, the backend attempts to detect the version automatically from the PyTorch model file, but the file still needs to come from one of the supported YOLO versions. The current explicit yolo_version values exposed by the SDK are yolov5, yolov6r1, yolov6r3, yolov6r4, yolov7, yolov8, yolov9, yolov10, yolov11, yolov12, yolov26, and goldyolo. For the exact set of supported YOLO families, variants, and current limitations, see the upstream supported models table.For more information about online conversion, please refer to the Hub Online Conversion guide.