Tutorial
Document Processing
8 min reading

How to Extract Specific Information from Documents Using Question Answering with JavaScript

Summarize this article with:

summary
  • 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!

FAQ — Extract Specific Information from Documents

You need an API key from your chosen AI provider. Eden AI lets you access multiple providers with a single key, removing the need for separate vendor accounts.
Any language that supports HTTP requests works — Python, JavaScript, PHP, Ruby, Go, and more. Ready-to-use code snippets are available for the most common languages.
Most developers complete a basic integration in under an hour using standardized API endpoints and ready-to-use code examples.
Implement exponential backoff for rate limit errors and use try-catch blocks for network failures. Eden AI's built-in fallback routing automatically redirects requests if a provider is unavailable.
Eden AI supports GDPR-compliant provider filtering and does not store or reuse your data, ensuring compliance with European privacy regulations.

Similar articles

LLM API Security: How to Detect Abnormal Credential Usage
Tutorial
Generative AI
LLM API Security: How to Detect Abnormal Credential Usage
10/9/2026
·
Written byClément Moreau
How to Build an Open Source Software Factory
Tutorial
Generative AI
How to Build an Open Source Software Factory
9/29/2026
·
Written byClément Moreau
let’s start

Start building with Eden AI

A single interface to integrate the best AI technologies into your products.