curl -X POST "https://api.moorcheh.ai/v1/answer" \ -H "Content-Type: application/json" \ -H "x-api-key: your-api-key-here" \ -d '{ "namespace": "my-document-collection", "query": "What are the main benefits of Moorcheh?", "type": "text", "top_k": 5 }'
Copy
{ "answer": "Serverless architecture offers several benefits, including reduced operational costs as you only pay for what you use, automatic scaling to handle workload changes, and faster time-to-market since developers can focus on code instead of infrastructure management.", "model": "anthropic.claude-sonnet-4-5-20250929-v1:0", "contextCount": 3, "query": "What are the main benefits of using serverless architecture?"}
AI Generation
Generate AI Answer
Generate AI-powered answers to questions using your uploaded data as context or direct AI model calls.
POST
https://api.moorcheh.ai
/
v1
/
answer
Copy
curl -X POST "https://api.moorcheh.ai/v1/answer" \ -H "Content-Type: application/json" \ -H "x-api-key: your-api-key-here" \ -d '{ "namespace": "my-document-collection", "query": "What are the main benefits of Moorcheh?", "type": "text", "top_k": 5 }'
Copy
{ "answer": "Serverless architecture offers several benefits, including reduced operational costs as you only pay for what you use, automatic scaling to handle workload changes, and faster time-to-market since developers can focus on code instead of infrastructure management.", "model": "anthropic.claude-sonnet-4-5-20250929-v1:0", "contextCount": 3, "query": "What are the main benefits of using serverless architecture?"}
Generate AI-powered answers to questions with two modes: Search Mode (with namespace) and Direct AI Mode (empty namespace). The API supports context-aware generation using your data or direct AI model calls.
Supports multiple AI models including Claude 3.7 Sonnet, Claude Sonnet 4, Llama 4 Maverick, and DeepSeek-R1. Use empty string "" as namespace for direct AI calls.
When set with enabled: true, the API returns a JSON object in structuredData matching a schema (default or custom). Optional: schema, toolName, toolDescription. See Structured Output below.
Empty Namespace Mode: Only these fields are allowed: namespace, query, temperature, chatHistory, footerPrompt, headerPrompt, aiModel, structuredResponseProvided Namespace Mode: All fields are allowed: namespace, query, top_k, threshold, type, kiosk_mode, aiModel, chatHistory, headerPrompt, footerPrompt, temperature, structuredResponse
Copy
curl -X POST "https://api.moorcheh.ai/v1/answer" \ -H "Content-Type: application/json" \ -H "x-api-key: your-api-key-here" \ -d '{ "namespace": "my-document-collection", "query": "What are the main benefits of Moorcheh?", "type": "text", "top_k": 5 }'
Copy
{ "answer": "Serverless architecture offers several benefits, including reduced operational costs as you only pay for what you use, automatic scaling to handle workload changes, and faster time-to-market since developers can focus on code instead of infrastructure management.", "model": "anthropic.claude-sonnet-4-5-20250929-v1:0", "contextCount": 3, "query": "What are the main benefits of using serverless architecture?"}
When structuredResponse.enabled is true: the JSON object matching your schema (or the default). Contains e.g. answer, confidence, sources, summary, topics, followUpQuestions. Omitted otherwise.
Include structuredResponse: { enabled: true } in the request to get a type-safe JSON object in structuredData instead of (or in addition to) the plain answer string. Works in both Search Mode and Direct AI Mode.
If schema is omitted or null, the default schema is used:
Copy
{ "type": "object", "properties": { "answer": { "type": "string", "description": "The main answer to the user's query" }, "confidence": { "type": "number", "description": "Confidence score from 0 to 1 indicating how confident the model is in the answer", "minimum": 0, "maximum": 1 }, "sources": { "type": "array", "description": "List of source references used to generate the answer", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "The identifier of the source document/chunk" }, "relevance": { "type": "string", "description": "How relevant this source was to the answer", "enum": ["high", "medium", "low"] } }, "required": ["id"] } }, "summary": { "type": "string", "description": "A brief summary of the answer (max 200 characters)", "maxLength": 200 }, "topics": { "type": "array", "description": "Key topics or themes identified in the query/answer", "items": { "type": "string" } }, "followUpQuestions": { "type": "array", "description": "Suggested follow-up questions the user might want to ask", "items": { "type": "string" } } }, "required": ["answer", "confidence"]}
Pass your own JSON Schema in structuredResponse.schema. Use type, properties, required, items, enum, minimum, maximum, maxLength, etc. Keep required minimal so the model can fill all fields.