Documentation Index
Fetch the complete documentation index at: https://docs.dzap.io/llms.txt
Use this file to discover all available pages before exploring further.
DZapSDK is the AI SDK — a TypeScript class that runs ZapBot inside your app. Distinct from @dzapio/sdk (which is the on-chain SDK).
Two SDKs, two purposes:
@dzapio/sdk (DZapClient) — chain operations: quote, swap, sign, send.
dzapai (DZapSDK) — AI runtime: ask, listTools, executeTool.
You typically use both. The AI SDK calls into the chain SDK under the hood.
Install
Initialize
import { DZapSDK } from 'dzapai';
const sdk = new DZapSDK();
await sdk.initialize({
initializeRetrieval: true, // load RAG/embedding tools
syncProviders: false, // skip provider sync (faster cold start)
});
Initialization is one-time per process. The SDK is safe to use across requests.
ask
The main entry point — runs one agent turn.
const result = await sdk.ask({
userQuery: "Show my balances on Arbitrum",
metadata: {
accountInfo: [
{ blockchain: 'evm', chain: '42161', user_account: '0xUser' },
],
},
});
console.log(result.finalText);
console.log(result.toolCalls); // structured trace
Streaming with onStep
const result = await sdk.ask({
userQuery: '...',
metadata: { ... },
onStep: (event) => {
if (event.type === 'tool_call') console.log('calling', event.toolName);
if (event.type === 'text_delta') process.stdout.write(event.text);
},
});
For when you want to call a tool directly without going through the agent:
const tools = sdk.listTools();
console.log(tools.map(t => t.name));
const priceTool = sdk.getTool('PriceTool');
const result = await priceTool.execute({
tokenAddresses: '0xA0b86991c6218b36c1d19d4a2e9eb0ce3606eB48',
chainId: 1,
});
Direct tool calls are faster and cheaper (no LLM round-trip) but require you to know exactly which tool you want.
Custom system prompt
const sdk = new DZapSDK({
systemPrompt: `
You are an assistant for DefiDegens, a DeFi research app.
Always check user balances before suggesting trades.
Never execute swaps over $1000 without explicit confirmation.
`,
});
The system prompt nudges tool selection and adds guardrails.
Multi-tenant
Pass sessionId to scope memory per user:
await sdk.ask({ userQuery: '...', sessionId: 'user-42', metadata: { ... } });
Memory keyed by sessionId lets multi-user apps avoid cross-talk.
See also