Skip to main content
POST
/
dedicated
/
classify
Text classification
curl --request POST \
  --url https://api.friendli.ai/dedicated/classify \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "input": "I love programming.",
  "model": "(endpoint-id)"
}
'
{
  "data": [
    {
      "index": 0,
      "label": "Positive",
      "num_classes": 2,
      "probs": [
        0.9,
        0.1
      ]
    }
  ],
  "object": "list",
  "usage": {
    "prompt_tokens": 5,
    "total_tokens": 5
  }
}
Given a text input, the model classifies it into categories. To request successfully, it is mandatory to enter a Friendli Token (e.g. flp_XXX) value in the Bearer Token field. Refer to the authentication section on our introduction page to learn how to acquire this variable and visit here to generate your token.

Authorizations

Authorization
string
header
required

When using Friendli Suite API for inference requests, you need to provide a Friendli Token for authentication and authorization purposes.

For more detailed information, please refer here.

Headers

X-Friendli-Team
string | null

ID of team to run requests as (optional parameter).

Body

application/json
model
string
required

ID of target endpoint. If you want to send request to specific adapter, use the format "YOUR_ENDPOINT_ID:YOUR_ADAPTER_ROUTE". Otherwise, you can just use "YOUR_ENDPOINT_ID" alone.

Example:

"(endpoint-id)"

input

Input text to classify, encoded as a string or array of strings. To classify multiple inputs in a single request, pass an array of strings.

Either input or tokens field is required.

Example:

"I love programming."

tokens
integer[] | null

The tokenized prompt (i.e., input tokens).

Either input or tokens field is required.

Example:

72

Response

Successfully classified the text input.

data
BaseClassificationData · object[]
required
object
string
required

The object type, which is always set to list.

Allowed value: "list"
usage
TextClassificationUsage · object
required