Summarize this article with:
- Document Question Answering allows the extraction of specific information from text-based documents using a query.
- Simply provide the text you want to search, and the system will use optical character recognition (OCR) technology to scan the document and extract the information you need.
- Eden AI's Document QA API makes it easy to extract precise answers from documents.
- You'll need an Eden AI account and API key.
- With Eden AI's standardized API and ready-to-use code examples, most developers can integrate the feature in under an hour.
In this tutorial, you will learn how to use the Document Question Answering API in 5 minutes using JavaScript. Eden AI provides an easy and developer-friendly API that allows you to extract specific information from your documents.
What is Document Question Answering API?
Document Question Answering allows the extraction of specific information from text-based documents using a query.
Simply provide the text you want to search, and the system will use optical character recognition (OCR) technology to scan the document and extract the information you need.
Getting Started
1. Sign Up: Create a free account here to get your API key.
Implementation in JavaScript
const axios = require('axios').default;
const fs = require('fs');
const headers = { Authorization: 'Bearer YOUR_API_TOKEN' };
async function main() {
// 1. Upload your document (PDF, JPG, PNG...)
const form = new FormData();
form.append('file', new Blob([fs.readFileSync('invoice.pdf')], { type: 'application/pdf' }), 'invoice.pdf');
const upload = await axios.post('https://api.edenai.run/v3/upload', form, { headers });
// 2. Ask your questions, and get the answers as JSON
const response = await axios.post('https://api.edenai.run/v3/chat/completions', {
model: 'google/gemini-2.5-flash',
messages: [{
role: 'user',
content: [
{ type: 'text', text: 'What is the total? What is the due date?' },
{ type: 'file', file: { file_id: upload.data.file_id } }
]
}],
response_format: {
type: 'json_schema',
json_schema: {
name: 'answers',
schema: {
type: 'object',
properties: { total: { type: 'string' }, due_date: { type: 'string' } },
required: ['total', 'due_date']
}
}
}
}, { headers });
console.log(JSON.parse(response.data.choices[0].message.content));
}
main().catch(e => console.error(e.response ? e.response.data : e));- Upload: POST https://api.edenai.run/v3/upload sends your file to Eden AI and returns a file_id.
- Questions: document question answering now goes through a multimodal LLM. The file_id and your questions are sent to https://api.edenai.run/v3/chat/completions, here with google/gemini-2.5-flash.
- response_format: a JSON schema with one property per question, so the answers come back as JSON. On a sample invoice, the script prints
{ total: '$93.50', due_date: 'January 31, 2016' }.
Conclusion
Eden AI's Document QA API makes it easy to extract precise answers from documents. Sign up free and start today!

.jpg)

