API Reference
This page documents the main Python SDK methods and objects for working with datasets.Dataset methods
list_sync
Dataset objects (without rows). Each dataset object includes:
slug(str): Unique identifier for the dataset.name(str): Human-readable name.description(str): Description of the dataset.num_rows(int): Number of rows in the dataset.columns(list[DatasetColumn]): List of column definitions.
list (async)
list_sync, suitable for use in async applications.
Returns:
Same as list_sync: a list of Dataset objects.
get_sync
slug(str, required): Dataset identifier.
Dataset object (see below).
get (async)
get_sync, suitable for use in async applications.
Parameters:
slug(str, required): Dataset identifier.
Dataset object with all rows included.
add_row_sync
slug(str, required): Dataset identifier.values(dict, required): Column name → value mapping. Values can be strings, numbers, orFileAttachmentobjects for file uploads.name(str, optional): Row identifier; auto-generated if omitted.ideal_output(str, optional): Expected output for evaluation.metadata(dict, optional): Arbitrary metadata for this row.
DatasetRow object representing the newly created row.
add_row (async)
add_row_sync, for use in async workflows.
Returns:
Same as add_row_sync: a DatasetRow object.
Dataset objects
Dataset
Represents a complete dataset, including schema and rows.
slug(str): Unique identifier.name(str): Human-readable name.description(str): Description of the dataset.num_rows(int): Number of rows.columns(list[DatasetColumn]): List of column definitions.rows(list[DatasetRow]): List of rows in the dataset.
DatasetColumn
Describes a single column in the dataset schema.
name(str): Column name.type(str): Data type (for example"string","number").description(str): Column description.
DatasetRow
Represents a single test case / row.
name(str): Row identifier.values(dict): Column name → value mapping.ideal_output(str | None): Expected output, when available.metadata(dict | None): Additional metadata for this row.
Error Handling
The following exceptions can be raised by dataset operations: API Errors (all inherit fromBasaltAPIError):
NotFoundError: The dataset does not exist (HTTP 404).UnauthorizedError: The API key is missing, invalid, or lacks permissions (HTTP 401).BadRequestError: Invalid request parameters (HTTP 400).ForbiddenError: API key lacks permissions for this resource (HTTP 403).BasaltAPIError: Other API-level errors.
FileValidationError: File validation failed before upload (unsupported type, too large, etc.).FileUploadError: File upload to S3 failed. Has optionalfile_keyattribute.
NetworkError: Network connectivity issues.
BasaltError: Base class for all Basalt SDK errors.
Data Objects
FileAttachment
Used to upload files as part of a dataset row.
source(str | Path | bytes | BinaryIO): File source. Can be a file path, bytes, or file-like object.content_type(str, optional): MIME type of the file (e.g.,"image/png","application/pdf","text/html","text/markdown"). If omitted, content type is auto-detected from the file extension or path.filename(str, optional): Filename to use. Required whensourceis bytes. Auto-determined otherwise.
image/pngimage/jpegapplication/pdftext/htmltext/markdown