Cohere Classify API

The Cohere Classify API performs text classification by assigning labels to input text based on provided examples. It can be used for sentiment analysis, content moderation, topic categorization, and other classification tasks. Developers provide a set of labeled examples along with texts to classify, and the API returns predicted labels with confidence scores for each input.

Business capability
Language & Document Understanding AE-110.40

Operations 1

POST /v1/classify Classify #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/cohere:classify-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

cohere-classify-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Cohere Classify API
  version: 1.0.0
servers:
- url: https://api.cohere.com
  description: production
tags:
- name: Classify
paths:
  /v1/classify:
    post:
      operationId: classify
      summary: Classify
      description: 'This endpoint makes a prediction about which label fits the specified text inputs best. To make a prediction, Classify uses the provided `examples` of text + label pairs as a reference.

        Note: Fine-tuned models trained on classification examples don''t require the `examples` parameter to be passed in explicitly.'
      parameters:
      - name: X-Client-Name
        in: header
        description: 'The name of the project that is making the request.

          '
        required: false
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/classify_Response_200'
        '400':
          description: "This error is returned when the request is not well formed. This could be because:\n  - JSON is invalid\n  - The request is missing required fields\n  - The request contains an invalid combination of fields\n"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClassifyRequestBadRequestError'
        '401':
          description: "This error indicates that the operation attempted to be performed is not allowed. This could be because:\n  - The api token is invalid\n  - The user does not have the necessary permissions\n"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClassifyRequestUnauthorizedError'
        '403':
          description: "This error indicates that the operation attempted to be performed is not allowed. This could be because:\n  - The api token is invalid\n  - The user does not have the necessary permissions\n"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClassifyRequestForbiddenError'
        '404':
          description: "This error is returned when a resource is not found. This could be because:\n  - The endpoint does not exist\n  - The resource does not exist eg model id, dataset id\n"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClassifyRequestNotFoundError'
        '422':
          description: "This error is returned when the request is not well formed. This could be because:\n  - JSON is invalid\n  - The request is missing required fields\n  - The request contains an invalid combination of fields\n"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClassifyRequestUnprocessableEntityError'
        '429':
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClassifyRequestTooManyRequestsError'
        '498':
          description: 'This error is returned when a request or response contains a deny-listed token.

            '
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClassifyRequestInvalidTokenError'
        '499':
          description: 'This error is returned when a request is cancelled by the user.

            '
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClassifyRequestClientClosedRequestError'
        '500':
          description: 'This error is returned when an uncategorised internal server error occurs.

            '
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClassifyRequestInternalServerError'
        '501':
          description: 'This error is returned when the requested feature is not implemented.

            '
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClassifyRequestNotImplementedError'
        '503':
          description: "This error is returned when the service is unavailable. This could be due to:\n  - Too many users trying to access the service at the same time\n"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClassifyRequestServiceUnavailableError'
        '504':
          description: "This error is returned when a request to the server times out. This could be due to:\n  - An internal services taking too long to respond\n"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClassifyRequestGatewayTimeoutError'
      deprecated: true
      requestBody:
        description: ''
        content:
          application/json:
            schema:
              type: object
              properties:
                inputs:
                  type: array
                  items:
                    type: string
                  description: 'A list of up to 96 texts to be classified. Each one must be a non-empty string.

                    There is, however, no consistent, universal limit to the length a particular input can be. We perform classification on the first `x` tokens of each input, and `x` varies depending on which underlying model is powering classification. The maximum token length for each model is listed in the "max tokens" column [here](https://docs.cohere.com/docs/models).

                    Note: by default the `truncate` parameter is set to `END`, so tokens exceeding the limit will be automatically dropped. This behavior can be disabled by setting `truncate` to `NONE`, which will result in validation errors for longer texts.'
                examples:
                  type: array
                  items:
                    $ref: '#/components/schemas/ClassifyExample'
                  description: 'An array of examples to provide context to the model. Each example is a text string and its associated label/class. Each unique label requires at least 2 examples associated with it; the maximum number of examples is 2500, and each example has a maximum length of 512 tokens. The values should be structured as `{text: "...",label: "..."}`.

                    Note: [Fine-tuned Models](https://docs.cohere.com/docs/classify-fine-tuning) trained on classification examples don''t require the `examples` parameter to be passed in explicitly.'
                model:
                  type: string
                  description: ID of a [Fine-tuned](https://docs.cohere.com/v2/docs/classify-starting-the-training) Classify model
                preset:
                  type: string
                  description: The ID of a custom playground preset. You can create presets in the [playground](https://dashboard.cohere.com/playground). If you use a preset, all other parameters become optional, and any included parameters will override the preset's parameters.
                  deprecated: true
                truncate:
                  $ref: '#/components/schemas/V1ClassifyPostRequestBodyContentApplicationJsonSchemaTruncate'
                  default: END
                  description: 'One of `NONE|START|END` to specify how the API will handle inputs longer than the maximum token length.

                    Passing `START` will discard the start of the input. `END` will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.

                    If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned.'
              required:
              - inputs
      security:
      - bearerAuth: []
      tags:
      - Classify
components:
  schemas:
    ClassifyRequestUnprocessableEntityError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: ClassifyRequestUnprocessableEntityError
    ClassifyRequestNotImplementedError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: ClassifyRequestNotImplementedError
    ClassifyRequestClientClosedRequestError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: ClassifyRequestClientClosedRequestError
    V1ClassifyPostResponsesContentApplicationJsonSchemaClassificationsItemsLabels:
      type: object
      properties:
        confidence:
          type: number
          format: double
      title: V1ClassifyPostResponsesContentApplicationJsonSchemaClassificationsItemsLabels
    ApiMeta:
      type: object
      properties:
        api_version:
          $ref: '#/components/schemas/ApiMetaApiVersion'
        billed_units:
          $ref: '#/components/schemas/ApiMetaBilledUnits'
        tokens:
          $ref: '#/components/schemas/ApiMetaTokens'
        cached_tokens:
          type: number
          format: double
          description: 'The number of prompt tokens that hit the inference cache.

            '
        warnings:
          type: array
          items:
            type: string
      title: ApiMeta
    V1ClassifyPostResponsesContentApplicationJsonSchemaClassificationsItemsClassificationType:
      type: string
      enum:
      - single-label
      - multi-label
      description: The type of classification performed
      title: V1ClassifyPostResponsesContentApplicationJsonSchemaClassificationsItemsClassificationType
    ClassifyRequestInvalidTokenError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: ClassifyRequestInvalidTokenError
    ClassifyRequestNotFoundError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: ClassifyRequestNotFoundError
    ClassifyRequestForbiddenError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: ClassifyRequestForbiddenError
    ClassifyRequestTooManyRequestsError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: ClassifyRequestTooManyRequestsError
    V1ClassifyPostResponsesContentApplicationJsonSchemaClassificationsItems:
      type: object
      properties:
        id:
          type: string
        input:
          type: string
          description: The input text that was classified
        prediction:
          type: string
          description: The predicted label for the associated query (only filled for single-label models)
          deprecated: true
        predictions:
          type: array
          items:
            type: string
          description: An array containing the predicted labels for the associated query (only filled for single-label classification)
        confidence:
          type: number
          format: double
          description: The confidence score for the top predicted class (only filled for single-label classification)
          deprecated: true
        confidences:
          type: array
          items:
            type: number
            format: double
          description: An array containing the confidence scores of all the predictions in the same order
        labels:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/V1ClassifyPostResponsesContentApplicationJsonSchemaClassificationsItemsLabels'
          description: A map containing each label and its confidence score according to the classifier. All the confidence scores add up to 1 for single-label classification. For multi-label classification the label confidences are independent of each other, so they don't have to sum up to 1.
        classification_type:
          $ref: '#/components/schemas/V1ClassifyPostResponsesContentApplicationJsonSchemaClassificationsItemsClassificationType'
          description: The type of classification performed
      required:
      - id
      - predictions
      - confidences
      - labels
      - classification_type
      title: V1ClassifyPostResponsesContentApplicationJsonSchemaClassificationsItems
    ApiMetaApiVersion:
      type: object
      properties:
        version:
          type: string
        is_deprecated:
          type: boolean
        is_experimental:
          type: boolean
      required:
      - version
      title: ApiMetaApiVersion
    ClassifyRequestBadRequestError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: ClassifyRequestBadRequestError
    ApiMetaTokens:
      type: object
      properties:
        input_tokens:
          type: number
          format: double
          description: 'The number of tokens used as input to the model.

            '
        output_tokens:
          type: number
          format: double
          description: 'The number of tokens produced by the model.

            '
      title: ApiMetaTokens
    V1ClassifyPostRequestBodyContentApplicationJsonSchemaTruncate:
      type: string
      enum:
      - NONE
      - START
      - END
      default: END
      description: 'One of `NONE|START|END` to specify how the API will handle inputs longer than the maximum token length.

        Passing `START` will discard the start of the input. `END` will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.

        If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned.'
      title: V1ClassifyPostRequestBodyContentApplicationJsonSchemaTruncate
    ClassifyRequestInternalServerError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: ClassifyRequestInternalServerError
    ClassifyRequestServiceUnavailableError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: ClassifyRequestServiceUnavailableError
    ClassifyRequestGatewayTimeoutError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: ClassifyRequestGatewayTimeoutError
    ClassifyExample:
      type: object
      properties:
        text:
          type: string
        label:
          type: string
      title: ClassifyExample
    ApiMetaBilledUnits:
      type: object
      properties:
        images:
          type: number
          format: double
          description: 'The number of billed images.

            '
        input_tokens:
          type: number
          format: double
          description: 'The number of billed input tokens.

            '
        image_tokens:
          type: number
          format: double
          description: 'The number of billed image tokens.

            '
        output_tokens:
          type: number
          format: double
          description: 'The number of billed output tokens.

            '
        search_units:
          type: number
          format: double
          description: 'The number of billed search units.

            '
        classifications:
          type: number
          format: double
          description: 'The number of billed classifications units.

            '
        pages:
          type: number
          format: double
          description: 'The number of billed pages parsed.

            '
      title: ApiMetaBilledUnits
    ClassifyRequestUnauthorizedError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: ClassifyRequestUnauthorizedError
    classify_Response_200:
      type: object
      properties:
        id:
          type: string
        classifications:
          type: array
          items:
            $ref: '#/components/schemas/V1ClassifyPostResponsesContentApplicationJsonSchemaClassificationsItems'
        meta:
          $ref: '#/components/schemas/ApiMeta'
      required:
      - id
      - classifications
      title: classify_Response_200
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer