
Fundamentals
- generateText: Basic async text generation with model and prompt
- Unified interface: Switch models (GPT-4o, Perplexity, Gemini) by changing one line
- Tool calling: Define tools with name, description, parameters, and execute function; model decides when to call them
- maxSteps: Enables multi-step agent loops — model calls tools, gets results, continues until text output or max steps
Structured Output
- generateObject: Returns typed objects using Zod schemas
- Zod's describe function adds detailed instructions per field
Deep Research Clone (218 lines)
- Generate sub-queries from the main topic
- Web search each query using Exa API
- Evaluate results (relevant/irrelevant) with tool-calling agent
- Extract learnings and follow-up questions
- Recurse with depth/breadth parameters, accumulating research state
- Generate final report in markdown using all accumulated data
Key architecture: recursive deepResearch function with accumulated state, duplicate source prevention, and system prompt engineering for the final report.