dial-api-patterns

Standardize Next.js API routes for ai-dial-chat with session and input validation proxied to DIAL Core.

503|60|Updated Sep 7, 2023
One-click install
npx skills add https://github.com/epam/ai-dial-chat --skill dial-api-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dial-api-patterns
Source: https://github.com/epam/ai-dial-chat/tree/main/.claude/skills/dial-api-patterns
Command: npx skills add https://github.com/epam/ai-dial-chat --skill dial-api-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide standardizes the way ai-dial-chat API routes are built, ensuring sessions are validated, inputs are checked, and requests are proxied to DIAL Core with consistent error handling and streaming support.

Core Features & Use Cases

  • Standardize endpoint patterns: validate session → validate input → proxy to DIAL Core.
  • Enable streaming responses with correct headers and cancellation handling.
  • Centralize error handling messages and patterns for consistent behavior across routes.
  • Provide guidance for locating session utilities, auth options, and error definitions within the codebase.

Quick Start

Implement the standard pattern in an API route under apps/chat/src/pages/api/ by validating the session, validating input, and proxying to DIAL Core as described.

Frequently Asked Questions about dial-api-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I standardize Next.js API routes for ai-dial-chat?

To standardize Next.js API routes for ai-dial-chat, validate the session, validate input, and proxy requests to DIAL Core, applying centralized error handling and streaming support under apps/chat/src/pages/api/.

How does streaming work in Next.js API routes proxying to DIAL Core?

Streaming in Next.js API routes works by applying correct headers and cancellation handling when proxying responses to DIAL Core, ensuring consistent data flow and resource cleanup across the standardized endpoints.

What is the best way to handle errors in ai-dial-chat API routes?

The best way to handle errors in ai-dial-chat API routes is to centralize error messages and patterns, placing error definitions in designated code locations to ensure consistent behavior across all proxied endpoints.

Do I need session validation for every Next.js API route in ai-dial-chat?

Yes, session validation is required for every Next.js API route in ai-dial-chat. The standardized pattern enforces validating the session and input before proxying any requests to DIAL Core.

Where should I place session utilities and auth options for ai-dial-chat API patterns?

You should place session utilities, auth options, error messages, and stream helpers in the designated code locations within the ai-dial-chat codebase to maintain standardized API route architecture.

Why does my ai-dial-chat API route fail without input validation?

Your ai-dial-chat API route fails because the standard pattern enforces input validation before proxying to DIAL Core, preventing malformed requests from reaching the backend and ensuring consistent error handling.