Get the "view API" link to show up at the bottom of my page?
I’ve created a simple space using gradio atVectorAPI - a Hugging Face Space by summerstayI want to be able to use this as an API.Some similar pages have a “view API” link at the bottom of the page.I don’t know why my page doesn’t have one. What do I need to change?
2022-06-08T18:19:44Z
hello@summerstayPlease update your Gradio to3.0.13, the latest version has the API feature re-enabled. The view API link it’s not yet there, but you can still use it.For the Interface Class the default endpoint will be/api/predict/here is an example using Javascript.ps. I’ve also send you a PR suggestionsummerstay/vectorAPI · upgrade your gradio for API supportfetch("https://hf.space/embed/summerstay/vectorAPI/api/predict", {
  method: "POST",
  body: JSON.stringify({ data: [" Hello World"] }),
  headers: { "Content-Type": "application/json" },
})
  .then(function (response) {
    return response.json();
  })
  .then(function (json_response) {
    console.log(json_response);
  });
2022-06-17T04:15:47Z
Hi.Is it possible to have this API when using blocks? I guess not but just want to make sure.I think this API is quite useful in some use cases.
2022-06-17T23:03:25Z
hi@mikeee, yes in the latest Gradio version the API is enabled for blocks! it’s not well documented yet but here is a functional examplegradio/run.py at main · gradio-app/gradio · GitHubYou can have multiple api endpoints, for instance, for each click associated to an processing function you can have anapi_namexray_run.click(
                xray_model,
                inputs=[disease, xray_scan],
                outputs=xray_results,
                status_tracker=xray_progress,
                api_name="xray_model"
            )orct_run.click(
                ct_model,
                inputs=[disease, ct_scan],
                outputs=ct_results,
                status_tracker=ct_progress,
                api_name="ct_model"
            )then your API ends points will belocalhost:7860/api/xray_model
localhost:7860/api/ct_model
2022-06-19T07:06:19Z
Very cool thanks for the reply. I’ll give blocks a spin.