openapi: 3.0.0 info: title: AI Chatbot API version: 1.0.0 description: Production-grade AI chatbot with RAG, multi-model routing, and safety features contact: name: API Support servers: - url: http://localhost:3001 description: Development server - url: https://api.example.com description: Production server paths: /api/chat: post: summary: Send a chat message description: Process a chat message and return AI response tags: - Chat requestBody: required: true content: application/json: schema: type: object required: - message - sessionId properties: message: type: string minLength: 1 maxLength: 10000 description: The user's message sessionId: type: string description: Session identifier userId: type: string description: User identifier (optional) responses: '200': description: Successful response content: application/json: schema: type: object properties: response: type: string description: AI generated response sessionId: type: string timestamp: type: string format: date-time '400': description: Bad request '429': description: Rate limit exceeded '500': description: Internal server error /api/knowledge-base/add: post: summary: Add text to knowledge base description: Add text content to the RAG knowledge base tags: - Knowledge Base requestBody: required: true content: application/json: schema: type: object required: - text properties: text: type: string description: Text content to add metadata: type: object description: Optional metadata responses: '200': description: Text added successfully content: application/json: schema: type: object properties: success: type: boolean chunksCount: type: number /api/knowledge-base/stats: get: summary: Get knowledge base statistics description: Retrieve statistics about the knowledge base tags: - Knowledge Base responses: '200': description: Knowledge base statistics content: application/json: schema: type: object properties: hasEmbeddings: type: boolean persistentStore: type: boolean persistence: type: object properties: sources: type: number chunks: type: number embeddings: type: number /api/rag/query: post: summary: Query the RAG knowledge base directly description: Run retrieval, reranking, compression, and optional response generation without going through chat orchestration. tags: - Knowledge Base requestBody: required: true content: application/json: schema: type: object required: - query properties: query: type: string minLength: 1 description: Search or question text generateResponse: type: boolean default: true description: When false, return compressed context instead of an LLM-generated answer includeEmbeddings: type: boolean default: false description: Include raw chunk embedding arrays in retrievedChunks responses: '200': description: RAG query result content: application/json: schema: type: object properties: response: type: string citations: type: array items: type: object retrievedChunks: type: array items: type: object compressedContext: type: string metadata: type: object '400': description: Query is missing or blank '503': description: RAG service is not initialized /api/knowledge-online/research: post: summary: Build an approval-gated deep research preview description: Search the requested category and related categories, collect bounded public web evidence, and return a synthesized preview. This endpoint does not write to the knowledge base. tags: - Knowledge Base requestBody: required: true content: application/json: schema: type: object required: - query properties: query: type: string minLength: 1 domain: type: string default: ask description: Primary specialist category used to expand related searches. responses: '200': description: Reviewable deep research preview content: application/json: schema: type: object required: - query - answerPreview - sources - reviewToken - requiresApproval properties: query: type: string answerPreview: type: string synthesis: type: string researchType: type: string enum: [deep-dive] primaryCategory: type: string relatedCategories: type: array items: type: string crossReferences: type: array items: type: object sources: type: array items: type: object required: [title, url, snippet] properties: title: type: string url: type: string format: uri snippet: type: string category: type: string fetchStatus: type: string reviewToken: type: string requiresApproval: type: boolean '400': description: Query is missing or blank '503': description: Knowledge document manager is not initialized /api/tools: get: summary: List available tools description: Get list of all available tools tags: - Tools responses: '200': description: List of tools content: application/json: schema: type: object properties: tools: type: array items: type: object properties: id: type: string name: type: string description: type: string category: type: string /health: get: summary: Health check description: Check application health status tags: - System responses: '200': description: Application is healthy content: application/json: schema: type: object properties: status: type: string enum: [ready, initializing, degraded] timestamp: type: string format: date-time services: type: object /metrics: get: summary: Prometheus metrics description: Export metrics in Prometheus format tags: - System responses: '200': description: Metrics in Prometheus format content: text/plain: schema: type: string components: securitySchemes: BearerAuth: type: http scheme: bearer bearerFormat: JWT ApiKeyAuth: type: apiKey in: header name: X-API-Key