Resource Classes

Resource classes provide access to different parts of the Moderately AI platform API.

Synchronous Resources

Files

Files resource for the Moderately AI API.

class moderatelyai_sdk.resources.files.Files(client)[source]

Bases: BaseResource

Manage files in your team.

The Files resource provides methods for uploading, downloading, listing, and managing files. All methods return FileModel instances which provide rich functionality for file operations.

Key Features: - Upload files with automatic MIME type detection - Download files to memory or disk - List and filter files with pagination - Rich file type detection (CSV, images, documents, etc.) - Automatic presigned URL handling for secure transfers

Examples

```python # Upload a file and get a FileModel instance file = client.files.upload(

file=”/path/to/data.csv”, name=”Dataset”

)

# Use rich FileModel methods if file.is_ready() and file.is_csv():

content = file.download() # Download to memory file.download(path=”./local_copy.csv”) # Download to disk

# List files with filtering files_response = client.files.list(

mime_type=”text/csv”, page_size=20

) csv_files = files_response[“items”] # List of FileModel instances

# Get a specific file file = client.files.retrieve(“file_123”) print(f”File: {file.name} ({file.file_size} bytes)”)

# Delete files file.delete() # Using FileModel method # OR client.files.delete(“file_123”) # Using resource method ```

Parameters:

client (BaseClient)

list(*, dataset_id=None, status=None, mime_type=None, file_hashes=None, page=1, page_size=10, order_by='created_at', order_direction='desc')[source]

List all files with pagination and filtering.

Returns a paginated response containing FileModel instances. Results are automatically filtered to the team specified in the client configuration.

Parameters:
  • dataset_id (Optional[str]) – Filter files by dataset ID.

  • status (Optional[str]) – Filter files by status (e.g., “completed”, “processing”, “error”).

  • mime_type (Optional[str]) – Filter files by MIME type (e.g., “text/csv”, “application/pdf”).

  • file_hashes (Optional[str]) – Filter files by SHA256 hash. Can be a single hash string.

  • page (int) – Page number (1-based). Defaults to 1.

  • page_size (int) – Number of items per page (max 100). Defaults to 10.

  • order_by (str) – Field to sort by. Defaults to “created_at”.

  • order_direction (str) – Sort direction (“asc” or “desc”). Defaults to “desc”.

Return type:

Dict[str, Any]

Returns:

Dictionary with “items” (list of FileModel instances) and “pagination” info.

Example

```python # List recent CSV files response = client.files.list(

mime_type=”text/csv”, page_size=20, order_direction=”desc”

)

csv_files = response[“items”] # List of FileModel instances for file in csv_files:

if file.is_ready():

print(f”Ready: {file.name} ({file.file_size} bytes)”)

```

retrieve(file_id)[source]

Retrieve a specific file by ID.

Parameters:

file_id (str) – The ID of the file to retrieve.

Return type:

FileModel

Returns:

FileModel instance with rich file operations.

Raises:

NotFoundError – If the file doesn’t exist.

Example

```python file = client.files.retrieve(“file_123”) print(f”File: {file.name} ({file.mime_type})”)

if file.is_ready():

content = file.download()

```

upload(file, *, name=None, metadata=None, **kwargs)[source]

Upload a file using secure presigned URL workflow.

Accepts files in multiple convenient formats and handles all the complexity of secure upload automatically, including SHA256 hashing, MIME type detection, and presigned URL generation.

Supported file inputs: - File paths (str or Path objects) - Raw bytes data - File-like objects with .read() method (buffers, streams)

Parameters:
  • file (Union[str, Path, bytes, Any]) – The file to upload in any supported format

  • name (Optional[str]) – Custom display name for the file. If not provided, uses the filename from path or defaults to a generic name.

  • metadata (Optional[Dict[str, Any]]) – Additional metadata dictionary to store with the file.

  • **kwargs (Any) – Additional file properties.

Return type:

FileModel

Returns:

FileModel instance representing the uploaded file with rich operations.

Raises:
  • ValueError – If file is invalid, not found, or unsupported format.

  • APIError – If upload process fails at any step.

Examples

```python # Upload from file path file = client.files.upload(“/path/to/document.pdf”)

# Upload with custom name and metadata file = client.files.upload(

file=”data.csv”, name=”Customer Data”, metadata={“category”: “sales”, “quarter”: “Q1”}

)

# Upload raw bytes with open(“image.jpg”, “rb”) as f:

file = client.files.upload(

file=f.read(), name=”Profile Picture”

)

# Upload from file-like object import io buffer = io.BytesIO(b”Hello, World!”) file = client.files.upload(buffer, name=”greeting.txt”)

# Use the returned FileModel if file.is_ready():

print(f”Uploaded: {file.name} ({file.file_size} bytes)”)

```

delete(file_id)[source]

Delete a file permanently.

This operation cannot be undone. The file will be removed from both the database and cloud storage. Consider using FileModel.delete() for better ergonomics.

Parameters:

file_id (str) – The ID of the file to delete.

Raises:
Return type:

None

Example

```python # Delete using resource method client.files.delete(“file_123”)

# OR delete using FileModel (recommended) file = client.files.retrieve(“file_123”) file.delete() ```

download(file_id, *, path=None)[source]

Download file content.

Note: Consider using FileModel.download() instead for better ergonomics:

file = client.files.retrieve(file_id) content = file.download(path=path)

Parameters:
  • file_id (str) – The ID of the file to download.

  • path (Union[str, Path, None]) – Optional path to save the file. If provided, saves to this location. If not provided, returns the file content as bytes.

Returns:

None (file is saved to disk) If path is not provided: The file content as bytes

Return type:

If path is provided

Raises:
  • NotFoundError – If the file doesn’t exist.

  • IOError – If unable to write to the specified path.

Users

Users resource for the Moderately AI API.

class moderatelyai_sdk.resources.users.Users(client)[source]

Bases: BaseResource

Manage users in your organization.

Note: The Users resource only supports read and update operations. User creation and deletion are handled through other mechanisms.

Examples

```python # List all users (returns raw paginated data) users_response = client.users.list()

# Get a specific user with rich functionality user = client.users.retrieve(“user_123”)

# Use rich user operations print(f”User: {user.display_name()} ({user.full_name})”) print(f”Nickname: {user.nickname}”) print(f”Created: {user.formatted_created_at()}”)

# Update user profile user = user.update_profile(full_name=”Jane Smith”)

# Or update via resource user = client.users.update(“user_123”, full_name=”John Doe”) ```

Parameters:

client (BaseClient)

list(*, page=1, page_size=10, order_by='created_at', order_direction='desc')[source]

List all users with pagination.

Parameters:
  • page (int) – Page number (1-based). Defaults to 1.

  • page_size (int) – Number of items per page. Defaults to 10.

  • order_by (str) – Field to sort by. Defaults to “created_at”.

  • order_direction (str) – Sort direction (“asc” or “desc”). Defaults to “desc”.

Return type:

PaginatedResponse

Returns:

Paginated list of users.

retrieve(user_id)[source]

Retrieve a specific user by ID.

Parameters:

user_id (str) – The ID of the user to retrieve.

Return type:

UserModel

Returns:

The user model with rich functionality.

Raises:

NotFoundError – If the user doesn’t exist.

update(user_id, *, full_name, **kwargs)[source]

Update an existing user.

Parameters:
  • user_id (str) – The ID of the user to update.

  • full_name (str) – New full name for the user (required).

  • **kwargs – Additional properties to update.

