ai-sdk-core-v6_skill

This skill helps you build backend AI using Vercel AI SDK v5/v6, handling agents, tools, and structured outputs efficiently.
  • TypeScript

4

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill blockmatic-icebox/basilic-old --skill ai-sdk-core-v6

  • SKILL.md3.5 KB

Overview

This skill shows how to build and troubleshoot backend AI using the Vercel AI SDK v5/v6. It focuses on server-side text generation, structured outputs with Zod, and agent workflows with tools and multi-provider support. Practical patterns, error handling, and runtime configuration guidance are included for reliable production use.

How this skill works

The skill explains core APIs: generateText for plain text, generateObject for Zod-validated structured outputs, and streamText for streaming responses. It covers ToolLoopAgent (v6) for agent-driven tool calling and tool approval flows, provider abstraction (openai, anthropic, google), and error types to inspect for robust error handling. Recommendations include runtime callOptions, schema validation, and retry/backoff patterns.

When to use it

  • Implement server-side AI features with Vercel AI SDK v5 or v6
  • Produce structured JSON outputs validated by Zod
  • Build agent workflows that call external tools or require human approval
  • Stream model responses for low-latency UX or server-sent events
  • Troubleshoot common API and schema validation errors in production

Best practices

  • Use generateText for simple prompts and generateObject with Zod for structured responses
  • Prefer ToolLoopAgent (v6) for agent orchestration rather than custom loops
  • Validate API keys at startup and handle response.error for typed errors
  • Implement exponential backoff and retries for rate limits and transient failures
  • Use callOptions to adjust model, temperature, and provider per request
  • Keep Cloudflare Worker entry modules free of top-level imports to avoid startup overhead

Example use cases

  • Backend endpoint that returns typed JSON user summaries using generateObject and a Zod schema
  • Agent that queries a database, calls a search tool, and composes an answer with ToolLoopAgent and tool approval
  • Streaming chat assistant that uses streamText with onError to gracefully recover and emit partial data
  • Multi-provider fallback where requests try openai then anthropic or google based on latency/cost
  • Error handling middleware that maps AI_APICallError and AI_NoObjectGeneratedError to actionable responses

FAQ

Use generateObject with a Zod schema and mode:'json' when available; validate the result and handle AI_NoObjectGeneratedError.

How do I implement human approval for tool calls?

Use ToolLoopAgent with tool execution approval hooks so tool actions pause for a human decision before execution.

What error handling is required at minimum?

Always inspect response.error, catch provider-specific error types (e.g., AI_APICallError), and use onError in streamText to handle streaming failures.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational