{
  "openapi": "3.0.0",
  "info": {
    "title": "Itqan Soft RAG API",
    "description": "Retrieval API for AI agents to get Itqan Soft company context (services, products, contact, FAQ). Use the search action with a natural language question to receive relevant text chunks.",
    "version": "1.0.0",
    "contact": {
      "name": "Itqan Soft",
      "url": "https://itqansoft.sd",
      "email": "info@itqansoft.sd"
    }
  },
  "servers": [
    {
      "url": "https://itqansoft.sd",
      "description": "Production"
    }
  ],
  "paths": {
    "/api/ai-rag": {
      "get": {
        "operationId": "searchRag",
        "summary": "Search Itqan Soft knowledge base",
        "description": "Returns relevant text chunks from the Itqan Soft knowledge base (company info, services, products, contact, FAQ). Use the query parameter with the user's question or topic.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "description": "Search query (e.g. user question about Itqan Soft)",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 500
            }
          },
          {
            "name": "locale",
            "in": "query",
            "description": "Language for results: en (English) or ar (Arabic). Omit for both.",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["en", "ar"]
            }
          },
          {
            "name": "topK",
            "in": "query",
            "description": "Maximum number of chunks to return (1-20). Default 5.",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 20,
              "default": 5
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Search results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean", "example": true },
                    "query": { "type": ["string", "null"], "example": "contact email" },
                    "locale": { "type": ["string", "null"], "example": "en" },
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": { "type": "string" },
                          "source": { "type": "string" },
                          "title": { "type": "string" },
                          "text": { "type": "string" },
                          "score": { "type": "number" }
                        }
                      }
                    },
                    "generated_at": { "type": "string", "format": "date-time" }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean", "example": false },
                    "error": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