Return type:

UserModel

Returns:

The updated user model with rich functionality.

Raises:

Teams

Teams resource for the Moderately AI API.

class moderatelyai_sdk.resources.teams.Teams(client)[source]

Bases: BaseResource

Manage teams in your organization.

Examples

```python # List all teams teams = client.teams.list()

# Get a specific team team = client.teams.retrieve(“team_123”)

# Create a new team team = client.teams.create(

name=”Engineering Team”, description=”Software development team”

)

# Update a team team = client.teams.update(

“team_123”, name=”Updated Team Name”

)

# Delete a team client.teams.delete(“team_123”) ```

Parameters:

client (BaseClient)

list(*, page=1, page_size=10, order_by='created_at', order_direction='desc')[source]

List all teams with pagination.

Parameters:
  • page (int) – Page number (1-based). Defaults to 1.

  • page_size (int) – Number of items per page. Defaults to 10.

  • order_by (str) – Field to sort by. Defaults to “created_at”.

  • order_direction (str) – Sort direction (“asc” or “desc”). Defaults to “desc”.

Return type:

PaginatedResponse

Returns:

Paginated list of teams.

retrieve(team_id)[source]

Retrieve a specific team by ID.

Parameters:

team_id (str) – The ID of the team to retrieve.

Return type:

Team

Returns:

The team data.

Raises:

NotFoundError – If the team doesn’t exist.

create(*, name, description=None, **kwargs)[source]

Create a new team.

Parameters:
  • name (str) – The team’s name.

  • description (Optional[str]) – The team’s description.

  • **kwargs – Additional team properties.

Return type:

Team

Returns:

The created team data.

Raises:

ValidationError – If the request data is invalid.

update(team_id, *, name=None, description=None, **kwargs)[source]

Update an existing team.

Parameters:
  • team_id (str) – The ID of the team to update.

  • name (Optional[str]) – New team name.

  • description (Optional[str]) – New team description.

  • **kwargs – Additional properties to update.

Return type:

Team

Returns:

The updated team data.

Raises:
delete(team_id)[source]

Delete a team.

Parameters:

team_id (str) – The ID of the team to delete.

Raises:

NotFoundError – If the team doesn’t exist.

Return type:

None

Agents

Agents resource for the Moderately AI API.

class moderatelyai_sdk.resources.agents.Agents(client)[source]

Bases: BaseResource

Manage AI agents in your teams.

Examples

```python # List all agents agents = client.agents.list()

# Get a specific agent agent = client.agents.retrieve(“agent_123”)

# Create a new agent agent = client.agents.create(

name=”Customer Support Agent”, team_id=”team_123”, description=”Handles customer inquiries”

)

# Update an agent agent = client.agents.update(

“agent_123”, name=”Updated Agent Name”

)

# Delete an agent client.agents.delete(“agent_123”) ```

Parameters:

client (BaseClient)

list(*, page=1, page_size=10, order_by='created_at', order_direction='desc')[source]

List all agents with pagination.

Note: Results are automatically filtered to the team specified in the client.

Parameters:
  • page (int) – Page number (1-based). Defaults to 1.

  • page_size (int) – Number of items per page. Defaults to 10.

  • order_by (str) – Field to sort by. Defaults to “created_at”.

  • order_direction (str) – Sort direction (“asc” or “desc”). Defaults to “desc”.

Return type:

PaginatedResponse

Returns:

Paginated list of agents for the client’s team.

retrieve(agent_id)[source]

Retrieve a specific agent by ID.

Parameters:

agent_id (str) – The ID of the agent to retrieve.

Return type:

Agent

Returns:

The agent data.

Raises:

NotFoundError – If the agent doesn’t exist.

create(*, name, description=None, **kwargs)[source]

Create a new agent.

Note: The agent will be created in the team specified in the client.

Parameters:
  • name (str) – The agent’s name.

  • description (Optional[str]) – The agent’s description.

  • **kwargs – Additional agent properties.

Return type:

Agent

Returns:

The created agent data.

Raises:

ValidationError – If the request data is invalid.

update(agent_id, *, name=None, description=None, **kwargs)[source]

Update an existing agent.

Parameters:
  • agent_id (str) – The ID of the agent to update.

  • name (Optional[str]) – New agent name.

  • description (Optional[str]) – New agent description.

  • **kwargs – Additional properties to update.

Return type:

Agent

Returns:

The updated agent data.

Raises:
delete(agent_id)[source]

Delete an agent.

Parameters:

agent_id (str) – The ID of the agent to delete.

Raises:

NotFoundError – If the agent doesn’t exist.

Return type:

None

Agent Executions

Agent executions resource for the Moderately AI API.

class moderatelyai_sdk.resources.agent_executions.AgentExecutions(client)[source]

Bases: BaseResource

Manage agent executions and monitor their progress.

Examples

```python # List all executions executions = client.agent_executions.list()

# Get a specific execution execution = client.agent_executions.retrieve(“execution_123”)

# Create a new execution execution = client.agent_executions.create(

agent_id=”agent_123”, input_data={“message”: “Hello, world!”}

)

# Cancel a running execution client.agent_executions.cancel(“execution_123”) ```

Parameters:

client (BaseClient)

list(*, agent_id=None, status=None, page=1, page_size=10, order_by='created_at', order_direction='desc')[source]

List all agent executions with pagination.

Parameters:
  • agent_id (Optional[str]) – Filter executions by agent ID.

  • status (Optional[str]) – Filter executions by status (e.g., “running”, “completed”, “failed”).

  • page (int) – Page number (1-based). Defaults to 1.

  • page_size (int) – Number of items per page. Defaults to 10.

  • order_by (str) – Field to sort by. Defaults to “created_at”.

  • order_direction (str) – Sort direction (“asc” or “desc”). Defaults to “desc”.

Return type:

PaginatedResponse

Returns:

Paginated list of agent executions.

retrieve(execution_id)[source]

Retrieve a specific agent execution by ID.

Parameters:

execution_id (str) – The ID of the execution to retrieve.

Return type:

AgentExecution

Returns:

The agent execution data.

Raises:

NotFoundError – If the execution doesn’t exist.

create(*, agent_id, input_data=None, **kwargs)[source]

Create a new agent execution.

Parameters:
  • agent_id (str) – The ID of the agent to execute.

  • input_data (Optional[Dict[str, Any]]) – Input data to pass to the agent.

  • **kwargs – Additional execution properties.

Return type:

AgentExecution

Returns:

The created agent execution data.

Raises:
cancel(execution_id)[source]

Cancel a running agent execution.

Parameters:

execution_id (str) – The ID of the execution to cancel.

Return type:

AgentExecution

Returns:

The updated execution data.

Raises:
  • NotFoundError – If the execution doesn’t exist.

  • ConflictError – If the execution cannot be cancelled (e.g., already completed).

wait_for_completion(execution_id, *, timeout=None, poll_interval=2.0)[source]

Wait for an agent execution to complete.

This is a convenience method that polls the execution status until it reaches a terminal state (completed, failed, or cancelled).

Parameters:
  • execution_id (str) – The ID of the execution to wait for.

  • timeout (Optional[float]) – Maximum time to wait in seconds. If None, waits indefinitely.

  • poll_interval (float) – Time between status checks in seconds. Defaults to 2.0.

Return type:

AgentExecution

Returns:

The final execution data.

Raises:

Datasets

Datasets resource for the Moderately AI API.

class moderatelyai_sdk.resources.datasets.Datasets(client)[source]

