---
title: "Label Existing Classification"
method: POST
path: "/generate/classification/label-existing"
tags: ["generate"]
---

# Label Existing Classification

`POST /generate/classification/label-existing`

Label existing texts for classification tasks.

Args:
    request: Classification labeling request with texts and labels.
    auth: Authenticated user context.

Returns:
    GenerateResponse with classified samples and optional dataset info.

Raises:
    HTTPException: 400 if no valid inputs or dataset validation fails.
    HTTPException: 500 on labeling failure.

## Request body

- LabelExistingClassificationRequest — Label existing texts for classification
  - `user_id` string, nullable — User ID (optional, uses authenticated user if not provided)
  - `labels` string[], required — List of classification labels
  - `inputs` string[], required — List of texts to label
  - `domain_description` string, nullable — Domain description for generation context
  - `seed` integer, nullable — Random seed for reproducibility
  - `class_balance` object, nullable — Optional class distribution (must sum to 1.0)
  - `session_id` string, nullable — Session ID for log streaming
  - `config_num_examples` integer — Number of examples to generate for config
  - `temperature` number — Generation temperature
  - `batch_size` integer — Number of samples to generate per API call
  - `constraints` ConstraintRequest[], nullable — Custom constraints
    - `description` string, required — Constraint description
    - `choices` string[], nullable — Optional list of choices for this constraint
    - `weights` number[], nullable — Optional weights for choices (must align with choices length)
    - `probability` number, nullable — Optional probability (0.0-1.0) for this constraint
  - `multi_label` boolean — Enable multi-label classification (samples can have multiple labels)
  - `save_dataset` boolean — Save generated dataset to S3 and database
  - `dataset_name` string, nullable — Name for the saved dataset (required if save_dataset=True)
  - `project_id` string, uuid, nullable — Project ID to assign the dataset to

## Response `200`

Successful Response

- GenerateResponse — Generation response
  - `success` boolean, required
  - `data` object[], required
  - `count` integer, required
  - `task_type` string, required
  - `token_usage` integer, nullable — Estimated tokens used for generation
  - `dataset` object, nullable — Dataset info if saved to S3/database

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/pioneer/apis/brain-api.md) · [All operations](https://skmtc.net/pioneer/apis/brain-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/pioneer/brain-api/revisions/31dfe831e079/schema)
