ai-sdk-core
Build backend AI with Vercel AI SDK v5/v6. Covers v6 beta (Agent abstraction, tool approval, reranking), v4→v5 migration (breaking changes), latest models (GPT-5/5.1, Claude 4.x, Gemini 2.5), Workers startup fix, and 12 error solutions (AI_APICallError, AI_NoObjectGeneratedError, streamText silent errors). Use when: implementing AI SDK v5/v6, migrating v4→v5, troubleshooting errors, fixing Workers startup issues, or updating to latest models.
What this skill does
# AI SDK Core Backend AI with Vercel AI SDK v5 and v6 Beta. **Installation:** ```bash npm install ai @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google zod # Beta: npm install ai@beta @ai-sdk/openai@beta ``` --- ## AI SDK 6 Beta (November 2025) **Status:** Beta (stable release planned end of 2025) **Latest:** [email protected] (Nov 22, 2025) ### New Features **1. Agent Abstraction** Unified interface for building agents with `ToolLoopAgent` class: - Full control over execution flow, tool loops, and state management - Replaces manual tool calling orchestration **2. Tool Execution Approval (Human-in-the-Loop)** Request user confirmation before executing tools: - Static approval: Always ask for specific tools - Dynamic approval: Conditional based on tool inputs - Native human-in-the-loop pattern **3. Reranking Support** Improve search relevance by reordering documents: - Supported providers: Cohere, Amazon Bedrock, Together.ai - Specialized reranking models for RAG workflows **4. Structured Output (Stable)** Combine multi-step tool calling with structured data generation: - Multiple output strategies: objects, arrays, choices, text formats - Now stable and production-ready in v6 **5. Call Options** Dynamic runtime configuration: - Type-safe parameter passing - RAG integration, model selection, tool customization - Provider-specific settings adjustments **6. Image Editing (Coming Soon)** Native support for image transformation workflows. ### Migration from v5 **Unlike v4→v5, v6 has minimal breaking changes:** - Powered by v3 Language Model Specification - Most users require no code changes - Agent abstraction is additive (opt-in) **Install Beta:** ```bash npm install ai@beta @ai-sdk/openai@beta @ai-sdk/react@beta ``` **Official Docs:** https://ai-sdk.dev/docs/announcing-ai-sdk-6-beta --- ## Latest AI Models (2025) ### OpenAI **GPT-5** (Aug 7, 2025): - 45% less hallucination than GPT-4o - State-of-the-art in math, coding, visual perception, health - Available in ChatGPT, API, GitHub Models, Microsoft Copilot **GPT-5.1** (Nov 13, 2025): - Improved speed and efficiency over GPT-5 - Available in API platform ```typescript import { openai } from '@ai-sdk/openai'; const gpt5 = openai('gpt-5'); const gpt51 = openai('gpt-5.1'); ``` ### Anthropic **Claude 4 Family** (May-Oct 2025): - **Opus 4** (May 22): Best for complex reasoning, $15/$75 per million tokens - **Sonnet 4** (May 22): Balanced performance, $3/$15 per million tokens - **Opus 4.1** (Aug 5): Enhanced agentic tasks, real-world coding - **Sonnet 4.5** (Sept 29): Most capable for coding, agents, computer use - **Haiku 4.5** (Oct 15): Small, fast, low-latency model ```typescript import { anthropic } from '@ai-sdk/anthropic'; const sonnet45 = anthropic('claude-sonnet-4-5-20250929'); // Latest const opus41 = anthropic('claude-opus-4-1-20250805'); const haiku45 = anthropic('claude-haiku-4-5-20251015'); ``` ### Google **Gemini 2.5 Family** (Mar-Sept 2025): - **Pro** (March 2025): Most intelligent, #1 on LMArena at launch - **Pro Deep Think** (May 2025): Enhanced reasoning mode - **Flash** (May 2025): Fast, cost-effective - **Flash-Lite** (Sept 2025): Updated efficiency ```typescript import { google } from '@ai-sdk/google'; const pro = google('gemini-2.5-pro'); const flash = google('gemini-2.5-flash'); const lite = google('gemini-2.5-flash-lite'); ``` --- ## v5 Core Functions (Basics) **generateText()** - Text completion with tools **streamText()** - Real-time streaming **generateObject()** - Structured output (Zod schemas) **streamObject()** - Streaming structured data See official docs for usage: https://ai-sdk.dev/docs/ai-sdk-core --- ## Cloudflare Workers Startup Fix **Problem:** AI SDK v5 + Zod causes >270ms startup time (exceeds Workers 400ms limit). **Solution:** ```typescript // ❌ BAD: Top-level imports cause startup overhead import { createWorkersAI } from 'workers-ai-provider'; const workersai = createWorkersAI({ binding: env.AI }); // ✅ GOOD: Lazy initialization inside handler app.post('/chat', async (c) => { const { createWorkersAI } = await import('workers-ai-provider'); const workersai = createWorkersAI({ binding: c.env.AI }); // ... }); ``` **Additional:** - Minimize top-level Zod schemas - Move complex schemas into route handlers - Monitor startup time with Wrangler --- ## v5 Tool Calling Changes **Breaking Changes:** - `parameters` → `inputSchema` (Zod schema) - Tool properties: `args` → `input`, `result` → `output` - `ToolExecutionError` removed (now `tool-error` content parts) - `maxSteps` parameter removed → Use `stopWhen(stepCountIs(n))` **New in v5:** - Dynamic tools (add tools at runtime based on context) - Agent class (multi-step execution with tools) --- ## Critical v4→v5 Migration AI SDK v5 introduced extensive breaking changes. If migrating from v4, follow this guide. ### Breaking Changes Overview 1. **Parameter Renames** - `maxTokens` → `maxOutputTokens` - `providerMetadata` → `providerOptions` 2. **Tool Definitions** - `parameters` → `inputSchema` - Tool properties: `args` → `input`, `result` → `output` 3. **Message Types** - `CoreMessage` → `ModelMessage` - `Message` → `UIMessage` - `convertToCoreMessages` → `convertToModelMessages` 4. **Tool Error Handling** - `ToolExecutionError` class removed - Now `tool-error` content parts - Enables automated retry 5. **Multi-Step Execution** - `maxSteps` → `stopWhen` - Use `stepCountIs()` or `hasToolCall()` 6. **Message Structure** - Simple `content` string → `parts` array - Parts: text, file, reasoning, tool-call, tool-result 7. **Streaming Architecture** - Single chunk → start/delta/end lifecycle - Unique IDs for concurrent streams 8. **Tool Streaming** - Enabled by default - `toolCallStreaming` option removed 9. **Package Reorganization** - `ai/rsc` → `@ai-sdk/rsc` - `ai/react` → `@ai-sdk/react` - `LangChainAdapter` → `@ai-sdk/langchain` ### Migration Examples **Before (v4):** ```typescript import { generateText } from 'ai'; const result = await generateText({ model: openai.chat('gpt-4'), maxTokens: 500, providerMetadata: { openai: { user: 'user-123' } }, tools: { weather: { description: 'Get weather', parameters: z.object({ location: z.string() }), execute: async (args) => { /* args.location */ }, }, }, maxSteps: 5, }); ``` **After (v5):** ```typescript import { generateText, tool, stopWhen, stepCountIs } from 'ai'; const result = await generateText({ model: openai('gpt-4'), maxOutputTokens: 500, providerOptions: { openai: { user: 'user-123' } }, tools: { weather: tool({ description: 'Get weather', inputSchema: z.object({ location: z.string() }), execute: async ({ location }) => { /* input.location */ }, }), }, stopWhen: stepCountIs(5), }); ``` ### Migration Checklist - [ ] Update all `maxTokens` to `maxOutputTokens` - [ ] Update `providerMetadata` to `providerOptions` - [ ] Convert tool `parameters` to `inputSchema` - [ ] Update tool execute functions: `args` → `input` - [ ] Replace `maxSteps` with `stopWhen(stepCountIs(n))` - [ ] Update message types: `CoreMessage` → `ModelMessage` - [ ] Remove `ToolExecutionError` handling - [ ] Update package imports (`ai/rsc` → `@ai-sdk/rsc`) - [ ] Test streaming behavior (architecture changed) - [ ] Update TypeScript types ### Automated Migration AI SDK provides a migration tool: ```bash npx ai migrate ``` This will update most breaking changes automatically. Review changes carefully. **Official Migration Guide:** https://ai-sdk.dev/docs/migration-guides/migration-guide-5-0 --- ## Top 12 Errors & Solutions ### 1. AI_APICallError **Cause:** API request failed (network, auth, rate limit). **Solution:** ```typescript import { AI_APICallError } from 'ai'; try { const result = await generateText({ model: openai('gpt-4'), prompt: 'Hello', }); } catch (error) { if (error insta
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.