Hi,
Is there a JavaScript example for using inference API - 🤗 Accelerated Inference API — Api inference documentation
Hi,
Is there a JavaScript example for using inference API - 🤗 Accelerated Inference API — Api inference documentation
Hi @hgarg ,
Currently we don’t provide documentation for JS (or TS).
You could probably use simple fetch
:
const HF_API_TOKEN = "api_xxxx";
const model = "XXX"
const data = {inputs:"Something here"};
const response = await fetch(`https://api-inference.huggingface.co/models/${model}`, {headers: {"Authorization": `Bearer ${HF_API_TOKEN}`}, method: "POST", data:JSON.stringify(data)});
const data = await response.json()
should work.
Cheers,
Nicolas
thanks @Narsil
This happens every time, no matter the input. The same thing works fine when calling the API from python.
Same here! I get the “CNN.com will feature…” response for any input. Same outcome using sshleifer/distilbart-cnn-12-6
too. Only JS, not Py.
Hi, we added NodeJS to the documentation so you can check out working examples:
Does that work better ? I think my example had an error.
Yes, this returns the correct summary! Thanks for your help. Is there any way to specify the min_length of the summary with the API? Detailed parameters — Api inference documentation appears there’s just three unrelated options.
You can use it.
It’s an unofficial parameter because it’s defined in tokens
which are hard to use properly when you manipulate string. But before we have string oriented parameters you can use this one !
Cheers,
Nicolas