{"id":51083538,"url":"https://github.com/blendsdk/building-agents-vercel-ai-sdk","last_synced_at":"2026-06-23T20:32:19.183Z","repository":{"id":363189862,"uuid":"1262146904","full_name":"blendsdk/building-agents-vercel-ai-sdk","owner":"blendsdk","description":"A hands-on masterclass for building production-grade AI agents in TypeScript with the Vercel AI SDK — 13 runnable tutorials plus a VitePress docs site.","archived":false,"fork":false,"pushed_at":"2026-06-07T19:49:12.000Z","size":227,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-07T21:22:20.917Z","etag":null,"topics":["agents","ai","llm","typescript","vercel-ai-sdk","vitepress"],"latest_commit_sha":null,"homepage":"https://blendsdk.github.io/building-agents-vercel-ai-sdk/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blendsdk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-07T16:26:27.000Z","updated_at":"2026-06-07T20:01:44.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/blendsdk/building-agents-vercel-ai-sdk","commit_stats":null,"previous_names":["blendsdk/building-agents-vercel-ai-sdk"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/blendsdk/building-agents-vercel-ai-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blendsdk%2Fbuilding-agents-vercel-ai-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blendsdk%2Fbuilding-agents-vercel-ai-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blendsdk%2Fbuilding-agents-vercel-ai-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blendsdk%2Fbuilding-agents-vercel-ai-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blendsdk","download_url":"https://codeload.github.com/blendsdk/building-agents-vercel-ai-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blendsdk%2Fbuilding-agents-vercel-ai-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34706579,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-23T02:00:07.161Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agents","ai","llm","typescript","vercel-ai-sdk","vitepress"],"created_at":"2026-06-23T20:32:18.354Z","updated_at":"2026-06-23T20:32:19.176Z","avatar_url":"https://github.com/blendsdk.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Building AI Agents with the Vercel AI SDK\n\nA hands-on, ten-part course for learning to build AI agents in TypeScript using the\n[Vercel AI SDK](https://ai-sdk.dev) (`ai` v6) with the OpenAI provider. Each tutorial\nis a small, heavily-commented, runnable program that teaches one concept — building\nfrom a basic agent loop all the way to a production-style capstone.\n\n## What's an \"agent\"?\n\nAn **agent** is an LLM running in a *loop* that can call **tools** (functions you\ndefine), observe the results, and keep going until it produces a final answer. The\nsingle line that enables that loop in this SDK is `stopWhen: stepCountIs(N)`.\n\n## Setup\n\n```bash\n# 1. Install dependencies\nyarn install\n\n# 2. Add your OpenAI API key\necho \"OPENAI_API_KEY=sk-...\" \u003e .env\n```\n\n\u003e ⚠️ Keep `.env` out of version control and rotate any key that's been exposed.\n\n## Running\n\n```bash\nyarn dev          # interactive menu — pick a tutorial 1–10\nyarn dev \u003cn\u003e      # run a specific tutorial directly, e.g. `yarn dev 5`\nyarn build        # type-check + compile with tsc\n```\n\n## The tutorials\n\nRun them in order — each builds on the last.\n\n| # | Tutorial | What you learn | File |\n|---|----------|----------------|------|\n| 1 | **One-shot agent** | The core agent loop + tool calling (`generateText` + `stepCountIs`) | `src/agents/01-oneshot.ts` |\n| 2 | **Interactive chat** | Streaming (`streamText`) + conversation memory (`messages`) | `src/agents/02-interactive.ts` |\n| 3 | **Structured JSON** | Typed, validated output via `Output.object` + Zod | `src/agents/03-json.ts` |\n| 4 | **Agent class** | The reusable `ToolLoopAgent` abstraction | `src/agents/04-agent-class.ts` |\n| 5 | **RAG** | Grounding answers in your own docs with embeddings + retrieval | `src/agents/05-rag.ts` |\n| 6 | **Robust agents** | Structured tool errors + the tool-repair hook | `src/agents/06-robust.ts` |\n| 7 | **Human-in-the-loop** | Approval gates for sensitive tools | `src/agents/07-human-in-the-loop.ts` |\n| 8 | **Multi-agent** | Orchestration — a supervisor that delegates to specialist agents | `src/agents/08-multi-agent.ts` |\n| 9 | **Observability** | Tracing steps, token usage \u0026 cost | `src/agents/09-observability.ts` |\n| 10 | **Capstone** | A support agent combining RAG + JSON + approval + errors + observability | `src/agents/10-capstone.ts` |\n\n## Project layout\n\n```\nsrc/\n  index.ts        # launcher / menu — dispatches to a tutorial\n  tools.ts        # shared example tools (getWeather, calculator)\n  markdown.ts     # terminal markdown renderer (pretty output)\n  agents/         # the ten tutorials (01 … 10)\n.clinerules/\n  ai-sdk.md       # conventions \u0026 gotchas — read this for the \"rules\"\n```\n\n## Key things to know (see `.clinerules/ai-sdk.md` for details)\n\n- **Structured output:** `generateObject` / `streamObject` are **deprecated** in v6.\n  Use `generateText` / `streamText` with an `output: Output.object({ schema })` setting\n  and read `result.output`.\n- **System prompts:** pass via the `system` option (or `instructions` on `ToolLoopAgent`),\n  not as a `{ role: \"system\" }` message.\n- **Embeddings:** use `openai.embedding(...)` (`textEmbedding` is deprecated).\n- **Robust tools:** return structured `{ ok: false, error }` results instead of throwing,\n  so the agent can recover.\n- **Verify the API:** when unsure, check the installed types directly:\n  `grep -nE \"@deprecated\" node_modules/ai/dist/index.d.ts`.\n\n## Tech stack\n\n- [`ai`](https://www.npmjs.com/package/ai) v6 — the Vercel AI SDK\n- [`@ai-sdk/openai`](https://www.npmjs.com/package/@ai-sdk/openai) v3 — OpenAI provider\n- [`zod`](https://zod.dev) — tool input + structured output schemas\n- TypeScript (ESM, `nodenext`) run with [`tsx`](https://www.npmjs.com/package/tsx)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblendsdk%2Fbuilding-agents-vercel-ai-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblendsdk%2Fbuilding-agents-vercel-ai-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblendsdk%2Fbuilding-agents-vercel-ai-sdk/lists"}