DZapSDK is the main orchestrator in @dzapio/ai.
@dzapio/sdk: direct chain primitives.
@dzapio/ai (DZapSDK): agent runtime, tool orchestration, sessions, scheduler hooks.
Install
Constructor
import { DZapSDK } from "@dzapio/ai";
const sdk = new DZapSDK({
baseUrl: "https://nlp-ai-439689868940.europe-north1.run.app", // optional
systemPrompt: "You are a DeFi assistant.", // optional
// systemPromptPath: "./prompt.txt", // optional
});
Initialize runtime
await sdk.initialize({
startupPassword: process.env.DZAP_STARTUP_PASSWORD,
syncProviders: false,
initializeRetrieval: true,
});
Ask (main entry point)
const result = await sdk.ask({
userQuery: "Show my balances and current ETH price",
metadata: {
accountInfo: [
{ blockchain: "evm", chain: "1", user_account: "0xabc..." },
],
},
transactionConfirmationMode: "on",
onStep: (step) => {
console.log(step.toolName ?? step.type);
},
});
console.log(result.sessionId);
console.log(result.finalText);
console.log(result.chainId);
Return payload includes:
sessionId
finalText
chainId
- optional
balanceData
steps[]
const output = await sdk.executeTool("PriceTool", {
tokenAddresses: "0xA0b86991c6218b36c1d19d4a2e9eb0ce3606eB48",
chainId: 1,
});
console.log(output);
Direct calls are useful for deterministic backend flows.
Session and schedule APIs
const tools = sdk.listTools();
const history = sdk.getChatHistory(result.sessionId);
const sessionSnapshot = sdk.getSessionHistory(result.sessionId);
const schedules = sdk.getSchedulesByUserId("user-123");
await sdk.runSchedulerOnce();
await sdk.startSchedulerLoop(60000);
Interactive confirmations (when needed)
await sdk.confirmZap("session-id", "yes");
await sdk.confirmChainChange("session-id", "approve");
These resolve pending interactive flows created by execution-sensitive tools.
See also
Last modified on May 26, 2026