Bases: BaseResource

Manage datasets in your teams.

Examples

```python # List all datasets (still returns raw data) datasets = client.datasets.list()

# Get a dataset with rich functionality dataset = client.datasets.retrieve(“dataset_123”)

# Create a new dataset dataset = client.datasets.create(

name=”Customer Data”, description=”Customer interaction dataset”

)

# Now use rich methods on the dataset object:

# Upload data to the dataset version = dataset.upload_data(“/path/to/sales_data.csv”) print(f”Uploaded version {version.version_no} with {version.row_count} rows”)

# Download current data data_bytes = dataset.download_data() dataset.download_data(path=”/save/local_copy.csv”)

# Work with specific versions versions = dataset.list_data_versions() old_data = dataset.download_data(version_id=”version_123”)

# Schema management (NEW!) # Simple schema creation schema = dataset.create_schema([

{“name”: “user_id”, “type”: “int”, “required”: True}, {“name”: “email”, “type”: “string”}, {“name”: “signup_date”, “type”: “datetime”},

])

# Auto-infer schema from sample data schema = dataset.create_schema_from_sample(“sample.csv”)

# Advanced schema with fluent API schema = (dataset.schema_builder()

.add_column(“id”, “int”, required=True) .add_column(“name”, “string”, description=”User name”) .with_parsing(delimiter=”,”, header_row=1) .as_current() .create())

# Access dataset metadata print(f”Dataset has {dataset.record_count} records”) print(f”Processing status: {dataset.processing_status}”) current_schema = dataset.get_current_schema()

# Update dataset dataset.update(name=”Updated Dataset Name”, should_process=True)

# Delete dataset dataset.delete() ```

Parameters:

client (BaseClient)

list(*, dataset_ids=None, name_like=None, name=None, page=1, page_size=10, order_by='createdAt', order_direction='desc')[source]

List all datasets with pagination.

Note: Results are automatically filtered to the team specified in the client.

Parameters:
  • dataset_ids (Optional[List[str]]) – Filter by specific dataset IDs.

  • name_like (Optional[str]) – Filter by datasets with names containing this text.

  • name (Optional[str]) – Filter by exact dataset name.

  • page (int) – Page number (1-based). Defaults to 1.

  • page_size (int) – Number of items per page. Defaults to 10.

  • order_by (str) – Field to sort by (“createdAt”, “updatedAt”, “name”). Defaults to “createdAt”.

  • order_direction (str) – Sort direction (“asc” or “desc”). Defaults to “desc”.

Return type:

PaginatedResponse

Returns:

Paginated list of datasets for the client’s team.

retrieve(dataset_id)[source]

Retrieve a specific dataset by ID.

Parameters:

dataset_id (str) – The ID of the dataset to retrieve.

Return type:

DatasetModel

Returns:

The dataset model with rich functionality.

Raises:

NotFoundError – If the dataset doesn’t exist.

create(*, name, description=None, **kwargs)[source]

Create a new dataset.

Note: The dataset will be created in the team specified in the client.

Parameters:
  • name (str) – The dataset’s name.

  • description (Optional[str]) – The dataset’s description.

  • **kwargs – Additional dataset properties.

Return type:

DatasetModel

Returns:

The created dataset model with rich functionality.

Raises:

ValidationError – If the request data is invalid.

update(dataset_id, *, name=None, description=None, should_process=None, **kwargs)[source]

Update an existing dataset.

Parameters:
  • dataset_id (str) – The ID of the dataset to update.

  • name (Optional[str]) – New dataset name.

  • description (Optional[str]) – New dataset description.

  • should_process (Optional[bool]) – Whether to trigger dataset processing workflow.

  • **kwargs – Additional properties to update.

Return type:

DatasetModel

Returns:

The updated dataset model with rich functionality.

Raises:
delete(dataset_id)[source]

Delete a dataset.

Parameters:

dataset_id (str) – The ID of the dataset to delete.

Raises:

NotFoundError – If the dataset doesn’t exist.

Return type:

None

Pipelines

Pipelines resource for the Moderately AI API.

class moderatelyai_sdk.resources.pipelines.Pipelines(client)[source]

Bases: BaseResource

Manage pipelines in your teams.

Pipelines are basic metadata containers with name, description, and team ownership. The actual pipeline logic is stored in PipelineConfigurationVersions. Execution instances are managed through PipelineExecutions.

Examples

```python # List all pipelines pipelines = client.pipelines.list()

# Get a specific pipeline pipeline = client.pipelines.retrieve(“pipeline_123”)

# Create a new pipeline pipeline = client.pipelines.create(

name=”Document Analysis Pipeline”, description=”Processes legal documents”

)

# Update a pipeline pipeline = client.pipelines.update(

“pipeline_123”, name=”Updated Pipeline Name”

)

# Delete a pipeline client.pipelines.delete(“pipeline_123”) ```

Parameters:

client (BaseClient)

list(*, pipeline_ids=None, name_like=None, page=1, page_size=10, order_by=None, order_direction='asc')[source]

List all pipelines with pagination.

Note: Results are automatically filtered to the team specified in the client.

Parameters:
  • pipeline_ids (Optional[List[str]]) – Filter by specific pipeline IDs.

  • name_like (Optional[str]) – Filter pipelines by name (case-insensitive partial match).

  • page (int) – Page number (1-based). Defaults to 1.

  • page_size (int) – Number of items per page (1-1000). Defaults to 10.

  • order_by (Optional[str]) – Field to sort by (“name”, “createdAt”, “updatedAt”).

  • order_direction (str) – Sort direction (“asc” or “desc”). Defaults to “asc”.

Return type:

PaginatedResponse

Returns:

Paginated list of pipelines for the client’s team.

retrieve(pipeline_id)[source]

Retrieve a specific pipeline by ID.

Parameters:

pipeline_id (str) – The ID of the pipeline to retrieve.

Return type:

PipelineModel

Returns:

The pipeline model instance.

Raises:

NotFoundError – If the pipeline doesn’t exist.

create(*, name, description=None, **kwargs)[source]

Create a new pipeline.

Note: The pipeline will be created in the team specified in the client.

Parameters:
  • name (str) – The pipeline’s name (1-255 characters). Must be unique within the team.

  • description (Optional[str]) – The pipeline’s description (max 1000 characters).

  • **kwargs – Additional pipeline properties.

Return type:

PipelineModel

Returns:

The created pipeline model instance.

Raises:
update(pipeline_id, *, name=None, description=None, **kwargs)[source]

Update an existing pipeline.

Parameters:
  • pipeline_id (str) – The ID of the pipeline to update.

  • name (Optional[str]) – New pipeline name (1-255 characters). Must be unique within the team.

  • description (Optional[str]) – New pipeline description (max 1000 characters).

  • **kwargs – Additional properties to update.

Return type:

PipelineModel

Returns:

The updated pipeline model instance.

Raises:
delete(pipeline_id)[source]

Delete a pipeline.

Parameters:

pipeline_id (str) – The ID of the pipeline to delete.

Raises:

NotFoundError – If the pipeline doesn’t exist.

Return type:

None

Pipeline Configuration Versions

Pipeline Configuration Versions resource for the Moderately AI API.

class moderatelyai_sdk.resources.pipeline_configuration_versions.PipelineConfigurationVersions(client)[source]

Bases: BaseResource

Manage pipeline configuration versions.

Configuration versions contain the actual pipeline logic - the blocks, connections, and workflow definition. Each pipeline can have multiple configuration versions to track changes over time.

