Feature extraction with Inference API in Javascript

Thanks @John6666!!! I’ve read it’s due to the pipeline_tag property of the model. It seems it must have the value ‘feature-extraction’.

This model worked to me:

async function query(data) {
	const response = await fetch(
		"https://api-inference.huggingface.co/models/facebook/bart-base",
		{
			headers: {
				Authorization: "Bearer hf_XXXXXXXXXXXX",
				"Content-Type": "application/json",
			},
			method: "POST",
			body: JSON.stringify(data),
		}
	);
	const result = await response.json();
	return result;
}

query({"inputs": "Today is a sunny day and I will get some ice cream."}).then((response) => {
	console.log(JSON.stringify(response));
});
1 Like