A Val Town template for building AI agents using the Vercel AI SDK. This is a model-agnostic alternative to the OpenAI Agents template — same agent pattern, but you can swap in any model provider (Anthropic, Google, etc.) by changing a single line.
An agent is inference in a loop with tools: an LLM receives a system prompt, reads from and writes to an environment through tools, and loops until it decides it's done.
Rendering mermaid diagram...
The OpenAI Agents SDK is great if you're all-in on OpenAI. The Vercel AI SDK gives you the same agent capabilities — tool loops, multi-step reasoning, structured output — but with a unified interface across providers. Switch from OpenAI to Anthropic to Google by changing one line:
// OpenAI
model: openai("gpt-4o-mini")
// Anthropic (just change this line + import)
model: anthropic("claude-sonnet-4-20250514")
// Google
model: google("gemini-2.0-flash")
OPENAI_API_KEY environment variable. Get your API key here: https://platform.openai.com/api-keys
ANTHROPIC_API_KEY, GOOGLE_GENERATIVE_AI_API_KEY, etc.main.ts — change the model, add custom tools, or modify the prompt.Run on main.ts