> ## Documentation Index
> Fetch the complete documentation index at: https://friendli.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Dedicated Text Classification

> Classify text into categories using your Friendli Dedicated Endpoint. Send text input and receive predicted labels with per-class probabilities.

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

To request successfully, it is mandatory to enter a **Personal API Key** (e.g. flp\_XXX) value in the **Bearer Token** field.
Refer to the [authentication section](/openapi/introduction#authentication) on our introduction page to learn how to acquire this variable and [visit here](https://friendli.ai/suite/~/setting/keys) to generate your API Key.


## OpenAPI

````yaml https://github.com/friendliai/friendli-openapi/raw/refs/heads/main/openapi.yaml post /dedicated/classify
openapi: 3.1.0
info:
  title: Friendli Suite API Reference
  description: This is an OpenAPI reference of Friendli Suite API.
  termsOfService: https://friendli.ai/terms-of-service
  contact:
    name: FriendliAI Support Team
    email: support@friendli.ai
  version: 0.1.0
servers:
  - url: https://api.friendli.ai
security: []
tags:
  - name: Serverless.Chat
  - name: Serverless.ToolAssistedChat
  - name: Serverless.Messages
  - name: Serverless.ChatRender
  - name: Serverless.Completions
  - name: Serverless.Token
  - name: Serverless.Audio
  - name: Serverless.Model
  - name: Serverless.Knowledge
  - name: Dedicated.Chat
  - name: Dedicated.Messages
  - name: Dedicated.ChatRender
  - name: Dedicated.Completions
  - name: Dedicated.Embeddings
  - name: Dedicated.TextClassification
  - name: Dedicated.Token
  - name: Dedicated.Image
  - name: Dedicated.Audio
  - name: Dedicated.Endpoint
  - name: Container.Chat
  - name: Container.Messages
  - name: Container.Completions
  - name: Container.TextClassification
  - name: Container.Token
  - name: Container.Image
  - name: Container.Audio
  - name: Cost
  - name: Dataset
  - name: File
paths:
  /dedicated/classify:
    post:
      tags:
        - Dedicated.Classification
      summary: Text classification
      description: Given a text input, the model classifies it into categories.
      operationId: dedicatedTextClassification
      parameters:
        - name: X-Friendli-Team
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: ID of team to run requests as (optional parameter).
            title: X-Friendli-Team
          description: ID of team to run requests as (optional parameter).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DedicatedTextClassificationBody'
      responses:
        '200':
          description: Successfully classified the text input.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DedicatedTextClassificationSuccess'
              examples:
                Example:
                  value:
                    data:
                      - index: 0
                        label: Positive
                        num_classes: 2
                        probs:
                          - 0.9
                          - 0.1
                    object: list
                    usage:
                      prompt_tokens: 5
                      total_tokens: 5
        '422':
          description: Unprocessable Entity
      security:
        - token: []
components:
  schemas:
    DedicatedTextClassificationBody:
      properties:
        model:
          type: string
          title: Model
          description: >-
            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.
          examples:
            - (endpoint-id)
        input:
          anyOf:
            - type: string
            - items:
                type: string
              type: array
            - type: 'null'
          title: Input
          description: >-
            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.
          examples:
            - I love programming.
        tokens:
          anyOf:
            - items:
                type: integer
              type: array
            - type: 'null'
          title: Tokens
          description: |-
            The tokenized prompt (i.e., input tokens).

            Either `input` or `tokens` field is required.
          examples:
            - 72
            - 1563
            - 2335
            - 13
      type: object
      required:
        - model
      title: DedicatedTextClassificationBody
      example:
        input: I love programming.
        model: (endpoint-id)
    DedicatedTextClassificationSuccess:
      $ref: '#/components/schemas/TextClassificationResult'
      title: DedicatedTextClassificationSuccess
    TextClassificationResult:
      properties:
        data:
          items:
            $ref: '#/components/schemas/BaseClassificationData'
          type: array
          title: Data
        object:
          type: string
          const: list
          title: Object
          description: The object type, which is always set to `list`.
        usage:
          $ref: '#/components/schemas/TextClassificationUsage'
      type: object
      required:
        - data
        - object
        - usage
      title: TextClassificationResult
    BaseClassificationData:
      properties:
        index:
          type: integer
          title: Index
          description: The index of the input in the list of inputs.
          examples:
            - 0
        label:
          type: string
          title: Label
          description: The predicted label for the input text.
          examples:
            - Positive
        num_classes:
          type: integer
          title: Num Classes
          description: The number of possible labels the model can predict.
          examples:
            - 2
        probs:
          items:
            type: number
          type: array
          title: Probs
          description: A list of logits for each possible label.
          examples:
            - - 0.1
              - 0.9
      type: object
      required:
        - index
        - label
        - num_classes
        - probs
      title: BaseClassificationData
    TextClassificationUsage:
      properties:
        prompt_tokens:
          type: integer
          title: Prompt Tokens
          description: Number of tokens in the input text.
          examples:
            - 10
        total_tokens:
          type: integer
          title: Total Tokens
          description: Total number of tokens used in the request.
          examples:
            - 10
      type: object
      required:
        - prompt_tokens
        - total_tokens
      title: TextClassificationUsage
  securitySchemes:
    token:
      type: http
      description: >-
        When using Friendli Suite API for inference requests, you need to
        provide a **Personal API Key** for authentication and authorization
        purposes.


        For more detailed information, please refer
        [here](https://friendli.ai/docs/openapi/introduction#authentication).
      scheme: bearer

````