POST
/
v1
/
classification
import { JigsawStack } from "jigsawstack";

const jigsaw = JigsawStack({ apiKey: "your-api-key" });

const response = await jigsaw.classification({
  "dataset": [
        {
              "type": "image",
              "value": "https://jigsawstack.com/preview/classification-example-1.jpg"
        },
        {
              "type": "image",
              "value": "https://jigsawstack.com/preview/classification-example-2.jpg"
        }
  ],
  "labels": [
        {
              "type": "text",
              "value": "hotdog"
        },
        {
              "type": "text",
              "value": "not a hotdog"
        }
  ]
})
{
  "success": true,
  "predictions": [
        "not a hotdog",
        "hotdog"
  ],
  "_usage": {
        "input_tokens": 69,
        "output_tokens": 14,
        "inference_time_tokens": 3942,
        "total_tokens": 4025
  }
}

Body

dataset
array
required
Array of data samples to classify. Each sample contains:
  • type: Either “text” or “image”
  • value: The content to classify (text string or image URL)
Maximum of 32 samples allowed per request. At least 1 sample required.
All items in the dataset must be of the same type. You cannot mix text and image samples in a single request.
labels
array
required
Array of classification labels. Each label contains:
  • key: Optional identifier for the label
  • type: Either “text” or “image”
  • value: The label content (text string or image URL)
At least 2 labels required.
multiple_labels
boolean
default:"false"
Whether to allow multiple labels per classification result. When false, each prediction returns a single label. When true, each prediction can return multiple labels.
x-api-key
string
required
Your JigsawStack API key

Response

success
boolean
Indicates whether the call was successful.
_usage
object
Usage information for the API call.
predictions
array[string | string[]]
Array of classification results. Each element corresponds to a dataset sample:
  • If multiple_labels is false: Each element is a string (single label)
  • If multiple_labels is true: Each element is an array of strings (multiple labels)
import { JigsawStack } from "jigsawstack";

const jigsaw = JigsawStack({ apiKey: "your-api-key" });

const response = await jigsaw.classification({
  "dataset": [
        {
              "type": "image",
              "value": "https://jigsawstack.com/preview/classification-example-1.jpg"
        },
        {
              "type": "image",
              "value": "https://jigsawstack.com/preview/classification-example-2.jpg"
        }
  ],
  "labels": [
        {
              "type": "text",
              "value": "hotdog"
        },
        {
              "type": "text",
              "value": "not a hotdog"
        }
  ]
})
{
  "success": true,
  "predictions": [
        "not a hotdog",
        "hotdog"
  ],
  "_usage": {
        "input_tokens": 69,
        "output_tokens": 14,
        "inference_time_tokens": 3942,
        "total_tokens": 4025
  }
}