Skip to content

vercel-labs/ai-sdk-tool-as-package-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI SDK Tool Package Template

A TypeScript package template for building and publishing AI SDK tools.

Installation

npm install ai-sdk-tool-as-package-template

Usage

import { 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,
  },
});

Development

Setup

  1. Clone the repository
  2. Install dependencies:
pnpm install
  1. Create a .env file:
cp .env.example .env
  1. Add your Vercel AI Gateway (or other preferred provider) API key to .env

Testing

Test your tool locally:

pnpm test

Building

Build the package:

pnpm build

Publishing

Before publishing, update the package name in package.json to your desired package name.

The package automatically builds before publishing:

pnpm publish

Project structure

.
├── src/
│   ├── index.ts      # Your tool exports
│   └── test.ts       # Test script
├── dist/             # Build output (generated)
├── package.json
├── tsconfig.json
└── README.md

License

MIT

About

Template for publishing your tools as an NPM package.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published