Examples

```python # List configuration versions versions = client.pipeline_configuration_versions.list()

# Get a specific version version = client.pipeline_configuration_versions.retrieve(“version_123”)

# Create a new configuration version version = client.pipeline_configuration_versions.create(

pipeline_id=”pipeline_123”, configuration={

“id”: “my-pipeline”, “name”: “Document Processor”, “version”: “1.0.0”, “blocks”: {

“input”: {

“id”: “input”, “type”: “input”, “config”: {“json_schema”: {“type”: “object”}}

}

}

}

)

# Update a configuration version version = client.pipeline_configuration_versions.update(

“version_123”, configuration=updated_config

)

# Clone a configuration version new_version = client.pipeline_configuration_versions.clone(“version_123”)

# Validate a configuration validation = client.pipeline_configuration_versions.validate(configuration)

# Get the configuration schema schema = client.pipeline_configuration_versions.get_schema()

# Delete a configuration version client.pipeline_configuration_versions.delete(“version_123”) ```

Parameters:

client (BaseClient)

list(*, pipeline_ids=None, pipeline_configuration_version_ids=None, page=1, page_size=10, order_by=None, order_direction='asc')[source]

List pipeline configuration versions with pagination.

Parameters:
  • pipeline_ids (Optional[List[str]]) – Filter by specific pipeline IDs.

  • pipeline_configuration_version_ids (Optional[List[str]]) – Filter by specific version IDs.

  • page (int) – Page number (1-based). Defaults to 1.

  • page_size (int) – Number of items per page (1-1000). Defaults to 10.

  • order_by (Optional[str]) – Field to sort by (“createdAt”, “updatedAt”).

  • order_direction (str) – Sort direction (“asc” or “desc”). Defaults to “asc”.

Return type:

PaginatedResponse

Returns:

Paginated list of configuration versions.

retrieve(pipeline_configuration_version_id)[source]

Retrieve a specific configuration version by ID.

Parameters:

pipeline_configuration_version_id (str) – The ID of the version to retrieve.

Return type:

PipelineConfigurationVersion

Returns:

The configuration version data.

Raises:

NotFoundError – If the version doesn’t exist.

create(*, pipeline_id, configuration, **kwargs)[source]

Create a new pipeline configuration version.

Parameters:
  • pipeline_id (str) – The ID of the pipeline this version belongs to.

  • configuration (Dict[str, Any]) – The pipeline configuration object with blocks and connections.

  • **kwargs – Additional version properties.

Return type:

PipelineConfigurationVersion

Returns:

The created configuration version data.

Raises:
update(pipeline_configuration_version_id, *, configuration=None, **kwargs)[source]

Update an existing configuration version.

Parameters:
  • pipeline_configuration_version_id (str) – The ID of the version to update.

  • configuration (Optional[Dict[str, Any]]) – New configuration object.

  • **kwargs – Additional properties to update.

Return type:

PipelineConfigurationVersion

Returns:

The updated configuration version data.

Raises:
delete(pipeline_configuration_version_id)[source]

Delete a configuration version.

Parameters:

pipeline_configuration_version_id (str) – The ID of the version to delete.

Raises:

NotFoundError – If the version doesn’t exist.

Return type:

None

clone(pipeline_configuration_version_id)[source]

Clone an existing configuration version.

Creates a new version by copying an existing one. The cloned version will have a new ID, incremented version number, and draft status.

Parameters:

pipeline_configuration_version_id (str) – The ID of the version to clone.

Return type:

PipelineConfigurationVersion

Returns:

The newly created configuration version.

Raises:

NotFoundError – If the version doesn’t exist.

validate(*, configuration)[source]

Validate a pipeline configuration.

Validates the configuration against the JSON Schema and business logic rules without creating a version.

Parameters:

configuration (Dict[str, Any]) – The pipeline configuration to validate.

Return type:

Dict[str, Any]

Returns:

Validation results with valid flag, errors, warnings, and schemas.

get_schema()[source]

Get the JSON Schema for pipeline configurations.

Return type:

Optional[Dict[str, Any]]

Returns:

The JSON Schema definition for pipeline configurations.

Pipeline Executions

Pipeline Executions resource for the Moderately AI API.

class moderatelyai_sdk.resources.pipeline_executions.PipelineExecutions(client)[source]

Bases: BaseResource

Manage pipeline executions.

Pipeline executions are runtime instances that process input data through a specific pipeline configuration version. They track status, progress, and output data.

Examples

```python # List executions executions = client.pipeline_executions.list()

# Get a specific execution execution = client.pipeline_executions.retrieve(“execution_123”)

# Create a new execution execution = client.pipeline_executions.create(

pipeline_configuration_version_id=”version_123”, pipeline_input={“documents”: [“doc1.pdf”, “doc2.pdf”]}, pipeline_input_summary=”Process 2 legal documents”

)

# Update execution status/output execution = client.pipeline_executions.update(

“execution_123”, status=”completed”, pipeline_output={“results”: “…”}, pipeline_output_summary=”Successfully processed 2 documents”

)

# Cancel a running execution execution = client.pipeline_executions.cancel(“execution_123”)

# Get execution output output = client.pipeline_executions.get_output(“execution_123”) ```

Parameters:

client (BaseClient)

list(*, pipeline_ids=None, pipeline_configuration_version_ids=None, pipeline_execution_ids=None, status=None, statuses=None, page=1, page_size=10, order_by=None, order_direction='asc')[source]

List pipeline executions with pagination.

Parameters:
  • pipeline_ids (Optional[List[str]]) – Filter by pipeline IDs (requires join through config versions).

  • pipeline_configuration_version_ids (Optional[List[str]]) – Filter by config version IDs.

  • pipeline_execution_ids (Optional[List[str]]) – Filter by specific execution IDs.

  • status (Optional[str]) – Filter by single execution status.

  • statuses (Optional[List[str]]) – Filter by multiple execution statuses.

  • page (int) – Page number (1-based). Defaults to 1.

  • page_size (int) – Number of items per page (1-1000). Defaults to 10.

  • order_by (Optional[str]) – Field to sort by (“createdAt”, “updatedAt”, “startedAt”).

  • order_direction (str) – Sort direction (“asc” or “desc”). Defaults to “asc”.

Return type:

PaginatedResponse

Returns:

Paginated list of pipeline executions.

retrieve(pipeline_execution_id)[source]

Retrieve a specific pipeline execution by ID.

Parameters:

pipeline_execution_id (str) – The ID of the execution to retrieve.

Returns:

The pipeline execution data.

Raises:

NotFoundError – If the execution doesn’t exist.

create(*, pipeline_configuration_version_id, pipeline_input, pipeline_input_summary, current_step=None, total_steps=None, **kwargs)[source]

Create a new pipeline execution.

Parameters:
  • pipeline_configuration_version_id (str) – The ID of the config version to execute.

  • pipeline_input (Dict[str, Any]) – The input data for the pipeline execution.

  • pipeline_input_summary (str) – Human-readable summary of the input (max 1000 chars).

  • current_step (Optional[int]) – The current step in the pipeline execution (0-indexed).

  • total_steps (Optional[int]) – The total number of steps in the pipeline.

  • **kwargs – Additional execution properties.

Return type:

PipelineExecution

Returns:

The created pipeline execution data.

Raises:
update(pipeline_execution_id, *, pipeline_output=None, pipeline_output_summary=None, status=None, progress_data=None, current_step=None, total_steps=None, started_at=None, completed_at=None, failed_at=None, cancelled_at=None, paused_at=None, **kwargs)[source]

