API Documentation
/v1/categorize

/v1/categorize

This endpoint provides a categorization function based on the given input. It supports various categorization modes through different parameters.

Request: POST /v1/categorize

Headers

  • Content-Type: application/json
  • Authorization: Bearer <your_api_key>

Body

The request accepts a JSON body with the following properties:

FieldTypeDescriptionRequired
promptstringThe input text that needs to be categorized.Yes
categoriesstring[]The categories to use for categorization.Yes
allow_null_categorybooleanIf set to true, allows uncategorized entries.No
allow_multiple_classesbooleanIf set to true, allows entries to belong to multiple categories.No

Example

{
  "prompt": "Sample prompt text",
  "categories": ["category1", "category2", "category3"],
  "allow_null_category": true,
  "allow_multiple_classes": false
}

Response

The response from the server includes the following fields:

FieldTypeDescription
choicesstring[]The categories chosen for the given prompt.

If there was a problem with the request, you will receive an error message instead.

Example

{
  "choices": ["category1", "category2"]
}

Error Handling

In case of a bad request or authentication error, you will receive an HTTP status code other than 200, and a descriptive error message.

Example

{
  "error": "Invalid API Key provided.",
  "code": 401
}