Skip to main content
Version: 2.0

aixplain.v2.tool

Tool resource module for managing tools and their integrations.

ToolResult Objects

@dataclass_json

@dataclass(repr=False)
class ToolResult(Result)

[view_source]

Result for a tool.

Tool Objects

@dataclass_json

@dataclass(repr=False)
class Tool(Model, DeleteResourceMixin[BaseDeleteParams, DeleteResult],
ActionMixin)

[view_source]

Resource for tools.

This class represents a tool resource that matches the backend structure. Tools can be integrations, utilities, or other specialized resources. Inherits from Model to reuse shared attributes and functionality.

DEFAULT_INTEGRATION_ID

Script integration

__post_init__

def __post_init__() -> None

[view_source]

Initialize tool after dataclass creation.

Sets up default integration for utility tools if no integration is provided. Validates integration type if provided.

list_actions

def list_actions() -> List[Action]

[view_source]

List available actions for the tool.

Overrides parent method to add fallback to base integration.

Returns:

List of Action objects available for this tool. Falls back to integration's list_actions() if tool's own method fails.

list_inputs

def list_inputs(*actions: str) -> List["Action"]

[view_source]

List available inputs for specified actions.

Overrides parent method to add fallback to base integration.

Arguments:

  • *actions - Variable number of action names to get inputs for.

Returns:

List of Action objects with their input specifications. Falls back to integration's list_inputs() if tool's own method fails.

validate_allowed_actions

def validate_allowed_actions() -> None

[view_source]

Validate that all allowed actions are available for this tool.

Checks that:

  • Integration is available
  • All actions in allowed_actions list exist in the integration

Raises:

  • AssertionError - If validation fails.

get_parameters

def get_parameters() -> List[dict]

[view_source]

Get parameters for the tool in the format expected by agent saving.

This method includes both static backend values and dynamically set values from the ActionInputsProxy instances, ensuring agents get the current configured action inputs.

run

def run(*args: Any, **kwargs: Unpack[ModelRunParams]) -> ToolResult

[view_source]

Run the tool.