Skip to content

feat(api): add project AI chat endpoint with validation#4

Closed
flooryyyy wants to merge 1 commit intomainfrom
codex/add-post-route-for-ai-chat
Closed

feat(api): add project AI chat endpoint with validation#4
flooryyyy wants to merge 1 commit intomainfrom
codex/add-post-route-for-ai-chat

Conversation

@flooryyyy
Copy link
Copy Markdown
Owner

Motivation

  • Provide an in-project AI chat endpoint to let project users send a short conversation and receive an assistant reply with usage metadata.
  • Ensure inputs are validated and bounded to prevent excessive upstream usage and request payload abuse.

Description

  • Add POST /api/projects/[id]/ai/chat implemented with projectAction, parsing and validating messages via Zod and returning an assistant message plus usage metadata.
  • Enforce size limits including content-length check, serialized body byte-size (256KB), per-message char limit (8,000), max messages (40), and overall char cap (120,000), returning 413 when exceeded.
  • Introduce an AI provider abstraction in src/app/lib/ai/provider.ts with generateProjectAssistantReply and an OpenAI-compatible implementation driven by AI_CHAT_ENDPOINT, AI_CHAT_API_KEY, AI_CHAT_MODEL, and AI_CHAT_PROVIDER, with upstream error mapping and logging.

Testing

  • Ran static checks via npm run check which includes eslint and tsc and completed successfully.
  • Ran the test suite (vitest run) which completed with all tests passing (Test Files 11 passed, Tests 55 passed).

Codex Task

@flooryyyy flooryyyy closed this Apr 10, 2026
@flooryyyy flooryyyy deleted the codex/add-post-route-for-ai-chat branch April 10, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant