API Resources
Overview
The Vi SDK provides a comprehensive API for interacting with the Datature Vi platform. All resources are accessed through the ViClient instance and follow a consistent, type-safe interface.
Prerequisites
- Vi SDK installed with authentication configured
- A secret key for API authentication
- Understanding of Vi SDK basics
- Familiarity with Python type hints and async/await patterns
Core resources
Manage datasets, exports, and downloads
Upload, download, and manage images
Create and manage annotations
Manage training runs and workflows
Download models and run inference
Manage training workflows
Access organization information
Quick reference
Client initialization
import vi
client = vi.Client(
secret_key="your-secret-key",
organization_id="your-org-id"
)Resource access pattern
All resources follow a consistent access pattern:
# List resources (with pagination)
for page in client.resource.list():
for item in page.items:
print(item.name)
# Get specific resource
resource = client.resource.get("resource-id")
# Create resource
new_resource = client.resource.create(...)
# Delete resource
client.resource.delete("resource-id")Common patterns
Pagination
All list operations support automatic pagination:
from vi.api.types import PaginationParams
# Custom page size
pagination = PaginationParams(page_size=50)
datasets = client.datasets.list(pagination=pagination)
# Iterate all pages
for page in client.datasets.list():
for dataset in page.items:
process(dataset)
# Get all items across pages
all_items = list(client.datasets.list().all_items())Error handling
Handle specific exceptions for better error management:
from vi import (
ViError,
ViNotFoundError,
ViAuthenticationError,
ViValidationError
)
try:
dataset = client.datasets.get("dataset-id")
except ViNotFoundError as e:
print(f"Not found: {e.message}")
except ViAuthenticationError as e:
print(f"Auth failed: {e.message}")
except ViValidationError as e:
print(f"Invalid params: {e.message}")
except ViError as e:
print(f"Error {e.error_code}: {e.message}")Progress tracking
Long-running operations support progress tracking:
# Download with progress bar
dataset = client.get_dataset(
dataset_id="dataset-id",
save_dir="./data",
show_progress=True # Shows progress bar
)
# Upload with progress tracking
result = client.assets.upload(
dataset_id="dataset-id",
paths="./images/",
wait_until_done=True # Wait for processing
)Resource hierarchy
ViClient
├── organizations (Organization)
├── datasets (Dataset)
│ ├── assets (Asset)
│ └── annotations (Annotation)
├── runs (Run)
│ └── models (Model)
└── flows (Flow)
Type hints
All SDK methods include complete type hints for better IDE support:
from pathlib import Path
from vi.api.resources.datasets.responses import Dataset
def process_dataset(
client: vi.Client,
dataset_id: str,
save_dir: Path | str
) -> Dataset:
"""Download and process a dataset."""
result = client.get_dataset(
dataset_id=dataset_id,
save_dir=save_dir
)
return resultRelated resources
- Vi SDK getting started — Quick start guide and tutorials
- Vi SDK installation — Install and configure the Vi SDK
- Datasets API — Manage datasets, exports, and downloads
- Assets API — Upload, download, and manage images
- Annotations API — Create and manage annotations
- Runs API — Manage training runs and workflows
- Models API — Download models and run inference
- Flows API — Manage training workflows
- Organizations API — Access organization information
- Inference guide — Load models and run predictions
- Vi SDK changelog — See what's new in the latest version
Need help?
We're here to support your VLMOps journey. Reach out through any of these channels:
Updated about 1 month ago
