Skip to main content

Package Installation

PromptSmith is distributed as an npm package and works with both Vercel AI SDK and Mastra. Choose the installation method that fits your project.

For Vercel AI SDK

If you’re using Vercel AI SDK for your AI agents, install these packages:
npm install promptsmith-ts zod ai
Dependencies:
  • promptsmith-ts - The core PromptSmith library
  • zod - Schema validation and type inference for tools
  • ai - Vercel AI SDK for LLM integration

For Mastra

If you’re using Mastra for your AI agents, install these packages:
npm install promptsmith-ts zod @mastra/core
Dependencies:
  • promptsmith-ts - The core PromptSmith library
  • zod - Schema validation and type inference for tools
  • @mastra/core - Mastra agent framework

For Both Frameworks

If you want to use PromptSmith with both Vercel AI SDK and Mastra in the same project:
npm install promptsmith-ts zod ai @mastra/core
PromptSmith works seamlessly with both frameworks in the same project, giving you maximum flexibility.

Model Provider Setup

You’ll also need to install a model provider SDK. PromptSmith works with any provider supported by Vercel AI SDK or Mastra.
npm install @ai-sdk/openai
import { openai } from "@ai-sdk/openai";

const model = openai("gpt-4");

Requirements

Make sure your environment meets these minimum requirements:
1

Node.js Version

Node.js >= 18.0.0 is required. PromptSmith uses modern JavaScript features that require Node 18 or higher.Check your Node version:
node --version
2

TypeScript (Optional)

TypeScript >= 5.0.0 is recommended but not required. PromptSmith provides full type definitions for the best development experience.If using TypeScript, install it:
npm install -D typescript
3

Module System

PromptSmith is distributed as ESM (ES Modules). Make sure your project supports ES modules:In package.json:
{
  "type": "module"
}
Or use .mjs file extensions for your scripts.

TypeScript Configuration

For the best TypeScript experience, configure your tsconfig.json:
tsconfig.json
{
  "compilerOptions": {
    "target": "ES2020",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  }
}
PromptSmith is written in TypeScript and provides full type definitions out of the box. No additional @types packages needed!

Environment Variables

Set up your API keys for the model providers you’re using:
.env
# OpenAI
OPENAI_API_KEY=sk-...

# Anthropic
ANTHROPIC_API_KEY=sk-ant-...

# Google AI
GOOGLE_GENERATIVE_AI_API_KEY=...

# Mistral
MISTRAL_API_KEY=...
Never commit your API keys to version control. Add .env to your .gitignore file.

Verify Installation

Create a simple test file to verify everything is working:
test.ts
import { createPromptBuilder } from "promptsmith-ts/builder";

const agent = createPromptBuilder()
  .withIdentity("You are a helpful assistant")
  .withCapabilities(["Answer questions", "Provide help"]);

const prompt = agent.build();
console.log(prompt);
console.log("\nPromptSmith installed successfully!");
Run the test:
node test.ts
You should see the generated system prompt printed to the console.

Module Exports

PromptSmith provides three main export paths:

Builder Module

import { createPromptBuilder } from "promptsmith-ts/builder";
import type {
  SystemPromptBuilder,
  ToolDefinition,
  ExecutableToolDefinition,
  ConstraintType,
  Example,
  AiSdkConfig,
  PromptFormat,
} from "promptsmith-ts/builder";

Tester Module

import { createTester } from "promptsmith-ts/tester";
import type {
  TestCase,
  TestOptions,
  TestResult,
  TestCaseResult,
} from "promptsmith-ts/tester";

Templates Module

import {
  customerService,
  codingAssistant,
  dataAnalyst,
  researchAssistant,
  security,
  multilingual,
  accessibility,
} from "promptsmith-ts/templates";

Troubleshooting

Make sure you’ve installed the package:
npm install promptsmith-ts
If using a monorepo, ensure the package is installed in the correct workspace.
Install Zod as a peer dependency:
npm install zod
Zod is required for tool schema validation.
PromptSmith uses ESM. Add to your package.json:
{
  "type": "module"
}
Or use .mjs file extensions.
Make sure you’re using TypeScript 5.0 or higher:
npm install -D typescript@latest
PromptSmith includes its own type definitions, no @types package needed.

Next Steps

Now that you have PromptSmith installed, you’re ready to build your first agent!

Quick Start Guide

Build your first agent in 5 minutes

API Reference

Explore the complete API documentation

Examples

Learn from real-world examples

Templates

Use pre-built templates for common use cases

Build docs developers (and LLMs) love