A TypeScript package template for building and publishing AI SDK tools.
npm install ai-sdk-tool-as-package-templateimport { weatherTool } from "ai-sdk-tool-as-package-template";
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
const result = await generateText({
model: openai("gpt-4o-mini"),
prompt: "What's the weather like?",
tools: {
weatherTool,
},
});- Clone the repository
- Install dependencies:
pnpm install- Create a
.envfile:
cp .env.example .env- Add your Vercel AI Gateway (or other preferred provider) API key to
.env
Test your tool locally:
pnpm testBuild the package:
pnpm buildBefore publishing, update the package name in package.json to your desired package name.
The package automatically builds before publishing:
pnpm publish.
├── src/
│ ├── index.ts # Your tool exports
│ └── test.ts # Test script
├── dist/ # Build output (generated)
├── package.json
├── tsconfig.json
└── README.md
MIT