---
title: "Text classification"
method: POST
path: "/dedicated/classify"
tags: ["Dedicated.Classification"]
---

# Text classification

`POST /dedicated/classify`

## Request

- Base URL: `https://api.friendli.ai`
- URL: `https://api.friendli.ai/dedicated/classify`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/friendli/apis/friendli-suite-api-reference/docs/dedicated/classify/post.ts> (a function with typed inputs; its response is checked against the schema)

Given a text input, the model classifies it into categories.

## Headers

- `X-Friendli-Team` string, nullable: ID of team to run requests as (optional parameter).

## Request body

- DedicatedTextClassificationBody
  - `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.
  - `input` union: 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.
    - string
    - string[]
  - `tokens` integer[], nullable: The tokenized prompt (i.e., input tokens). Either `input` or `tokens` field is required.

## Response `200`

Successfully classified the text input.

- DedicatedTextClassificationSuccess
  - `data` BaseClassificationData[], required
    - `index` integer, required: The index of the input in the list of inputs.
    - `label` string, required: The predicted label for the input text.
    - `num_classes` integer, required: The number of possible labels the model can predict.
    - `probs` number[], required: A list of logits for each possible label.
  - `object` 'list', required: The object type, which is always set to `list`.
  - `usage` TextClassificationUsage, required
    - `prompt_tokens` integer, required: Number of tokens in the input text.
    - `total_tokens` integer, required: Total number of tokens used in the request.

## Other responses

- `422`: Unprocessable Entity

---

[API](https://skmtc.dev/friendli/apis/friendli-suite-api-reference.md) - [All operations](https://skmtc.dev/friendli/apis/friendli-suite-api-reference/llms.txt) - [OpenAPI document](https://skmtc.dev/friendli/apis/friendli-suite-api-reference/revisions/38fb43993a11?raw)
