# T5 question answering inference

**URL:** <https://discuss.huggingface.co/t/t5-question-answering-inference/31106>\
**Category:** Beginners\
**Created:** [February 4, 2023, 1:34pm UTC](https://discuss.huggingface.co/t/t5-question-answering-inference/31106 "2023-02-04T13:34:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![badriyaharef](https://avatars.discourse-cdn.com/v4/letter/b/b3f665/32.png) [@badriyaharef](https://discuss.huggingface.co/u/badriyaharef)\
**Post date:** [February 4, 2023, 1:34pm UTC](https://discuss.huggingface.co/t/t5-question-answering-inference/31106/1 "2023-02-04T13:34:12Z")

</div>

Hello everyone, I am trying to use inference API javascript to get answers from the model  
This is the javascript code :

async function query(data) {  
const response = await fetch(  
“[https://api-inference.huggingface.co/models/MaRiOrOsSi/t5-base-finetuned-question-answering](https://api-inference.huggingface.co/models/MaRiOrOsSi/t5-base-finetuned-question-answering)”,  
{  
headers: { Authorization: “Bearer api\_org\_XXseeBTxOZyGRxnhrJpurjCJvgsLowXYDU” },  
method: “POST”,  
body: JSON.stringify(data),  
}  
);  
const result = await response.json();  
return result;  
}

const { messages, user\_text } = inputs

let past\_user\_inputs = ;  
let generated\_responses = ;

for (const message of messages){  
past\_user\_inputs.push(message.user\_input)  
generated\_responses.push(message.response)  
}

// Prepare Query  
const queryInput = {“inputs”: {  
“past\_user\_inputs”: past\_user\_inputs,  
“generated\_responses”: generated\_responses,  
“text”: user\_text  
}  
}

let newMessages = […messages]  
newMessages.push({  
datetime: moment().format(),  
})

const response = await query(queryInput);  
console.log(JSON.stringify(response));  
let result =   
console.log(response.conversation.generated\_responses.length)  
for (var i = 0; i \< response.conversation.generated\_responses.length; i++) {  
result.push({  
datetime: newMessages[i].datetime,  
id: String(i + 1),  
response: response.conversation.generated\_responses[i],  
user\_input: response.conversation.past\_user\_inputs[i],  
})  
}

console.log(“result”, result)  
return { result };  
but when I run the program I get the error:

{“error”:" `args[0]`: {‘past\_user\_inputs’: , ‘generated\_responses’: , ‘text’: ‘hello’} have the wrong format. The should be either of type `str` or type `list`",“warnings”:[“There was an inference error: `args[0]`: {‘past\_user\_inputs’: , ‘generated\_responses’: , ‘text’: ‘hello’} have the wrong format. The should be either of type `str` or type `list`”]}

Any idea on how to solve this?

Thanks a bunch

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [April 11, 2025, 4:57am UTC](https://discuss.huggingface.co/t/t5-question-answering-inference/31106/3 "2025-04-11T04:57:00Z")

</div>

It doesn’t look like there’s anything wrong with it, but there may be no “Content-Type”: “application/json” in the header.

> **[Question Answering](https://huggingface.co/docs/inference-providers/tasks/question-answering)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

```js
			headers: {
				Authorization: "Bearer hf_xxxxxxxxxxxxxxxxxxxxxxxx",
				"Content-Type": "application/json",
			},

```
