Skip to main content
Explore real-world examples of building AI agents with PromptSmith. Each example includes complete, runnable code with detailed explanations.

Available Examples

Customer Support Agent

Build a customer support agent with knowledge base search and order management tools

Code Assistant

Create a coding assistant with file operations and code analysis capabilities

Data Analysis Agent

Build a data analysis agent with conditional logic and role-based access control

Multi-Tool Agent

Create agents with multiple tools using both AI SDK and Mastra frameworks

What You’ll Learn

These examples demonstrate:
  • Prompt Building - Structured approach to creating agent prompts with identity, capabilities, and constraints
  • Tool Integration - Adding tools with Zod schemas for real-time data access
  • Framework Compatibility - Using PromptSmith with Vercel AI SDK and Mastra
  • Advanced Features - Validation, conditional logic, and production patterns
  • Best Practices - Real-world patterns for building reliable AI agents

Prerequisites

All examples require:
npm install promptsmith-ts zod

For AI SDK Examples

npm install ai @ai-sdk/openai

For Mastra Examples

npm install @mastra/core

Quick Start

Each example is self-contained and can be run independently:
1

Choose an Example

Browse the examples above and select one that matches your use case
2

Install Dependencies

Install the required packages listed in each example’s prerequisites
3

Copy the Code

Copy the complete example code into your project
4

Configure API Keys

Set up your API keys for OpenAI, Anthropic, or other providers
export OPENAI_API_KEY="your-api-key"
5

Run the Example

Execute the code to see the agent in action
npx tsx example.ts

Example Structure

Each example follows a consistent pattern:
  1. Overview - What the example demonstrates
  2. Prerequisites - Required packages and setup
  3. Complete Code - Full, runnable implementation
  4. Step-by-Step Walkthrough - Detailed explanation of each part
  5. Expected Output - What you’ll see when running the example
  6. Key Concepts - Important takeaways and best practices

Next Steps

Core Concepts

Learn the fundamentals of the PromptSmith builder pattern

API Reference

Explore the complete API documentation

Build docs developers (and LLMs) love