Skip to main content

Documentation Index

Fetch the complete documentation index at: https://datagen.dev/llms.txt

Use this file to discover all available pages before exploring further.

Installation

npm install @datagen-dev/typescript-sdk
Requires Node.js 18+ and TypeScript 5.0+.

Client Configuration

import { DatagenClient } from '@datagen-dev/typescript-sdk';

const client = new DatagenClient({
    apiKey: undefined,       // Default: reads from DATAGEN_API_KEY env var
    baseUrl: "https://api.datagen.dev",
    timeout: 30000,          // Request timeout in ms
    retries: 0,              // Retry attempts for failed requests
    backoffSeconds: 0.5      // Initial backoff for retries
});
ParameterTypeDefaultDescription
apiKeystring?undefinedAPI key. Falls back to DATAGEN_API_KEY env var
baseUrlstring"https://api.datagen.dev"DataGen API base URL
timeoutnumber30000Request timeout in milliseconds
retriesnumber0Number of retry attempts
backoffSecondsnumber0.5Initial backoff time for retries

Tool Execution

executeTool

Execute an MCP tool by its alias name.
const result = await client.executeTool(
    toolAliasName: string,
    parameters?: Record<string, any>
): Promise<any>
ParameterTypeRequiredDescription
toolAliasNamestringYesTool alias (e.g., "mcp_Gmail_gmail_send_email")
parametersRecord<string, any>NoTool-specific parameters
Returns: Tool execution result. Throws: DatagenAuthError, DatagenToolError, DatagenHttpError

Custom Tool Deployment

deployCustomTool

Deploy a Python workflow as an API endpoint.
const result = await client.deployCustomTool({
    name: string,
    code: string,
    description?: string,
    inputSchema?: Record<string, any>,
    outputVars?: string[],
    expectedTools?: string[],
    additionalImports?: string[],
    deploymentType?: "private" | "public",
    defaultInputVars?: Record<string, any>,
    mcpServerNames?: string[],
    requiredSecrets?: string[],
}): Promise<DeploymentResult>
ParameterTypeRequiredDefaultDescription
namestringYesAPI name for the tool
codestringYesPython code to deploy
descriptionstringNoTool description
inputSchemaobjectNoOpenAPI/JSON Schema for inputs
outputVarsstring[]NoOutput variable names
expectedToolsstring[]NoRequired MCP tools
additionalImportsstring[]NoPython packages
deploymentTypestringNo"private""private" or "public"
defaultInputVarsobjectNoDefault input values
mcpServerNamesstring[]NoMCP server names
requiredSecretsstring[]NoRequired secret names
Returns: Object with deploymentUuid and deployment details. Throws: DatagenDeploymentError

updateCustomTool

Update an existing custom tool. Only provided fields are updated.
const result = await client.updateCustomTool(
    deploymentUuid: string,
    updates: {
        name?: string,
        description?: string,
        code?: string,
        inputSchema?: Record<string, any>,
        outputVars?: string[],
        defaultInputVars?: Record<string, any>,
        additionalImports?: string[],
        expectedTools?: string[],
        requiredSecrets?: string[],
    }
): Promise<DeploymentResult>

getCustomTool

const result = await client.getCustomTool(deploymentUuid: string): Promise<DeploymentDetails>

listCustomTools

const result = await client.listCustomTools({
    sortBy?: string,    // Default: "created_at"
    orderBy?: string,   // Default: "desc"
    skip?: number,      // Default: 0
    limit?: number,     // Default: 100
}): Promise<DeploymentDetails[]>

Custom Tool Execution

runCustomTool

Run synchronously (blocks until complete).
const result = await client.runCustomTool(
    deploymentUuid: string,
    inputVars?: Record<string, any>,
    executionTimeout?: number    // Default: 120
): Promise<RunResult>

runCustomToolAsync

Run asynchronously (returns immediately).
const result = await client.runCustomToolAsync(
    deploymentUuid: string,
    inputVars?: Record<string, any>,
    executionTimeout?: number    // Default: 120
): Promise<{ runUuid: string, status: "pending" }>

checkRunStatus

const result = await client.checkRunStatus(runUuid: string): Promise<RunStatus>

getRun

const result = await client.getRun(runUuid: string): Promise<RunResult>

waitForRun

Poll until an async run completes.
const result = await client.waitForRun(
    runUuid: string,
    timeout?: number,        // Default: 300
    pollInterval?: number    // Default: 2.0
): Promise<RunResult>

Secret Management

listSecrets

const result = await client.listSecrets(): Promise<SecretMetadata[]>

setSecret

const result = await client.setSecret({
    name: string,
    value: string,
    displayName?: string,
    description?: string,
    category?: string,     // Default: "api_key"
    force?: boolean,       // Default: false
}): Promise<SecretMetadata>

Error Types

import {
    DatagenClient,
    DatagenError,
    DatagenAuthError,
    DatagenToolError,
    DatagenHttpError,
    DatagenDeploymentError,
    DatagenSecretError,
} from '@datagen-dev/typescript-sdk';
ExceptionDescription
DatagenErrorBase exception class
DatagenAuthErrorAuthentication failed (401/403)
DatagenToolErrorTool execution failed
DatagenHttpErrorHTTP-level errors
DatagenDeploymentErrorDeployment or run failed
DatagenSecretErrorSecret management errors