Skip to main content
The @invoke/sdk package is the primary way to route agent tool calls through the Invoke execution runtime from TypeScript. Install it once, instantiate a client, and replace direct API calls in your agent loop with invoke.call().

Installation

npm install @invoke/sdk

Client setup

import { Invoke } from "@invoke/sdk"

const invoke = new Invoke({
  apiKey: process.env.INVOKE_API_KEY!,
})
The client reads INVOKE_API_KEY from the environment automatically. Pass the value explicitly to ensure TypeScript can verify the key is present at startup.

invoke.call()

The primary method. Routes a tool call through Invoke’s execution controls.
const result = await invoke.call({
  tool: "stripe.charge_customer",        // registered tool name
  params: { customer_id: "cust_123", amount: 2400 },
  agentId: "billing-agent",              // registered agent identity
  idempotencyKey: "charge:cust_123:2400" // deduplication handle
})

Parameters

ParameterTypeRequiredDescription
toolstringYesThe registered tool name
paramsobjectYesTool parameters
agentIdstringYesThe agent identity bound to a registered policy
idempotencyKeystringRecommendedDeduplication key for write operations
workflowIdstringNoGroups related calls into a single workflow run

Response

{
  status: "executed" | "blocked" | "pending_approval" | "reconciled" | "replan_required",
  final_outcome?: "already_succeeded" | "not_executed",
  idempotency_key?: string,
  retry?: "blocked" | "allowed",
  trace: TraceStep[]
}
StatusMeaning
executedTool ran, side effect landed
blockedFailed a policy, scope, or identity check
pending_approvalStaged for human review
reconciledPrior attempt succeeded, duplicate blocked
replan_requiredLive state drifted, agent should replan

Error handling

try {
  const result = await invoke.call({ ... })
} catch (err) {
  if (err.code === "SCOPE_VIOLATION") {
    // tool not allowed for this agent
  }
  if (err.code === "AUTH_FAILED") {
    // invalid or missing API key
  }
}

Next steps