Installation
Client Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | Optional[str] | None | API key. Falls back to DATAGEN_API_KEY env var |
base_url | str | "https://api.datagen.dev" | DataGen API base URL |
timeout | int | 30 | Request timeout in seconds |
retries | int | 0 | Number of retry attempts |
backoff_seconds | float | 0.5 | Initial backoff time for retries |
Tool Execution
execute_tool
Execute an MCP tool by its alias name.
| Parameter | Type | Required | Description |
|---|---|---|---|
tool_alias_name | str | Yes | Tool alias (e.g., "mcp_Gmail_gmail_send_email") |
parameters | Dict[str, Any] | No | Tool-specific parameters |
DatagenAuthError, DatagenToolError, DatagenHttpError
Custom Tool Deployment
deploy_custom_tool
Deploy a Python workflow as an API endpoint.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name | str | Yes | — | API name for the tool |
code | str | Yes | — | Python code to deploy |
description | str | No | None | Tool description |
input_schema | Dict | No | None | OpenAPI/JSON Schema for inputs |
output_vars | List[str] | No | None | Output variable names |
expected_tools | List[str] | No | None | Required MCP tools |
additional_imports | List[str] | No | None | Python packages |
deployment_type | str | No | "private" | "private" or "public" |
default_input_vars | Dict | No | None | Default input values |
mcp_server_names | List[str] | No | None | MCP server names |
required_secrets | List[str] | No | None | Required secret names |
Dict with deployment_uuid and deployment details.
Raises: DatagenDeploymentError
update_custom_tool
Update an existing custom tool. Only provided fields are updated.
| Parameter | Type | Required | Description |
|---|---|---|---|
deployment_uuid | str | Yes | UUID of the tool to update |
name | str | No | Updated name |
description | str | No | Updated description |
code | str | No | Updated Python code |
input_schema | Dict | No | Updated input schema |
output_vars | List[str] | No | Updated output variables |
default_input_vars | Dict | No | Updated default inputs |
additional_imports | List[str] | No | Updated imports |
expected_tools | List[str] | No | Updated required tools |
required_secrets | List[str] | No | Updated required secrets |
Dict with updated deployment details.
Raises: DatagenDeploymentError
get_custom_tool
Get details of a custom tool.
list_custom_tools
List all custom tools.
| Parameter | Type | Default | Description |
|---|---|---|---|
sort_by | str | "created_at" | Sort field |
order_by | str | "desc" | "asc" or "desc" |
skip | int | 0 | Pagination offset |
limit | int | 100 | Max results |
Custom Tool Execution
run_custom_tool
Run a custom tool synchronously (blocks until complete).
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
deployment_uuid | str | Yes | — | Tool UUID |
input_vars | Dict | No | None | Input variables |
execution_timeout | int | No | 120 | Max execution time in seconds |
Dict with run_uuid, status, and output_vars.
Raises: DatagenDeploymentError
run_custom_tool_async
Run a custom tool asynchronously (returns immediately).
run_custom_tool.
Returns: Dict with run_uuid and status: "pending".
Raises: DatagenDeploymentError
check_run_status
Check the status of a custom tool run.
Dict with run_uuid and status ("pending", "running", "completed", or "failed").
get_run
Get full details of a custom tool run including output.
Dict with complete run details including output_vars.
wait_for_run
Poll until an async run completes or fails.
| Parameter | Type | Default | Description |
|---|---|---|---|
run_uuid | str | — | Run UUID |
timeout | int | 300 | Max wait time in seconds |
poll_interval | float | 2.0 | Seconds between status checks |
output_vars.
Raises: DatagenDeploymentError on failure or timeout.
Secret Management
list_secrets
List all secrets (values are never returned).
name, masked_value, provider, etc.).
set_secret
Create or update a secret.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name | str | Yes | — | Secret name (alphanumeric, underscores, hyphens) |
value | str | Yes | — | Secret value |
display_name | str | No | None | Human-readable name |
description | str | No | None | Description |
category | str | No | "api_key" | Secret category |
force | bool | No | False | If True, updates existing secret |
DatagenSecretError if secret exists and force=False.
Error Types
All exceptions inherit fromDatagenError.
| Exception | Description |
|---|---|
DatagenError | Base exception class |
DatagenAuthError | Authentication failed (401/403) or missing API key |
DatagenToolError | Tool execution failed |
DatagenHttpError | HTTP-level errors (4xx/5xx) |
DatagenDeploymentError | Custom tool deployment or run failed |
DatagenSecretError | Secret management errors |