Skip to content

Update to vercel sdk v5 #44

@noid2

Description

@noid2

🆙 Proposal: Update Vercel AI SDK from v4 to v5

Summary

This issue proposes upgrading the vercel/ai SDK dependency from v4 to the latest v5 release in the nuxtui-pro/chat project. The Vercel AI SDK v5 introduces significant improvements in API design, streaming support, fine-grained response handling, and better integrations with edge environments — making it a valuable update for our chat experience.


Motivation

  • Improved DX (Developer Experience): v5 introduces a more ergonomic API with better typings and modularity.
  • Streaming Enhancements: Cleaner handling of streaming responses using native web APIs (ReadableStream) and new utilities like experimental_streamText.
  • Edge Compatibility: Improved out-of-the-box support for deployment on Vercel Edge Functions or other edge runtimes.
  • Long-Term Support: v5 is the actively maintained and forward-compatible version. Remaining on v4 may cause future integration friction.

Impact Areas

  • server/api/chat.ts: The current usage of OpenAIStream, StreamingTextResponse, etc. needs to be updated to the new APIs (streamText, experimental_streamText, etc.).
  • Middleware & runtime setup: Vercel AI v5 offers more flexibility in how handlers are structured (e.g., use of POST request handlers and better request typing).
  • Any components consuming streaming output from the server endpoint may require review (e.g., ChatStream.vue).

Migration Plan

  1. Replace v4-specific imports such as OpenAIStream and StreamingTextResponse with v5’s streamText() API.
  2. Adjust server route handlers to accommodate the new streaming model.
  3. Validate compatibility with the current OpenAI or Anthropic provider configuration used in the app.
  4. Test the updated chat endpoint under Vercel edge runtime using local dev (vercel dev) and production preview.
  5. Update documentation and usage references in README.md or developer notes (if any).
  6. Ensure all TypeScript typings and ESLint rules pass with the updated SDK.

References


Checklist

  • Investigate compatibility with current OpenAI configuration
  • Update server API endpoints
  • Refactor streaming handling logic
  • Test locally and on preview deployment
  • Create PR with upgrade and relevant notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions