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 }'
{ "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": "deepseek.r1-v1:0", "context_count": 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
/
v1
/
answer
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 }'
{ "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": "deepseek.r1-v1:0", "context_count": 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 Sonnet 4.6, Claude Opus 4.6, Llama 4 Maverick, Amazon Nova Pro, DeepSeek, Qwen, and others. Use empty string "" as namespace for direct AI calls.
When set with enabled: true, the API returns a JSON object in structured_data matching a schema (default or custom). Optional: schema, tool_name, tool_description (legacy camelCase aliases still accepted). Schemas may use snake_case property names; the service normalizes them for Bedrock. See Structured Output below.
Use snake_case fields in requests/responses. Legacy camelCase aliases are still accepted for backward compatibility and return deprecation headers (Deprecation, Sunset, Warning). CamelCase support is deprecated and scheduled for removal on 1 May 2026.
Empty Namespace Mode: Only these fields are allowed: namespace, query, temperature, chat_history, footer_prompt, header_prompt, ai_model, structured_responseProvided Namespace Mode: All fields are allowed: namespace, query, top_k, threshold, type, kiosk_mode, ai_model, chat_history, header_prompt, footer_prompt, temperature, structured_response
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 }'
{ "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": "deepseek.r1-v1:0", "context_count": 3, "query": "What are the main benefits of using serverless architecture?"}
When structured_response.enabled is true: the JSON object matching your schema (or the default). Contains e.g. answer, confidence, sources, summary, topics, follow_up_questions. Omitted otherwise. Property names follow your schema; the default schema uses snake_case (e.g. follow_up_questions).
Include structured_response: { enabled: true } in the request to get a type-safe JSON object in structured_data instead of (or in addition to) the plain answer string. Works in both Search Mode and Direct AI Mode. Custom schema objects may use snake_case keys; they are normalized for Bedrock (camelCase) internally.
JSON Schema for the structured object. Omit or null to use the default. Prefer snake_case property names under properties; they are converted for Bedrock.
tool_name
string
No
"structured_response"
Internal tool name for structured output.
tool_description
string
No
"Generate a structured response based on the user's query and provided context"
If schema is omitted or null, the default schema is used:
{ "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" } }, "follow_up_questions": { "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 structured_response.schema. Use type, properties, required, items, enum, minimum, maximum, maxLength, etc. Keep required minimal so the model can fill all fields.