How to use Question Answering API with JavaScript in 5 minutes?
Tags: javascript, ai, api, questionanswering
Published: 2023-01-11 13:45:12

_‍In this tutorial, you will learn how to use QA API in 5 minutes using JavaScript and Eden AI QA API. Eden AI provides an easy and developer-friendly API that allows you to ask questions based on texts._
## **What is Question Answering (QA)?**
[Question answering (QA)](https://www.edenai.co/feature/question-answering?referral=how-to-qa-javascript) is a type of artificial intelligence designed to answer questions asked by humans. QA systems are designed to understand natural language input and provide accurate and relevant responses to questions.

There are different types of QA systems, including rule-based systems which rely on a predetermined set of rules to provide answers, and machine learning-based systems which use algorithms to learn from a large dataset and provide answers based on that learning.

![Exemple of QA API response on Eden AI platform using OpenAI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yfza66hhr8pb8ooyc11x.png)
QA systems can be used in a variety of applications, such as customer service, online search engines, and educational platforms. They can help users find information quickly and accurately, saving time and effort.

## How to use Question Answering API with JavaScript
### **1. Set Axios and Node.js**

The first step to start using Question Answering API is to set Axios, a promise-based HTTP client for the browser and Node.js, that will allow you to call Eden AI API.

![https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/638f08881993bd518d9ca0cc_carbon(3).png](https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/638f08881993bd518d9ca0cc_carbon(3).png)


That's it! You are now ready to process text into Eden AI QA API.

You can process QA in many languages. To access the list of the supported languages  check out our documentation [here](https://docs.edenai.co/reference/text_question_answer_create?referral=how-to-qa-javascript).

### **2. Get a QA API Key on Eden AI**

To perform QA, you'll need to create an account on [Eden AI](https://app.edenai.run/user/register?referral=how-to-qa-javascript) for free. Then, you will be able to get your **API key** directly from the homepage with free credits offered by Eden AI.

![Eden AI - Get your API key for FREE](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qnwgu2aqx3hqh7i5w18t.png)

**[Get your API key for FREE](https://app.edenai.run/user/register?referral=how-to-qa-javascript)**

### **3. Start asking questions with the QA API**

Now that you have initialized the required JavaScript modules and got your API key, you will be able to search infos into your text. With Eden AI, you can choose from a wide range of different engines you want for Question Answering. You can see QA providers available on Eden AI on our documentation [here](https://docs.edenai.co/reference/text_question_answer_create?referral=how-to-qa-javascript).

Here is the JS code to configure the request:
![https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/639068edc2a607496521edbb_carbon(28).png](https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/639068edc2a607496521edbb_carbon(28).png)
Then, you'll need to launch the request and print the result:
![https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/638f6d1e1a7e8a83944abff6_carbon(16).png](https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/638f6d1e1a7e8a83944abff6_carbon(16).png)
Here is an example of a QA response:
![https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/6346d10fe0857172175016f4_qa-response.png](https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/6346d10fe0857172175016f4_qa-response.png)

## Benefits of using QA API with Eden AI

Using question answering with Eden AI API is quick and easy.

![Multiple AIs in one API - Eden AI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g9mq010ydwuuc8tosjbr.gif)

### Save time and cost

We offer a unified API for all providers: simple and standard to use, with a quick switch between providers and an access to the specificic features of each provider

### Easy to integrate

The JSON output format is the same for all suppliers thanks to Eden AI's standardisation work. The response elements are also standardised thanks to Eden AI's powerful matching algorithms.

### Customization

With Eden AI you have the possibility to integrate a third party platform: we can quickly develop connectors. To go further and customize your  Q&A request with specific parameters, check out our [documentation](https://docs.edenai.co/reference/text_question_answer_create?referral=how-to-qa-javascript).

**[Create your Account on Eden AI](https://app.edenai.run/user/register?referral=how-to-qa-javascript)**