Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Send Requests to Endpoints

The Endpoint overview provides access to the Inference Widget which can be used to send requests (see step 6 of Create an Endpoint). This allows you to quickly test your Endpoint with different inputs and share it with team members. In addition, the Inference Widget has an additional option for creating your request as a cURL command and copying it so you can easily share or use it.

copy curl

The cURL command for the request above should look like this. You’ll need to provide your user token which can be found in your Hugging Face account settings:

curl \
	-X POST \
	-d '{"inputs": "Deploying my first endpoint was an amazing experience."}' \
	-H "Authorization: Bearer <Token>"

The Endpoints API offers the same API definitions as the Inference API and the SageMaker Inference Toolkit. All the request payloads are documented in the Supported Tasks section.

This means for an NLP task, the payload is represented as the inputs key and additional pipeline parameters are included in the parameters key. You can provide any of the supported kwargs from pipelines as parameters. For image or audio tasks, you should send the data as a binary request with the corresponding mime type. Below is an example cURL for an audio payload:

curl --request POST \
  --url \
  --header 'Authorization: Bearer <Token>' \
  --header 'Content-Type: audio/x-flac' \
  --data-binary '@sample1.flac'

To use your cURL command as code, use the cURL Converter tool to quickly get started with the programming language of your choice.