FAQ Generator
Overview
The FAQ Generator endpoint is a knowledge agent that automatically generates frequently asked questions (FAQs) from documents using AI-powered question extraction and answer generation. You can specify focus areas and the number of questions to generate, and the system will create relevant Q&A pairs with source and relevance rankings.
Use this endpoint to:
- Automatically generate FAQs from documents, manuals, and knowledge bases
- Create Q&A pairs with specific focus areas (e.g., pricing, legal, technical)
- Build comprehensive FAQ sections for websites and documentation
- Extract key information as question-answer pairs
- Generate training data for chatbots and support systems
Endpoint Details
Method:
POST
Endpoint:/api/agent/faq_generator
Base URL:https://api.k-v.ai
Authentication: Access Key (Required)
Request Specification
Headers
| Header | Type | Required | Description |
|---|---|---|---|
access-key | string | Yes | Your unique access-key generated from the platform UI |
Content-Type | string | Yes | Must be application/json |
Request Body
{
"doc_process_ids": [
"264dfa262b748d15ccbeaada89430c68"
],
"focus_areas": ["fee"],
"question_count": 2,
"model_data": {
"model_name": "gpt-5.1",
"api_key": ""
}
}Body Fields
| Field | Type | Required | Description |
|---|---|---|---|
doc_process_ids | array | Yes | Array of document IDs to generate FAQs from (obtained from Upload or List Documents APIs) |
focus_areas | array | No | List of focus areas to generate questions about (e.g., "pricing", "legal", "technical"). Leave empty for general FAQs |
question_count | integer | Yes | Number of questions to generate (minimum: 1, maximum: 10) |
model_data | object | Yes | AI model configuration |
model_data.model_name | string | Yes | AI model to use for FAQ generation (see supported models below) |
model_data.api_key | string | No | Your own LLM API key (leave empty to use platform's default keys) |
Supported AI Models
| Model Name | Provider |
|---|---|
gpt-5.1 | OpenAI |
gpt-5-mini | OpenAI |
claude-sonnet-4-5-20250929 | Anthropic |
gemini/gemini-2.5-flash-lite | |
gemini/gemini-2.5-pro | |
gemini/gemini-3-pro-preview | |
mistral/mistral-small-latest | Mistral AI |
mistral/mistral-medium-latest | Mistral AI |
llama3.1-70b | Meta |
Question Count Limits
- Minimum: 1 question
- Maximum: 10 questions per request
Using Your Own LLM API Keys
Platform Keys (Default):
{
"model_data": {
"model_name": "gpt-5.1",
"api_key": ""
}
}Your Own Keys:
{
"model_data": {
"model_name": "gpt-5.1",
"api_key": "sk-your-openai-api-key-here"
}
}Response Specification
Success Response (200 OK)
{
"data": {
"questions_answers": [
{
"question": "What is the prevailing party entitled to regarding attorneys' fees in any action relating to the Agreement?",
"answer": "In any action relating to the Agreement, the prevailing party is entitled to collect reasonable attorneys' fees and costs from the non-prevailing party in addition to any other recovery.",
"focus_area": "fee",
"page_numbers": [
"1"
],
"rank": 1,
"source": "Settlement Agreement (1).pdf",
"doc_hash": [
"264dfa262b748d15ccbeaada89430c68"
]
},
{
"question": "Who is responsible for paying attorneys' fees and costs incurred before the execution of the Settlement Agreement?",
"answer": "Each party is responsible for bearing its own attorneys' fees and costs arising from the actions of its own counsel incurred prior to the date of execution of the Agreement.",
"focus_area": "fee",
"page_numbers": [
"1"
],
"rank": 2,
"source": "Settlement Agreement (1).pdf",
"doc_hash": [
"264dfa262b748d15ccbeaada89430c68"
]
}
],
"is_sufficient": true,
"tokens": {
"input": 1501,
"output": 261,
"total": 1762
}
},
"message": "FAQs extracted successfully"
}Response Fields
| Field | Type | Description |
|---|---|---|
data | object | Response data object |
data.questions_answers | array | Array of generated Q&A pairs |
data.questions_answers[].question | string | Generated question |
data.questions_answers[].answer | string | AI-generated answer based on document content |
data.questions_answers[].focus_area | string | Focus area this Q&A relates to (if specified in request) |
data.questions_answers[].page_numbers | array | Page numbers where the answer information was found |
data.questions_answers[].rank | integer | Relevance ranking (1 = most relevant) based on cosine similarity and keyword matching |
data.questions_answers[].source | string | Original filename of the source document |
data.questions_answers[].doc_hash | array | Document process ID(s) |
data.is_sufficient | boolean | true if the number of generated questions matches question_count, false if fewer questions were generated |
data.tokens | object | Token usage for this request |
data.tokens.input | integer | Input tokens consumed |
data.tokens.output | integer | Output tokens generated |
data.tokens.total | integer | Total tokens used |
message | string | Human-readable response message |
Error Responses
401 Unauthorized
{
"data": {},
"message": "Invalid or missing access key"
}Cause: Missing or invalid access-key header
422 Unprocessable Entity - Invalid Model Name
{
"detail": [
{
"type": "literal_error",
"loc": [
"body",
"model_data",
"model_name"
],
"msg": "Input should be 'gpt-5-chat-latest', 'gpt-5.1', 'gpt-5-mini', 'claude-sonnet-4-5-20250929', 'gemini/gemini-2.5-flash-lite', 'mistral/mistral-small-latest', 'mistral/mistral-medium-latest', 'gemini/gemini-2.5-pro', 'gemini/gemini-3-pro-preview' or 'llama3.1-70b'",
"input": "",
"ctx": {
"expected": "'gpt-5-chat-latest', 'gpt-5.1', 'gpt-5-mini', 'claude-sonnet-4-5-20250929', 'gemini/gemini-2.5-flash-lite', 'mistral/mistral-small-latest', 'mistral/mistral-medium-latest', 'gemini/gemini-2.5-pro', 'gemini/gemini-3-pro-preview' or 'llama3.1-70b'"
}
}
]
}Cause: Invalid or unsupported model_name in model_data. See supported models list above.
400 Bad Request - Invalid Document IDs
{
"data": {},
"message": "Invalid docs selected"
}Causes: Missing or invalid doc_process_ids.
500 Internal Server Error - Invalid LLM API Key
{
"data": {},
"message": "litellm.AuthenticationError: AuthenticationError: OpenAIException - Incorrect API key provided: tyrdfuih**uhf7. You can find your API key at https://platform.openai.com/account/api-keys."
}Cause: The api_key provided in model_data is invalid or expired. Verify your LLM provider API key.
500 Internal Server Error - General Error
{
"data": {},
"message": "Something went wrong"
}Causes:
- LLM service temporarily unavailable
- Server-side processing error
422 Unprocessable Entity - Invalid Question Count
{
"detail": [
{
"type": "json_invalid",
"loc": [
"body",
121
],
"msg": "JSON decode error",
"input": {},
"ctx": {
"error": "Expecting value"
}
}
]
}Causes:
- Missing
question_countfield - Invalid
question_countvalue (must be 1-10) - Malformed JSON request body
Code Snippets
cURL
curl --location 'https://api.k-v.ai/api/agent/faq_generator' \
--header 'access-key: YOUR_ACCESS_KEY' \
--header 'Content-Type: application/json' \
--data '{
"doc_process_ids": [
"264dfa262b748d15ccbeaada89430c68"
],
"focus_areas": ["fee"],
"question_count": 2,
"model_data": {
"model_name": "gpt-5.1",
"api_key": ""
}
}'Python
import requests
import json
url = "https://api.k-v.ai/api/agent/faq_generator"
payload = json.dumps({
"doc_process_ids": [
"264dfa262b748d15ccbeaada89430c68"
],
"focus_areas": [
"fee"
],
"question_count": 2,
"model_data": {
"model_name": "gpt-5.1",
"api_key": ""
}
})
headers = {
'access-key': 'YOUR_ACCESS_KEY',
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers, data=payload)
print(response.text)JavaScript (Node.js)
const axios = require('axios');
let data = JSON.stringify({
"doc_process_ids": [
"264dfa262b748d15ccbeaada89430c68"
],
"focus_areas": [
"fee"
],
"question_count": 2,
"model_data": {
"model_name": "gpt-5.1",
"api_key": ""
}
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://api.k-v.ai/api/agent/faq_generator',
headers: {
'access-key': 'YOUR_ACCESS_KEY',
'Content-Type': 'application/json'
},
data: data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data, null, 2));
})
.catch((error) => {
console.log(error);
});Important Notes
- Document Processing: Only generate FAQs from documents with status: "processed"
- Question Limits: Maximum 10 questions per request
- Focus Areas: More specific focus areas yield better, more targeted questions
- Rankings: Lower rank numbers indicate higher relevance
- Sufficiency: Check
is_sufficientto know if all requested questions were generated
Next Steps
After generating FAQs:
- Review Quality: Verify generated Q&A accuracy against source documents
- Build Knowledge Base: Integrate FAQs into documentation or support systems
- Iterate: Refine focus areas and question counts based on results
Need Help? Contact support at support@k-v.ai