@zap-tools/sdk
v0.0.2
Published
ZapTools SDK — createZapServer (server) and useZapChat hook (client via /client subpath)
Downloads
195
Maintainers
Readme
@zap-tools/sdk
Server & client SDK for ZapTools — create a streaming AI chat backend with tool calling, powered by Vercel AI SDK and OpenRouter.
Install
npm install @zap-tools/sdk zodServer Usage
// app/api/chat/route.ts
import { createZapServer } from "@zap-tools/sdk";
import { tool } from "ai";
import { z } from "zod";
const zap = createZapServer({
apiKey: process.env.OPENROUTER_API_KEY!,
systemPrompt: "You are a helpful assistant.",
tools: {
getUserEmail: tool({
description: "Get the current user email",
parameters: z.object({}),
execute: async () => "[email protected]",
}),
},
});
export async function POST(req: Request) {
return zap.handleRequest(req);
}Client Usage
import { useZapChat } from "@zap-tools/sdk/client";
const chat = useZapChat({ endpoint: "/api/chat" });The /client subpath is tree-shaken from server code — no server deps in your client bundle.
Exports
| Subpath | Description |
|---------|-------------|
| @zap-tools/sdk | Server — createZapServer, types, ZapTool |
| @zap-tools/sdk/client | Client — useZapChat hook, ZapChatState, ZapMessage |
Server Config
| Field | Type | Default | Description |
|-------|------|---------|-------------|
| apiKey | string | — | Your OpenRouter API key (server-only) |
| model | string | openai/gpt-oss-120b:free | Any OpenRouter model ID |
| systemPrompt | string | — | System prompt for the AI |
| tools | Record<string, ZapTool> | {} | Tools the AI can call server-side |
| maxSteps | number | 5 | Max tool-calling loops per request |
License
MIT
