ai-sdk-6-skills
AI SDK 6 Beta overview, agents, tool approval, Groq (Llama), and Vercel AI Gateway. Key breaking changes from v5 and new patterns.
By gocallum · 456 installs
npx skills add gocallum/nextjs16-agent-skills --skill ai-sdk-6-skills
Source repository · Upstream listing
Links
AI SDK 6 Beta Docs: https://v6.ai sdk.dev/docs/announcing ai sdk 6 beta
Groq Provider: https://v6.ai sdk.dev/providers/ai sdk providers/groq
Vercel AI Gateway: https://v6.ai sdk.dev/providers/ai sdk providers/ai gateway
AI SDK GitHub: https://github.com/vercel/ai
Groq Console Models: https://console.groq.com/docs/models
Installation
Note : Pin versions during beta as breaking changes may occur in patch releases.
What's New in AI SDK 6?
1. Agent Abstraction (New)
Unified interface for building agents with full control over execution flow, tool loops, and state management.
2. Tool Execution Approval (New)
Request user confirmation before executing sensitive tools.
Client side approval UI:
3. Structured Output + Tool Calling (Stable)
Combine tool calling with structured output generation:
4. Reranking Support (New)
Improve search relevance by reordering documents:
Migration from AI SDK 5
Minimal breaking changes expected . Most AI SDK 5 code will work with little modification.
Key differences:
Agent abstraction replaces ad hoc patterns; consider migrating to ToolLoopAgent .
Structured output now works with generateText / streamText (requires stopWhen ).
@ai sdk/ packages may have minor API adjustments during beta.
Groq Provider (Open Weight Models)
Setup
Environment:
Open Weight Models Available
Popular Groq models for AI SDK 6:
llama 3.3 70b versatile (Llama 3.3, 70B, balanced)
llama 3.1 8b instant (Llama 3.1, 8B, fast)
mixtral 8x7b 32768 (Mixture of Experts)
gemma2 9b it (Google Gemma 2)
qwen/qwen3 32b (Qwen 3)
See [Groq console](https://console.groq.com/docs/models) for full list.
Basic Llama Example
Structured Output with Llama (Groq)
Tool Use with Llama (Groq)
Reasoning Models (Groq)
Groq offers reasoning models like qwen/qwen3 32b and deepseek r1 distill llama 70b :
Image Input with Llama (Groq Multi Modal)
Vercel AI Gateway
What It Is
A unified interface to access models from 20+ providers (OpenAI, Anthropic, Google, Groq, xAI, Mistral, etc.) through a single API. Requires Vercel account and credit card .
Setup
Get your key from Vercel Dashboard AI Gateway.
⚠️ Note : Credit card required for Gateway usage. You will be billed for model calls routed through the gateway.
Authentication
API Key Authentication
Set via environment variable or directly in code:
OIDC Authentication (Vercel Deployments)
When deployed to Vercel, use OIDC tokens for automatic authentication (no API key needed):
Production/Preview : Automatic OIDC handling, no setup required.
Local Development :
1. Install & authenticate Vercel CLI: vercel login
2. Pull OIDC token: vercel env pull
3. Use vercel dev to start dev server (handles token refresh automatically)
Note: OIDC tokens expire after 12 hours; use vercel dev for automatic refresh, or run vercel env pull again manually.
Basic Usage
Gateway Instance
Model Discovery (Dynamic)
Check Credit Usage
Streaming with Gateway
Tool Use with Gateway
Bring Your Own Key (BYOK)
Connect your own provider credentials to Gateway for private resource access:
Set up BYOK credentials in Vercel team's AI Gateway settings; no code changes needed after configuration.
Provider Executed Tools
Some providers offer tools executed server side (e.g., OpenAI web search). Use through Gateway by importing the provider:
Note : Tools requiring account specific configuration (e.g., Claude Agent Skills) may need direct provider access via BYOK.
Provider Routing & Fallback
Core Routing Options :
order : Try providers in sequence (fallback priority)
only : Restrict to specific providers only
models : Fallback to alternative models if primary fails
user : Track usage per end user
tags : Categorize requests for analytics
zeroDataRetention : Only use providers with zero data retention
byok : Request scoped BYOK credentials
Example: Provider & Model Fallback
Example: Usage Tracking
Zero Data Retention
Route requests only to providers with zero data retention policies for sensitive data:
When zeroDataRetention: true , Gateway only routes to providers that don't retain your data. No enforcement applied if omitted or false .
Key Concepts
Call Options for Agents
Dynamically configure agents at runtime:
UI Integration with React
Best Practices
Groq
Use llama 3.3 70b versatile for balanced performance and cost.
Use llama 3.1 8b instant for low latency, lightweight tasks.
Enable parallelToolCalls: true (default) for faster multi tool execution.
Use serviceTier: 'flex' for 10x rate limits if you can tolerate occasional failures.
Vercel AI Gateway
Always add credit card ; gateway is pay per token.
Use only / order to control routing and costs.
Use user and tags for spend tracking and debugging.
Enable zeroDataRetention for sensitive data.
Check gateway.getCredits() regularly to monitor usage.
Agents
Use ToolLoopAgent as a starting point; extend only if needed.
Combine structured output with tool calling for rich responses.
Use tool approval for payment/deletion operations.
Set stopWhen to control loop iterations (default: stepCountIs(20) ).
Common Patterns
RAG Agent
Multi Provider with Fallback
Cost Optimized Selection
Timeline
AI SDK 6 Beta : Available now (pin versions)
Stable Release : End of 2025