Update an existing pipeline execution.

Used by workers to report execution progress and results.

Parameters:
  • pipeline_execution_id (str) – The ID of the execution to update.

  • pipeline_output (Optional[Dict[str, Any]]) – The output data from the pipeline execution.

  • pipeline_output_summary (Optional[str]) – Human-readable summary of the output (max 1000 chars).

  • status (Optional[str]) – The execution status (pending, running, completed, failed, cancelled, paused).

  • progress_data (Optional[Dict[str, Any]]) – Progress tracking data for the execution.

  • current_step (Optional[int]) – The current step in the pipeline execution.

  • total_steps (Optional[int]) – The total number of steps in the pipeline.

  • started_at (Optional[str]) – When the execution started.

  • completed_at (Optional[str]) – When the execution completed.

  • failed_at (Optional[str]) – When the execution failed.

  • cancelled_at (Optional[str]) – When the execution was cancelled.

  • paused_at (Optional[str]) – When the execution was paused.

  • **kwargs – Additional properties to update.

Return type:

PipelineExecution

Returns:

The updated pipeline execution data.

Raises:
cancel(pipeline_execution_id, *, reason=None)[source]

Cancel a running or pending pipeline execution.

Only non-terminal executions can be cancelled.

Parameters:
  • pipeline_execution_id (str) – The ID of the execution to cancel.

  • reason (Optional[str]) – Optional reason for cancelling the execution (max 500 chars).

Return type:

PipelineExecution

Returns:

The updated execution with cancelled status.

Raises:
get_output(pipeline_execution_id)[source]

Get the output of a specific pipeline execution.

Handles both inline and S3-stored outputs automatically: - Inline: Small outputs stored directly in the API response - S3: Large outputs stored in S3 with automatic download via presigned URL

Parameters:

pipeline_execution_id (str) – The ID of the execution.

Return type:

Any

Returns:

The execution output data or None if not available.

Raises:

NotFoundError – If the execution doesn’t exist or has no output.

Asynchronous Resources

Files

Async files resource for the Moderately AI API.

class moderatelyai_sdk.resources_async.files.AsyncFiles(client)[source]

Bases: AsyncBaseResource

Manage files in your teams (async version).

All methods return FileAsyncModel instances which provide rich functionality for file operations like downloading, deleting, and checking file properties.

Examples

```python # List all files (returns raw data) files = await client.files.list()

# Get a file with rich functionality file = await client.files.retrieve(“file_123”)

# Upload a new file and get FileAsyncModel file = await client.files.upload(

file_path=”/path/to/document.pdf”, name=”Important Document”

)

# Use rich file operations if file.is_ready() and file.is_document():

content = await file.download() # Download to memory await file.download(path=”./local_copy.pdf”) # Download to disk

# Check file properties print(f”File: {file.name} ({file.file_size} bytes)”) print(f”Type: {file.mime_type}, Extension: {file.get_extension()}”)

# Update file metadata file = await client.files.update(

“file_123”, name=”Updated Document Name”

)

# Delete file using rich model await file.delete() ```

Parameters:

client (AsyncBaseClient)

async list(*, dataset_id=None, status=None, mime_type=None, file_hashes=None, page=1, page_size=10, order_by='created_at', order_direction='desc')[source]

List all files with pagination.

Note: Results are automatically filtered to the team specified in the client.

Parameters:
  • dataset_id (Optional[str]) – Filter files by dataset ID.

  • status (Optional[str]) – Filter files by status (e.g., “uploaded”, “processing”, “ready”, “error”).

  • mime_type (Optional[str]) – Filter files by MIME type (e.g., “text/csv”, “application/pdf”).

  • file_hashes (Optional[str]) – Filter files by SHA256 hash. Can be a single hash string.

  • page (int) – Page number (1-based). Defaults to 1.

  • page_size (int) – Number of items per page. Defaults to 10.

  • order_by (str) – Field to sort by. Defaults to “created_at”.

  • order_direction (str) – Sort direction (“asc” or “desc”). Defaults to “desc”.

Return type:

Dict[str, Any]

Returns:

Paginated list of files for the client’s team.

async retrieve(file_id)[source]

Retrieve a specific file by ID.

Parameters:

file_id (str) – The ID of the file to retrieve.

Return type:

FileAsyncModel

Returns:

The file model with rich functionality.

Raises:

NotFoundError – If the file doesn’t exist.

async upload(file, *, name=None, metadata=None, **kwargs)[source]

Upload a file using secure presigned URL workflow (async version).

Accepts files in multiple convenient formats and handles all the complexity of secure upload automatically, including SHA256 hashing, MIME type detection, and presigned URL generation.

Supported file inputs: - File paths (str or Path objects) - Raw bytes data - File-like objects with .read() method (buffers, streams)

Parameters:
  • file (Union[str, Path, bytes, Any]) – The file to upload in any supported format

  • name (Optional[str]) – Custom display name for the file. If not provided, uses the filename from path or defaults to a generic name.

  • metadata (Optional[Dict[str, Any]]) – Additional metadata dictionary to store with the file.

  • **kwargs (Any) – Additional file properties.

Return type:

FileAsyncModel

Returns:

FileAsyncModel instance representing the uploaded file with rich async operations.

Raises:
  • ValueError – If file is invalid, not found, or unsupported format.

  • APIError – If upload process fails at any step.

  • NotFoundError – If the dataset doesn’t exist.

async update(file_id, *, name=None, dataset_id=None, metadata=None, **kwargs)[source]

Update an existing file’s metadata.

Parameters:
  • file_id (str) – The ID of the file to update.

  • name (Optional[str]) – New file name.

  • dataset_id (Optional[str]) – New dataset ID to associate with.

  • metadata (Optional[Dict[str, Any]]) – Updated metadata.

  • **kwargs – Additional properties to update.

Return type:

FileAsyncModel

Returns:

The updated file model with rich functionality.

Raises:
async delete(file_id)[source]

Delete a file.

Parameters:

file_id (str) – The ID of the file to delete.

Raises:

NotFoundError – If the file doesn’t exist.

Return type:

None

async download(file_id)[source]

Download file content.

Parameters:

file_id (str) – The ID of the file to download.

Return type:

bytes

Returns:

The file content as bytes.

Raises:

NotFoundError – If the file doesn’t exist.

async get_upload_url(*, filename, file_size, mime_type=None, dataset_id=None, **kwargs)[source]

Get a presigned upload URL for large file uploads.

This is useful for uploading large files directly to cloud storage.

Parameters:
  • filename (str) – Name of the file to upload.

  • file_size (int) – Size of the file in bytes.

  • mime_type (Optional[str]) – MIME type of the file.

  • dataset_id (Optional[str]) – Optional dataset ID to associate the file with.

  • **kwargs – Additional upload parameters.

Return type:

Dict[str, Any]

Returns:

Upload URL and metadata.

Raises:

ValidationError – If the request data is invalid.

Users

Async users resource for the Moderately AI API.

class moderatelyai_sdk.resources_async.users.AsyncUsers(client)[source]

Bases: AsyncBaseResource

Manage users in your teams (async version).

Parameters:

client (AsyncBaseClient)

async list(*, page=1, page_size=10, order_by='created_at', order_direction='desc')[source]

List all users with pagination (async).

Parameters:
  • page (int)

  • page_size (int)

  • order_by (str)

  • order_direction (str)

Return type:

PaginatedResponse

