Interactive TypeScript examples for aitutorial.dev. Every example runs in StackBlitz (browser) or locally with npx tsx.
git clone https://github.com/ai-tutorial/typescript-examples.git
cd typescript-examples
cp env/.env.example env/.env
# Add your API keys to env/.envSet AI_PROVIDER in env/.env to switch between providers:
| Provider | AI_PROVIDER |
API Key | Default Model |
|---|---|---|---|
| OpenAI | openai |
OPENAI_API_KEY |
gpt-4.1-nano |
| Gemini | gemini |
GOOGLE_GENERATIVE_AI_API_KEY + GOOGLE_API_KEY |
gemini-2.5-flash-lite |
| Claude | anthropic |
ANTHROPIC_API_KEY |
claude-haiku-4-5-20251001 |
Gemini offers a free tier — get a key at aistudio.google.com/apikey.
LLM fundamentals, structured outputs, prompt chaining, security defenses, cost optimization.
npx tsx src/prompting/hello_world.tsSearch strategies, chunking, PDF processing, evaluation, reranking, advanced patterns.
npm run --prefix src/rag test:ragLangChain agents, MCP servers, memory, business rules, security guardrails.
| File | What it does |
|---|---|
minimal_agent.ts |
Simplest LLM call (baseline) |
weather_agent.ts |
LangChain ReAct agent with tool calling |
weather_mcp_server.ts |
MCP server with self-test |
customer_support_agent.ts |
Multi-server agent (3 MCP servers, thread memory) |
CustomerSupportAgent.ts |
Stateless agent class |
KnowledgeBaseServer.ts |
MCP server: FAQ search |
CustomerInfoServer.ts |
MCP server: account, orders, preferences |
IncidentTicketServer.ts |
MCP server: ticket creation and tracking |
memory_examples.ts |
Working memory + long-term memory demos |
business_rules_validation.ts |
Deterministic expense validation |
guardrails_security.ts |
PII detection, jailbreak prevention, output filtering |
insurance_claims_example.ts |
Full insurance claims agent |
tool_selection_patterns.ts |
Context-based filtering, tool differentiation |
tool_analytics.ts |
Tool usage tracking and recommendations |
- aitutorial.dev — Full tutorial
- Vercel AI SDK
- LangChain
- MCP Specification