Skip to main content
Our classification endpoints cover text, audio, image, token, video and zero-shot classification, exposed via simple JSON APIs.

Text classification

Here is an example of text classification: Parameters:
  • model: The model ID of the model you want to use
  • inputs: One or several texts to classify. To use text pairs, send a dict with {"text", "text_pair"} or a list of such dicts
  • top_k: How many results to return for each input (optional)
  • function_to_apply: How to convert raw logits to scores (optional, options: sigmoid, softmax, none)

Audio classification

Here is an example of audio classification: Parameters:
  • model: The model ID of the model you want to use
  • inputs: The audio data to classify. Can be raw waveform, bytes from an audio file, or a dict with sampling rate and raw audio
  • top_k: The number of top labels to return (optional)
  • function_to_apply: How to convert model outputs to scores (optional, options: sigmoid, softmax, none)

Image classification

Here is an example of image classification: Parameters:
  • model: The model ID of the model you want to use
  • inputs: The image or list of images to classify. Can be a URL, base64 string, file path, or PIL.Image
  • function_to_apply: How to convert model outputs to scores (optional, options: sigmoid, softmax, none)
  • top_k: The number of top labels to return (optional)
  • timeout: Maximum time in seconds to wait for fetching images from the web (optional)

Token classification

Here is an example of token classification: Parameters:
  • model: The model ID of the model you want to use
  • inputs: One or several texts for token classification

Video classification

Here is an example of video classification: Parameters:
  • model: The model ID of the model you want to use
  • inputs: A HTTP link or local path to a video, or a list of such inputs
  • top_k: The number of top labels to return (optional)
  • num_frames: The number of frames sampled from the video (optional)
  • frame_sampling_rate: The sampling rate used to select frames from the video (optional)
  • function_to_apply: How to convert model outputs to scores (optional, options: sigmoid, softmax, none)

Zero-shot text classification

Zero-shot classification lets you classify text into labels that the model has not been explicitly trained on, by providing your own candidate labels. Parameters:
  • model: The model ID of the model you want to use
  • sequences: The input text or list of texts to classify
  • candidate_labels: List of labels to classify the text against (required)
  • hypothesis_template: Template used to format each candidate label into a hypothesis for scoring (optional, default: This example is {})
  • multi_label: Whether multiple labels can be true for each input (optional)

Zero-shot audio classification

Here is an example of zero-shot audio classification: Parameters:
  • model: The model ID of the model you want to use
  • audios: One audio array or a list of audio arrays to classify
  • candidate_labels: Candidate labels to classify the audio against (required)
  • hypothesis_template: Template used with candidate labels (optional, default: This is a sound of {})

Zero-shot image classification

Here is an example of zero-shot image classification: Parameters:
  • model: The model ID of the model you want to use
  • image: An image or list of images to classify (URL, base64, file path, or PIL.Image)
  • candidate_labels: Candidate labels for the image (required)
  • hypothesis_template: Template used with candidate labels (optional, default: This is a photo of {})
  • timeout: Maximum time in seconds to wait for fetching images from the web (optional)

Object detection

Object detection uses the /v1/images/object-detection endpoint, not the classification routes. See the Images page for a full example with parameters and code samples. You can also try classification endpoints using the Playground. For endpoint details, see the API reference.