async retrieve(user_id)[source]

Retrieve a specific user by ID (async).

Parameters:

user_id (str)

Return type:

UserAsyncModel

async update(user_id, *, full_name, **kwargs)[source]

Update an existing user (async).

Parameters:
  • user_id (str) – The ID of the user to update.

  • full_name (str) – New full name for the user (required).

  • **kwargs – Additional properties to update.

Return type:

UserAsyncModel

Returns:

The updated user model with rich functionality.

Raises:

Teams

Async teams resource for the Moderately AI API.

class moderatelyai_sdk.resources_async.teams.AsyncTeams(client)[source]

Bases: AsyncBaseResource

Manage teams (async version).

Parameters:

client (AsyncBaseClient)

async list(*, page=1, page_size=10, order_by='created_at', order_direction='desc')[source]

List all teams with pagination (async).

Parameters:
  • page (int)

  • page_size (int)

  • order_by (str)

  • order_direction (str)

Return type:

PaginatedResponse

async retrieve(team_id)[source]

Retrieve a specific team by ID (async).

Parameters:

team_id (str)

Return type:

Team

async create(*, name, description=None, **kwargs)[source]

Create a new team (async).

Parameters:
Return type:

Team

async update(team_id, *, name=None, description=None, **kwargs)[source]

Update an existing team (async).

Parameters:
Return type:

Team

async delete(team_id)[source]

Delete a team (async).

Parameters:

team_id (str)

Return type:

None

Agents

Async agents resource for the Moderately AI API.

class moderatelyai_sdk.resources_async.agents.AsyncAgents(client)[source]

Bases: AsyncBaseResource

Manage AI agents in your teams (async version).

Examples

```python import asyncio import moderatelyai_sdk

async def main():
async with moderatelyai_sdk.AsyncModeratelyAI() as client:

# List all agents agents = await client.agents.list()

# Get a specific agent agent = await client.agents.retrieve(“agent_123”)

# Create a new agent agent = await client.agents.create(

name=”Customer Support Agent”, description=”Handles customer inquiries”

)

# Update an agent agent = await client.agents.update(

“agent_123”, name=”Updated Agent Name”

)

# Delete an agent await client.agents.delete(“agent_123”)

asyncio.run(main()) ```

Parameters:

client (AsyncBaseClient)

async list(*, page=1, page_size=10, order_by='created_at', order_direction='desc')[source]

List all agents with pagination (async).

Note: Results are automatically filtered to the team specified in the client.

Parameters:
  • page (int) – Page number (1-based). Defaults to 1.

  • page_size (int) – Number of items per page. Defaults to 10.

  • order_by (str) – Field to sort by. Defaults to “created_at”.

  • order_direction (str) – Sort direction (“asc” or “desc”). Defaults to “desc”.

Return type:

PaginatedResponse

Returns:

Paginated list of agents for the client’s team.

async retrieve(agent_id)[source]

Retrieve a specific agent by ID (async).

Parameters:

agent_id (str) – The ID of the agent to retrieve.

Return type:

Agent

Returns:

The agent data.

Raises:

NotFoundError – If the agent doesn’t exist.

async create(*, name, description=None, **kwargs)[source]

Create a new agent (async).

Note: The agent will be created in the team specified in the client.

Parameters:
  • name (str) – The agent’s name.

  • description (Optional[str]) – The agent’s description.

  • **kwargs – Additional agent properties.

Return type:

Agent

Returns:

The created agent data.

Raises:

ValidationError – If the request data is invalid.

async update(agent_id, *, name=None, description=None, **kwargs)[source]

Update an existing agent (async).

Parameters:
  • agent_id (str) – The ID of the agent to update.

  • name (Optional[str]) – New agent name.

  • description (Optional[str]) – New agent description.

  • **kwargs – Additional properties to update.

Return type:

Agent

Returns:

The updated agent data.

Raises:
async delete(agent_id)[source]

Delete an agent (async).

Parameters:

agent_id (str) – The ID of the agent to delete.

Raises:

NotFoundError – If the agent doesn’t exist.

Return type:

None

Agent Executions

Async agent executions resource for the Moderately AI API.

class moderatelyai_sdk.resources_async.agent_executions.AsyncAgentExecutions(client)[source]

Bases: AsyncBaseResource

Manage agent executions in your teams (async version).

Parameters:

client (AsyncBaseClient)

async list(*, agent_id=None, status=None, page=1, page_size=10, order_by='created_at', order_direction='desc')[source]

List all agent executions with pagination (async).

Parameters:
Return type:

PaginatedResponse

async retrieve(execution_id)[source]

Retrieve a specific agent execution by ID (async).

Parameters:

execution_id (str)

Return type:

AgentExecution

async create(*, agent_id, input_data=None, **kwargs)[source]

Create a new agent execution (async).

Parameters:
Return type:

AgentExecution

async cancel(execution_id)[source]

Cancel a running agent execution (async).

Parameters:

execution_id (str)

Return type:

AgentExecution

async delete(execution_id)[source]

Delete an agent execution (async).

Parameters:

execution_id (str)

Return type:

None

Datasets

Async datasets resource for the Moderately AI API.

class moderatelyai_sdk.resources_async.datasets.AsyncDatasets(client)[source]

Bases: AsyncBaseResource

Manage datasets in your teams (async version).

Examples

```python import asyncio import moderatelyai_sdk

async def main():
async with moderatelyai_sdk.AsyncModeratelyAI() as client:

# List all datasets (still returns raw data) datasets = await client.datasets.list()

# Get a dataset with rich functionality dataset = await client.datasets.retrieve(“dataset_123”)

# Create a new dataset dataset = await client.datasets.create(

name=”Customer Data”, description=”Customer interaction dataset”

)

# Now use rich methods on the dataset object:

# Upload data to the dataset version = await dataset.upload_data(“/path/to/sales_data.csv”) print(f”Uploaded version {version.version_no} with {version.row_count} rows”)

# Download current data data_bytes = await dataset.download_data() await dataset.download_data(path=”/save/local_copy.csv”)

# Work with specific versions versions = await dataset.list_data_versions() old_data = await dataset.download_data(version_id=”version_123”)

# Schema management # Simple schema creation schema = await dataset.create_schema([

{“name”: “user_id”, “type”: “int”, “required”: True}, {“name”: “email”, “type”: “string”}, {“name”: “signup_date”, “type”: “datetime”},

])

# Auto-infer schema from sample data schema = await dataset.create_schema_from_sample(“sample.csv”)

asyncio.run(main()) ```

Parameters:

client (AsyncBaseClient)

async list(*, dataset_ids=None, name_like=None, name=None, page=1, page_size=10, order_by='createdAt', order_direction='desc')[source]

List all datasets with pagination (async).

Note: Results are automatically filtered to the team specified in the client.

Parameters:
  • dataset_ids (Optional[List[str]]) – Filter by specific dataset IDs.

  • name_like (Optional[str]) – Filter by datasets with names containing this text.

  • name (Optional[str]) – Filter by exact dataset name.

  • page (int) – Page number (1-based). Defaults to 1.

  • page_size (int) – Number of items per page. Defaults to 10.

  • order_by (str) – Field to sort by (“createdAt”, “updatedAt”, “name”). Defaults to “createdAt”.

  • order_direction (str) – Sort direction (“asc” or “desc”). Defaults to “desc”.

Return type:

PaginatedResponse

Returns:

Paginated list of datasets for the client’s team.

async retrieve(dataset_id)[source]

