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

# Text classification

`POST /classify`

## Request

- Base URL: `http://localhost:8000`
- URL: `http://localhost:8000/classify`
- Auth: none declared
- TypeScript: <https://skmtc.dev/friendli/apis/friendli-suite-api-reference/docs/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.

## Request body

- ContainerTextClassificationBody
  - `model` string, nullable: Routes the request to a specific adapter.
  - `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.

- ContainerTextClassificationSuccess
  - `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)
