Skip to content

feat(api): implement streaming AI responses using Vercel AI SDK (fixes #48) - #56

Open
Diwakar-odds wants to merge 2 commits into
Sparkyyy45:mainfrom
Diwakar-odds:feat/issue-48-ai-sdk
Open

feat(api): implement streaming AI responses using Vercel AI SDK (fixes #48)#56
Diwakar-odds wants to merge 2 commits into
Sparkyyy45:mainfrom
Diwakar-odds:feat/issue-48-ai-sdk

Conversation

@Diwakar-odds

Copy link
Copy Markdown

Summary

Introduces Vercel AI SDK integration for server-side LLM inference.

Motivation

Closes #48.

Changes

  • app/api/chat/route.ts:
    • [NEW] Created the chat Edge endpoint to securely proxy LLM requests to Groq and OpenRouter using @ai-sdk/openai.
  • lib/llm/provider.ts:
    • [MODIFY] Refactored streamText and generateText to query our new /api/chat route and consume the data stream format.
  • package.json:
    • [MODIFY] Added ai, @ai-sdk/openai, @upstash/ratelimit, @upstash/redis dependencies.

Acceptance Criteria

  • Implemented streaming AI responses on Edge runtime.
  • Refactored provider.ts to use internal API route.

Impact & Side Effects

No breaking changes to the user interface. Network traffic for AI analysis now routes through /api/chat rather than directly to providers.

How to Test

  1. Run npm run dev.
  2. Configure your AI keys in Settings.
  3. Open an issue and trigger the AI analysis. The responses should stream seamlessly just as before, but via the internal API route.

Quality Checklist

  • Code aligns with PEP-8/ESLint standards.
  • No temporary or scratch files are included in the commit.
  • Commit messages follow conventional format.

@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

@Diwakar-odds is attempting to deploy a commit to the suyashyadav1709-9626's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Diwakar-odds

Copy link
Copy Markdown
Author

PR Analysis & Label Request

This PR migrates the AI code parsing and generation from the frontend directly calling provider APIs into a secure, robust Next.js Edge Runtime API route (/api/chat). It introduces the Vercel AI SDK to seamlessly handle custom streaming behavior and parsing from Groq/OpenRouter. This foundational architectural shift removes raw request logic from the client, enhancing security and preparing the system for backend-level rate limiting.

ECSoC26 Label Justification:
Based on the code changes and ECSoC criteria, I kindly request this PR be labeled with:

  • ECSoC26-L3 as this involves core backend architectural restructuring (migrating client-side fetching to Next.js Edge Runtime with the Vercel AI SDK).
  • good-backend and good-pr as this introduces a secure standard practice for proxying LLM requests securely, handling streams efficiently on the edge, and eliminating raw fetch loops on the client.

Please review when you have a moment. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ECSoC_2026] Arch: Implement streaming AI responses using Vercel AI SDK and Next.js Edge Runtime

1 participant