Retrieve a specific dataset by ID (async).

Parameters:

dataset_id (str) – The ID of the dataset to retrieve.

Return type:

DatasetAsyncModel

Returns:

The dataset model with rich functionality.

Raises:

NotFoundError – If the dataset doesn’t exist.

async create(*, name, description=None, **kwargs)[source]

Create a new dataset (async).

Note: The dataset will be created in the team specified in the client.

Parameters:
  • name (str) – The dataset’s name.

  • description (Optional[str]) – The dataset’s description.

  • **kwargs – Additional dataset properties.

Return type:

DatasetAsyncModel

Returns:

The created dataset model with rich functionality.

Raises:

ValidationError – If the request data is invalid.

async update(dataset_id, *, name=None, description=None, should_process=None, **kwargs)[source]

Update an existing dataset (async).

Parameters:
  • dataset_id (str) – The ID of the dataset to update.

  • name (Optional[str]) – New dataset name.

  • description (Optional[str]) – New dataset description.

  • should_process (Optional[bool]) – Whether to trigger dataset processing workflow.

  • **kwargs – Additional properties to update.

Return type:

DatasetAsyncModel

Returns:

The updated dataset model.

Raises:
async delete(dataset_id)[source]

Delete a dataset (async).

Parameters:

dataset_id (str) – The ID of the dataset to delete.

Raises:

NotFoundError – If the dataset doesn’t exist.

Return type:

None

Pipelines

Async pipelines resource for the Moderately AI API.

class moderatelyai_sdk.resources_async.pipelines.AsyncPipelines(client)[source]

Bases: AsyncBaseResource

Manage pipelines in your teams (async version).

Pipelines are basic metadata containers with name, description, and team ownership. The actual pipeline logic is stored in PipelineConfigurationVersions. Execution instances are managed through PipelineExecutions.

Examples

```python # List all pipelines pipelines = await client.pipelines.list()

# Get a specific pipeline pipeline = await client.pipelines.retrieve(“pipeline_123”)

# Create a new pipeline pipeline = await client.pipelines.create(

name=”Document Analysis Pipeline”, description=”Processes legal documents”

)

# Update a pipeline pipeline = await client.pipelines.update(

“pipeline_123”, name=”Updated Pipeline Name”

)

# Delete a pipeline await client.pipelines.delete(“pipeline_123”) ```

Parameters:

client (AsyncBaseClient)

async list(*, pipeline_ids=None, name_like=None, page=1, page_size=10, order_by=None, order_direction='asc')[source]

List all pipelines with pagination (async).

Note: Results are automatically filtered to the team specified in the client.

Parameters:
  • pipeline_ids (Optional[List[str]]) – Filter by specific pipeline IDs.

  • name_like (Optional[str]) – Filter pipelines by name (case-insensitive partial match).

  • page (int) – Page number (1-based). Defaults to 1.

  • page_size (int) – Number of items per page (1-1000). Defaults to 10.

  • order_by (Optional[str]) – Field to sort by (“name”, “createdAt”, “updatedAt”).

  • order_direction (str) – Sort direction (“asc” or “desc”). Defaults to “asc”.

Return type:

PaginatedResponse

Returns:

Paginated list of pipelines for the client’s team.

async retrieve(pipeline_id)[source]

Retrieve a specific pipeline by ID (async).

Parameters:

pipeline_id (str) – The ID of the pipeline to retrieve.

Return type:

PipelineAsyncModel

Returns:

The pipeline model instance.

Raises:

NotFoundError – If the pipeline doesn’t exist.

async create(*, name, description=None, **kwargs)[source]

Create a new pipeline (async).

Note: The pipeline will be created in the team specified in the client.

Parameters:
  • name (str) – The pipeline’s name (1-255 characters). Must be unique within the team.

  • description (Optional[str]) – The pipeline’s description (max 1000 characters).

  • **kwargs – Additional pipeline properties.

Return type:

PipelineAsyncModel

Returns:

The created pipeline model instance.

Raises:
async update(pipeline_id, *, name=None, description=None, **kwargs)[source]

Update an existing pipeline (async).

Parameters:
  • pipeline_id (str) – The ID of the pipeline to update.

  • name (Optional[str]) – New pipeline name (1-255 characters). Must be unique within the team.

  • description (Optional[str]) – New pipeline description (max 1000 characters).

  • **kwargs – Additional properties to update.

Return type:

PipelineAsyncModel

Returns:

The updated pipeline model instance.

Raises:
async delete(pipeline_id)[source]

Delete a pipeline (async).

Parameters:

pipeline_id (str) – The ID of the pipeline to delete.

Raises:

NotFoundError – If the pipeline doesn’t exist.

Return type:

None

Pipeline Configuration Versions

Async Pipeline Configuration Versions resource for the Moderately AI API.

class moderatelyai_sdk.resources_async.pipeline_configuration_versions.AsyncPipelineConfigurationVersions(client)[source]

Bases: AsyncBaseResource

Manage pipeline configuration versions (async version).

Configuration versions contain the actual pipeline logic - the blocks, connections, and workflow definition. Each pipeline can have multiple configuration versions to track changes over time.

Examples

```python # List configuration versions versions = await client.pipeline_configuration_versions.list()

# Get a specific version version = await client.pipeline_configuration_versions.retrieve(“version_123”)

# Create a new configuration version version = await client.pipeline_configuration_versions.create(

pipeline_id=”pipeline_123”, configuration={

“id”: “my-pipeline”, “name”: “Document Processor”, “version”: “1.0.0”, “blocks”: {

“input”: {

“id”: “input”, “type”: “input”, “config”: {“json_schema”: {“type”: “object”}}

}

}

}

)

# Update a configuration version version = await client.pipeline_configuration_versions.update(

“version_123”, configuration=updated_config

)

# Clone a configuration version new_version = await client.pipeline_configuration_versions.clone(“version_123”)

# Validate a configuration validation = await client.pipeline_configuration_versions.validate(configuration)

# Get the configuration schema schema = await client.pipeline_configuration_versions.get_schema()

# Delete a configuration version await client.pipeline_configuration_versions.delete(“version_123”) ```

Parameters:

client (AsyncBaseClient)

async list(*, pipeline_ids=None, pipeline_configuration_version_ids=None, page=1, page_size=10, order_by=None, order_direction='asc')[source]

List pipeline configuration versions with pagination (async).

Parameters:
  • pipeline_ids (Optional[List[str]]) – Filter by specific pipeline IDs.

  • pipeline_configuration_version_ids (Optional[List[str]]) – Filter by specific version IDs.

  • page (int) – Page number (1-based). Defaults to 1.

  • page_size (int) – Number of items per page (1-1000). Defaults to 10.

  • order_by (Optional[str]) – Field to sort by (“createdAt”, “updatedAt”).

  • order_direction (str) – Sort direction (“asc” or “desc”). Defaults to “asc”.

Return type:

PaginatedResponse

Returns:

Paginated list of configuration versions.

async retrieve(pipeline_configuration_version_id)[source]

Retrieve a specific configuration version by ID (async).

Parameters:

pipeline_configuration_version_id (str) – The ID of the version to retrieve.

Return type:

PipelineConfigurationVersionAsyncModel

Returns:

The configuration version data.

Raises:

NotFoundError – If the version doesn’t exist.

async create(*, pipeline_id, configuration, **kwargs)[source]

Create a new pipeline configuration version (async).

