Common Issues
This guide covers the most common issues developers encounter when using the AI SDK and their solutions.API and Authentication Errors
Missing API Key
Issue:Invalid API Key Format
Issue:- OpenAI keys start with
sk- - Anthropic keys start with
sk-ant- - Check for whitespace or special characters
- Verify the key hasn’t expired
Rate Limiting
Issue:Streaming Issues
Stream Not Working When Deployed
Issue: Streaming works locally but not in production. Solution: Ensure your deployment platform supports streaming:- Use Edge Runtime or Node.js 18+
- Ensure
runtime = 'edge'orruntime = 'nodejs'is set
Buffering by Proxy/CDN
Issue: Responses are buffered by proxies or CDNs. Solution: Disable response buffering:Stream Timeout on Vercel
Issue: Streams timeout after 30 seconds on Vercel Hobby. Solution:- Upgrade to Vercel Pro for 5-minute timeouts
- Or use Edge Runtime (no timeout):
RSC Issues
Streamable UI Not Updating
Issue: UI remains in loading state. Solution: Always call.done():
Server Actions in Client Components
Issue:File Extension Error (.ts vs .tsx)
Issue:.tsx extension for files with JSX:
Changed from .ts to .tsx
Tool Calling Issues
Tools Not Being Called
Issue: Model doesn’t call your tools. Solution:- Improve tool descriptions:
- Use
toolChoice: 'required':
Invalid Tool Input
Issue:TypeScript Issues
Model Not Assignable to Type
Issue:Cannot Find Namespace ‘JSX’
Issue:tsconfig.json includes React types:
Message Format Issues
useChat Stale Body Data
Issue: Chat messages contain stale or incorrect data. Solution: Ensure proper message state management:Failed to Parse Stream
Issue:Performance Issues
Slow TypeScript Compilation with Zod
Issue: TypeScript compilation is very slow. Solution: Use simpler schemas or increase TypeScript memory:High Memory Usage with Images
Issue: Application uses too much memory when processing images. Solution: Stream images or process in batches:Next Steps
- Learn about debugging techniques
- Review error recovery strategies
- Check the API reference