Parameters:
  • pipeline_id (str) – The ID of the pipeline this version belongs to.

  • configuration (Dict[str, Any]) – The pipeline configuration object with blocks and connections.

  • **kwargs – Additional version properties.

Return type:

PipelineConfigurationVersionAsyncModel

Returns:

The created configuration version data.

Raises:
async update(pipeline_configuration_version_id, *, configuration=None, **kwargs)[source]

Update an existing configuration version (async).

Parameters:
  • pipeline_configuration_version_id (str) – The ID of the version to update.

  • configuration (Optional[Dict[str, Any]]) – New configuration object.

  • **kwargs – Additional properties to update.

Return type:

PipelineConfigurationVersionAsyncModel

Returns:

The updated configuration version data.

Raises:
async delete(pipeline_configuration_version_id)[source]

Delete a configuration version (async).

Parameters:

pipeline_configuration_version_id (str) – The ID of the version to delete.

Raises:

NotFoundError – If the version doesn’t exist.

Return type:

None

async clone(pipeline_configuration_version_id)[source]

Clone an existing configuration version (async).

Creates a new version by copying an existing one. The cloned version will have a new ID, incremented version number, and draft status.

Parameters:

pipeline_configuration_version_id (str) – The ID of the version to clone.

Return type:

PipelineConfigurationVersionAsyncModel

Returns:

The newly created configuration version.

Raises:

NotFoundError – If the version doesn’t exist.

async validate(*, configuration)[source]

Validate a pipeline configuration (async).

Validates the configuration against the JSON Schema and business logic rules without creating a version.

Parameters:

configuration (Dict[str, Any]) – The pipeline configuration to validate.

Return type:

Dict[str, Any]

Returns:

Validation results with valid flag, errors, warnings, and schemas.

async get_schema()[source]

Get the JSON Schema for pipeline configurations (async).

Return type:

Optional[Dict[str, Any]]

Returns:

The JSON Schema definition for pipeline configurations.

Pipeline Executions

Async Pipeline Executions resource for the Moderately AI API.

class moderatelyai_sdk.resources_async.pipeline_executions.AsyncPipelineExecutions(client)[source]

Bases: AsyncBaseResource

Manage pipeline executions (async version).

Pipeline executions are runtime instances that process input data through a specific pipeline configuration version. They track status, progress, and output data.

Examples

```python # List executions executions = await client.pipeline_executions.list()

# Get a specific execution execution = await client.pipeline_executions.retrieve(“execution_123”)

# Create a new execution execution = await client.pipeline_executions.create(

pipeline_configuration_version_id=”version_123”, pipeline_input={“documents”: [“doc1.pdf”, “doc2.pdf”]}, pipeline_input_summary=”Process 2 legal documents”

)

# Update execution status/output execution = await client.pipeline_executions.update(

“execution_123”, status=”completed”, pipeline_output={“results”: “…”}, pipeline_output_summary=”Successfully processed 2 documents”

)

# Cancel a running execution execution = await client.pipeline_executions.cancel(“execution_123”)

# Get execution output output = await client.pipeline_executions.get_output(“execution_123”) ```

Parameters:

client (AsyncBaseClient)

async list(*, pipeline_ids=None, pipeline_configuration_version_ids=None, pipeline_execution_ids=None, status=None, statuses=None, page=1, page_size=10, order_by=None, order_direction='asc')[source]

List pipeline executions with pagination (async).

Parameters:
  • pipeline_ids (Optional[List[str]]) – Filter by pipeline IDs (requires join through config versions).

  • pipeline_configuration_version_ids (Optional[List[str]]) – Filter by config version IDs.

  • pipeline_execution_ids (Optional[List[str]]) – Filter by specific execution IDs.

  • status (Optional[str]) – Filter by single execution status.

  • statuses (Optional[List[str]]) – Filter by multiple execution statuses.

  • page (int) – Page number (1-based). Defaults to 1.

  • page_size (int) – Number of items per page (1-1000). Defaults to 10.

  • order_by (Optional[str]) – Field to sort by (“createdAt”, “updatedAt”, “startedAt”).

  • order_direction (str) – Sort direction (“asc” or “desc”). Defaults to “asc”.

Return type:

PaginatedResponse

Returns:

Paginated list of pipeline executions.

async retrieve(pipeline_execution_id)[source]

Retrieve a specific pipeline execution by ID (async).

Parameters:

pipeline_execution_id (str) – The ID of the execution to retrieve.

Return type:

PipelineExecutionAsyncModel

Returns:

The pipeline execution data.

Raises:

NotFoundError – If the execution doesn’t exist.

async create(*, pipeline_configuration_version_id, pipeline_input, pipeline_input_summary, current_step=None, total_steps=None, **kwargs)[source]

Create a new pipeline execution (async).

Parameters:
  • pipeline_configuration_version_id (str) – The ID of the config version to execute.

  • pipeline_input (Dict[str, Any]) – The input data for the pipeline execution.

  • pipeline_input_summary (str) – Human-readable summary of the input (max 1000 chars).

  • current_step (Optional[int]) – The current step in the pipeline execution (0-indexed).

  • total_steps (Optional[int]) – The total number of steps in the pipeline.

  • **kwargs – Additional execution properties.

Return type:

PipelineExecutionAsyncModel

Returns:

The created pipeline execution data.

Raises:
async update(pipeline_execution_id, *, pipeline_output=None, pipeline_output_summary=None, status=None, progress_data=None, current_step=None, total_steps=None, started_at=None, completed_at=None, failed_at=None, cancelled_at=None, paused_at=None, **kwargs)[source]

Update an existing pipeline execution (async).

Used by workers to report execution progress and results.

Parameters:
  • pipeline_execution_id (str) – The ID of the execution to update.

  • pipeline_output (Optional[Dict[str, Any]]) – The output data from the pipeline execution.

  • pipeline_output_summary (Optional[str]) – Human-readable summary of the output (max 1000 chars).

  • status (Optional[str]) – The execution status (pending, running, completed, failed, cancelled, paused).

  • progress_data (Optional[Dict[str, Any]]) – Progress tracking data for the execution.

  • current_step (Optional[int]) – The current step in the pipeline execution.

  • total_steps (Optional[int]) – The total number of steps in the pipeline.

  • started_at (Optional[str]) – When the execution started.

  • completed_at (Optional[str]) – When the execution completed.

  • failed_at (Optional[str]) – When the execution failed.

  • cancelled_at (Optional[str]) – When the execution was cancelled.

  • paused_at (Optional[str]) – When the execution was paused.

  • **kwargs – Additional properties to update.

Return type:

PipelineExecutionAsyncModel

Returns:

The updated pipeline execution data.

Raises:
async cancel(pipeline_execution_id, *, reason=None)[source]

Cancel a running or pending pipeline execution (async).

Only non-terminal executions can be cancelled.

Parameters:
  • pipeline_execution_id (str) – The ID of the execution to cancel.

  • reason (Optional[str]) – Optional reason for cancelling the execution (max 500 chars).

Return type:

PipelineExecutionAsyncModel

Returns:

The updated execution with cancelled status.

Raises:
async get_output(pipeline_execution_id)[source]

Get the output of a specific pipeline execution (async).

Handles both inline and S3-stored outputs automatically: - Inline: Small outputs stored directly in the API response - S3: Large outputs stored in S3 with automatic download via presigned URL

Parameters:

pipeline_execution_id (str) – The ID of the execution.

Return type:

Any

Returns:

The execution output data or None if not available.

Raises:

NotFoundError – If the execution doesn’t exist or has no output.