Documentation

You send text and some possible answers. The Classifier returns probabilities.

Contents

Getting started

You send text and the choices you will accept. The Classifier returns a probability for each choice. It does not write an answer.

Create an account on the registration page, choose a plan on the billing page, then create a key in API keys. The key is shown once.

Python client

pip install --upgrade 'theclassifier>=0.2.0'

Set CLASSIFIER_API_KEY to your dashboard API key. The service URL defaults to https://api.theclassifier.ai; override it with CLASSIFIER_API_PUBLIC_URL or the base_url constructor argument.

import os
from theclassifier import Classifier

classifier = Classifier(api_key=os.environ["CLASSIFIER_API_KEY"])
result = classifier.classify(
    "Please close my account.",
    choices=["cancellation", "billing", "none"],
)
print(result["results"][0]["selected"]["choice"])

The API is used by default. Add mode="local" to run on your computer after installing local support. See train, save and load your own model for the full workflow.

Direct HTTP requests

Request · POST /v1/classify

POST https://api.theclassifier.ai/v1/classify
Authorization: Bearer CLASSIFIER_API_KEY
Content-Type: application/json

{
  "state": "Please cancel my account at the end of the month.",
  "questions": [{
    "question": "What is the customer asking for?",
    "choices": [
      {"choice": "billing", "criteria": "Questions about charges, invoices, or payments."},
      {"choice": "technical support", "criteria": "Help with a product fault or technical issue."},
      {"choice": "cancellation", "criteria": "A request to close an account or end a subscription."},
      {"choice": "fraud", "criteria": "Suspected unauthorised activity or identity theft."},
      {"choice": "none", "criteria": "None of the other categories apply."}
    ]
  }],
  "version": "latest", "domain": "general"
}

Example response · results only; timing, token usage and request metadata are omitted.

{
  "results": [{
    "question": "What is the customer asking for?",
    "selected": {"choice": "cancellation", "score": 0.982},
    "detailed_results": [
      {"choice": "cancellation", "score": 0.982},
      {"choice": "billing", "score": 0.011},
      {"choice": "technical support", "score": 0.004},
      {"choice": "fraud", "score": 0.002},
      {"choice": "none", "score": 0.001}
    ]
  }]
}

Read results[0].selected.choice for the highest-scoring answer. detailed_results contains every supplied choice, sorted by score. Include a none choice explicitly when a request might not fit the other categories.

Individual inference in Python

Install requests and pandas with pip install requests pandas, and set your API key in the CLASSIFIER_API_KEY environment variable.

import os
import requests

API_URL = "https://api.theclassifier.ai/v1/classify"
HEADERS = {"Authorization": f"Bearer {os.environ['CLASSIFIER_API_KEY']}"}
QUESTION = {
    "question": "What is the customer asking for?",
    "choices": [
        {"choice": "billing", "criteria": "Questions about charges or payments."},
        {"choice": "technical support", "criteria": "Help with a technical issue."},
        {"choice": "cancellation", "criteria": "Requests to close an account."},
        {"choice": "fraud", "criteria": "Suspected unauthorised activity."},
        {"choice": "none", "criteria": "None of the other categories apply."},
    ],
}


def classify(text):
    response = requests.post(
        API_URL,
        headers=HEADERS,
        json={"state": text, "questions": [QUESTION], "version": "latest", "domain": "general"},
        timeout=(10, 60),  # Connection and read timeouts, in seconds.
    )
    response.raise_for_status()
    return response.json()["results"][0]


result = classify("Please cancel my account at the end of the month.")
print(result["selected"]["choice"])
print(result["selected"]["score"])
# All choices and their scores:
print(result["detailed_results"])

Example output · illustrative scores

cancellation
0.982
[{'choice': 'cancellation', 'score': 0.982}, {'choice': 'billing', 'score': 0.011}, {'choice': 'technical support', 'score': 0.004}, {'choice': 'fraud', 'score': 0.002}, {'choice': 'none', 'score': 0.001}]

Batch inference with pandas

This standalone example includes the headers, question and choices, and applies classification to each row in a DataFrame. This sends one request per row, sequentially. On HTTP 429, it waits for the API’s requested delay and retries the same row, up to five times.

import os
import time
import requests
import pandas as pd

API_URL = "https://api.theclassifier.ai/v1/classify"
HEADERS = {
    "Authorization": f"Bearer {os.environ['CLASSIFIER_API_KEY']}",
    "Content-Type": "application/json",
}
QUESTION = {
    "question": "What is the customer asking for?",
    "choices": [
        {"choice": "billing", "criteria": "Questions about charges or payments."},
        {"choice": "technical support", "criteria": "Help with a technical issue."},
        {"choice": "cancellation", "criteria": "Requests to close an account."},
        {"choice": "fraud", "criteria": "Suspected unauthorised activity."},
        {"choice": "none", "criteria": "None of the other categories apply."},
    ],
}


def classify(text):
    response = requests.post(
        API_URL,
        headers=HEADERS,
        json={"state": text, "questions": [QUESTION], "version": "latest", "domain": "general"},
        timeout=(10, 60),  # Connection and read timeouts, in seconds.
    )
    response.raise_for_status()
    return response.json()["results"][0]



def classify_with_retry(text, max_retries=5):
    for attempt in range(max_retries + 1):
        try:
            return classify(text)
        except requests.HTTPError as error:
            response = error.response
            if response.status_code != 429 or attempt == max_retries:
                raise

            # The API sends Retry-After as seconds.
            retry_after = response.headers.get("Retry-After")
            try:
                wait = float(retry_after)
            except (TypeError, ValueError):
                # Fall back to the JSON delay, then exponential backoff.
                try:
                    milliseconds = response.json()["error"]["retry_after_ms"]
                    wait = float(milliseconds) / 1000
                except (ValueError, TypeError, KeyError):
                    wait = min(2 ** attempt, 60)

            time.sleep(max(wait, 1) + 0.1)


df = pd.DataFrame({
    "text": [
        "Please cancel my account.",
        "Why was I charged twice?",
        "The app crashes when I sign in.",
    ]
})

# Keep the full result, then extract the winning label and score.
df["result"] = df["text"].apply(classify_with_retry)
df["label"] = df["result"].apply(lambda result: result["selected"]["choice"])
df["score"] = df["result"].apply(lambda result: result["selected"]["score"])
print(df[["text", "label", "score"]].to_string(index=False))

Example output · illustrative scores

                           text             label score
      Please cancel my account.      cancellation 0.982
       Why was I charged twice?           billing 0.975
The app crashes when I sign in. technical support 0.963

Other errors, including exhausted credits (403), stop the run immediately. If the retry limit is reached, the last error is raised. This example does not save completed rows, so rerunning it sends those requests again.

Python references: Requests and pandas Series.apply.

Use /v1/classify for one or several questions, with optional criteria for each choice. See the API section for the full response, limits and billing.

Choose a model

Use general unless you have a reason to choose a specialist. You still provide the possible answers; the model chooses from that list.

domain selects the area of use. version selects a release and defaults to latest. Currently latest, 1.1 and 1.1.0 refer to model release 1.1.0.

DomainUse it for
generalGeneral text classification. Start here if you are unsure.
intentWhat a customer wants to do, such as cancel an account or ask about a charge.
sentimentWhether language is positive, neutral or negative.
triageSupport ticket categories.
causeThe issue or reason reported in a complaint.
codifyProduct and service categories.
complaintsProducts and issues in financial complaints.
starsOne-to-five review ratings.
result = classifier.classify(
    "Great service!",
    choices=["positive", "neutral", "negative"],
    domain="sentiment",
    version="1.1",
)

Find published versions and domains

from theclassifier import available_versions, available_domains

print(available_versions())
print(available_domains(version="latest"))

These functions read the release catalog on Hugging Face. Local model downloads use a fixed revision for each version and reuse downloaded files. New models do not require a package update. Use offline=True to read a previously cached catalog.

These models are available for local use. The hosted service lists its currently available models at GET https://api.theclassifier.ai/v1/versions.

See the full evaluation results to help choose a model, then check it on examples from your own work.

Pricing

We charge A$1 per billion input tokens. Output tokens are free.

Token pricing · per billion tokens
ModelInputOutput
The ClassifierA$1A$0
Jev 1.13US$42US$0

Plans

Tester has no monthly fee: pay for the input tokens you use, with a 30 requests/minute limit. Standard is A$5/month with A$5 in credits and 60 requests/minute. Production is A$50/month with A$50 in credits and 300 requests/minute.

Shared API plans · Australian dollars
Per accountTesterStandardProduction
MonthlyA$0A$5A$50
Request limit30 / min60 / min300 / min
Included creditsA$0A$5A$50
Token billingPay per tokenFrom creditsFrom credits
SupportDocumentationDocumentationEmail

Your plan limits both the number of requests you can send and the GPU time they use, across all your API keys. Longer inputs and more choices take more compute, so the request limit alone does not determine your throughput.

Request and GPU allowances refill continuously; usage credits renew with your billing period. If you reach a limit, the API returns 429 with a retry time. Shared capacity can also return 503 when busy. Read the API limits.

Tester usage is billed monthly, with no included credits. On Standard and Production, tokens spend your included credits; there are no automatic overage charges or top-ups. If those credits run out, requests pause until renewal or an upgrade. Contact us for more capacity.

Create an account

Dedicated deployments and custom training

For organisations that need their own deployment or a model trained for a specific task, we can discuss dedicated capacity, custom training, and integration work. Pricing depends on what you need.

Contact us

API

Base URL https://api.theclassifier.ai. Send Authorization: Bearer CLASSIFIER_API_KEY. Keys are created in the dashboard and shown once.

Classify

POST https://api.theclassifier.ai/v1/classify takes a record and one or more closed questions. Use this when an agent needs more than one decision, or when a choice needs a short criteria string.

POST https://api.theclassifier.ai/v1/classify
Authorization: Bearer CLASSIFIER_API_KEY
Content-Type: application/json

{
  "state": "Customer: you charged me twice.",
  "questions": [
    {
      "question": "What is the customer trying to do?",
      "choices": [
        {"choice": "duplicate_charge", "criteria": "They say they were billed more than once."},
        {"choice": "none", "criteria": "Not a billing problem."}
      ]
    }
  ]
}

Example response (selected fields):

{
  "results": [
    {
      "question": "What is the customer trying to do?",
      "selected": {"choice": "duplicate_charge", "score": 0.9821},
      "detailed_results": [
        {"choice": "duplicate_charge", "score": 0.9821},
        {"choice": "none", "score": 0.0179}
      ]
    }
  ],
  "version": "1.1.0",
  "domain": "general",
  "input_tokens": 2150,
  "gpu_service_ms": 40,
  "queue_wait_ms": 0,
  "request_id": "9a814034d2804ed1a72aa568cfe051a2"
}

Read results[0].selected.choice. Scores are rounded to 4 decimal places and sum to about 1 within that question. If the top two scores are close, ask a clarifying question. input_tokens, gpu_service_ms, queue_wait_ms, and request_id describe this call.

version selects the model release: latest (default), 1.1 or 1.1.0. domain selects the model’s area of use and defaults to general. Responses report the resolved version and domain.

Python

import requests

response = requests.post(
    "https://api.theclassifier.ai/v1/classify",
    headers={"Authorization": "Bearer CLASSIFIER_API_KEY"},
    json={
        "state": "Please cancel my account.",
        "questions": [{
            "question": "What is the customer asking for?",
            "choices": [
                {"choice": "cancellation", "criteria": "Requests to close an account."},
                {"choice": "none", "criteria": "None of the other choices apply."},
            ],
        }],
        "version": "latest", "domain": "general",
    },
)
response.raise_for_status()
result = response.json()
print(result["results"][0]["selected"]["choice"])

Example output

cancellation

MCP

Streamable HTTP at https://api.theclassifier.ai/mcp. The tools are classify, versions and health.

In ChatGPT, connect The Classifier and sign in with your Classifier account. Approve access to classify text and list models. Calls use your account’s usual credits and limits. Revoke access under API keys by revoking “ChatGPT connection”.

Other MCP clients can use an API key:

{
  "mcpServers": {
    "the-classifier": {
      "url": "https://api.theclassifier.ai/mcp",
      "headers": {"Authorization": "Bearer CLASSIFIER_API_KEY"}
    }
  }
}

Limits

Two limits apply at once. Tokens are not one of them.

  • Burst: how many requests you can send in a short window.
  • Compute: a rolling budget of GPU service time, in milliseconds.

A short classification is about 40 ms and 2,150 input tokens. A long one is about 109 ms and 11,750 input tokens.

If the shared machine is briefly busy, the request waits. If the wait would be longer than the queue limit, the API returns 503 instead of letting latency grow.

When you are over your own limit, the API returns 429:

{
  "error": {
    "type": "rate_limit_exceeded",
    "message": "Compute allowance exceeded.",
    "retry_after_ms": 840,
    "limit_type": "compute"
  }
}

Headers on limited and successful calls:

Retry-After
X-RateLimit-Limit
X-RateLimit-Remaining
X-RateLimit-Reset
X-Compute-Limit
X-Compute-Remaining

Billing

Tester is A$0/month with 30 requests/minute and input-token usage billed monthly at A$1 per billion. It has no included credits. Standard is A$5/month; Production is A$50/month. The paid plans include A$5 or A$50 in credits, respectively. Input tokens spend these credits at A$1 per billion; output tokens cost A$0. Credits renew each billing period. No credit top-ups or automatic overage charges apply to the paid plans.

See current allowances. Limits refill continuously across the account's API keys. Retry after the indicated delay when you receive 429. Exhausted credits return 403 with error type credits_exhausted; wait for renewal, upgrade, or contact us for more capacity. Existing legacy subscriptions retain their original terms.

Use cases

Send the text and the choices you will accept. Include none when the text might not fit the list.

Route an agent

Route an agent by scoring its allowed tools. Send the user message and the tool list. The Classifier returns a probability for each tool and does not call one.

The agent already has a fixed set of tools, queues, or next steps. You need it to pick one before it does anything else.

Call

POST https://api.theclassifier.ai/v1/classify

{
  "state": "Please cancel my account at the end of the month.",
  "questions": [
    {
      "question": "Which label fits?",
      "choices": [
        {
          "choice": "billing"
        },
        {
          "choice": "technical support"
        },
        {
          "choice": "cancellation"
        },
        {
          "choice": "fraud"
        }
      ]
    }
  ]
}

Example response (results only). Scores are a relative fit among the choices you sent.

{
  "results": [
    {
      "question": "Which label fits?",
      "selected": {
        "choice": "cancellation",
        "score": 0.982
      },
      "detailed_results": [
        {
          "choice": "cancellation",
          "score": 0.982
        },
        {
          "choice": "billing",
          "score": 0.011
        },
        {
          "choice": "technical support",
          "score": 0.004
        },
        {
          "choice": "fraud",
          "score": 0.003
        }
      ]
    }
  ]
}

Read the highest score. If the top two are close, ask a clarifying question.

When this does not fit

The agent still has to write the reply, look something up, or choose a tool that is not on the list.

The full call, including the requests example, is on the API section.

Classify a ticket

Classify a support ticket into the queues you already have. Send the ticket text and the queue names. The Classifier returns a probability for each queue.

A new ticket has to land in one of your existing queues, such as billing, technical support, cancellation, or fraud.

Call

POST https://api.theclassifier.ai/v1/classify

{
  "state": "I was charged twice for the same invoice and the second payment failed.",
  "questions": [
    {
      "question": "Which label fits?",
      "choices": [
        {
          "choice": "billing"
        },
        {
          "choice": "technical support"
        },
        {
          "choice": "cancellation"
        },
        {
          "choice": "fraud"
        }
      ]
    }
  ]
}

Example response (results only). Scores are a relative fit among the choices you sent.

{
  "results": [
    {
      "question": "Which label fits?",
      "selected": {
        "choice": "billing",
        "score": 0.941
      },
      "detailed_results": [
        {
          "choice": "billing",
          "score": 0.941
        },
        {
          "choice": "fraud",
          "score": 0.032
        },
        {
          "choice": "technical support",
          "score": 0.018
        },
        {
          "choice": "cancellation",
          "score": 0.009
        }
      ]
    }
  ]
}

Read the highest score. If the top two are close, ask a clarifying question.

When this does not fit

You want the model to draft the reply, extract an order number, or invent a queue you did not send.

The full call, including the requests example, is on the API section.

Score an LLM response

Score an LLM response against a fixed list of judgments. Send the reply as the text and the judgments as the choices. The Classifier returns a probability for each judgment.

You already know the findings you care about, such as followed the policy, refused, or made up a fact.

Call

POST https://api.theclassifier.ai/v1/classify

{
  "state": "The assistant said the customer's plan renews on the 3rd. The account record shows the 30th.",
  "questions": [
    {
      "question": "Which label fits?",
      "choices": [
        {
          "choice": "followed the policy"
        },
        {
          "choice": "refused"
        },
        {
          "choice": "made up a fact"
        }
      ]
    }
  ]
}

Example response (results only). Scores are a relative fit among the choices you sent.

{
  "results": [
    {
      "question": "Which label fits?",
      "selected": {
        "choice": "made up a fact",
        "score": 0.91
      },
      "detailed_results": [
        {
          "choice": "made up a fact",
          "score": 0.91
        },
        {
          "choice": "followed the policy",
          "score": 0.06
        },
        {
          "choice": "refused",
          "score": 0.03
        }
      ]
    }
  ]
}

Read the highest score. If the top two are close, ask a clarifying question.

When this does not fit

You want a written critique, a rewrite, or a score on a scale you did not define as choices.

The full call, including the requests example, is on the API section.

Rank a lead

Rank a lead into the bands you already use. Send the lead note and the bands, such as hot, warm, and cold. The Classifier returns a probability for each band.

Sales already has a fixed set of bands and a note, email, or form reply to sort.

Call

POST https://api.theclassifier.ai/v1/classify

{
  "state": "We need this in production next month and have budget approved.",
  "questions": [
    {
      "question": "Which label fits?",
      "choices": [
        {
          "choice": "hot"
        },
        {
          "choice": "warm"
        },
        {
          "choice": "cold"
        }
      ]
    }
  ]
}

Example response (results only). Scores are a relative fit among the choices you sent.

{
  "results": [
    {
      "question": "Which label fits?",
      "selected": {
        "choice": "hot",
        "score": 0.86
      },
      "detailed_results": [
        {
          "choice": "hot",
          "score": 0.86
        },
        {
          "choice": "warm",
          "score": 0.12
        },
        {
          "choice": "cold",
          "score": 0.02
        }
      ]
    }
  ]
}

Read the highest score. If the top two are close, ask a clarifying question.

When this does not fit

You want a written summary of the lead or a score that is not one of your bands.

The full call, including the requests example, is on the API section.

Detect an objection

Detect which objection is in a reply. Send the reply and the objections you handle, plus none. The Classifier returns a probability for each objection.

A sales or support reply should be matched to an objection you already know how to answer.

Call

POST https://api.theclassifier.ai/v1/classify

{
  "state": "This looks useful, but we cannot move until security reviews the vendor.",
  "questions": [
    {
      "question": "Which label fits?",
      "choices": [
        {
          "choice": "price"
        },
        {
          "choice": "timing"
        },
        {
          "choice": "security review"
        },
        {
          "choice": "none"
        }
      ]
    }
  ]
}

Example response (results only). Scores are a relative fit among the choices you sent.

{
  "results": [
    {
      "question": "Which label fits?",
      "selected": {
        "choice": "security review",
        "score": 0.94
      },
      "detailed_results": [
        {
          "choice": "security review",
          "score": 0.94
        },
        {
          "choice": "timing",
          "score": 0.03
        },
        {
          "choice": "price",
          "score": 0.02
        },
        {
          "choice": "none",
          "score": 0.01
        }
      ]
    }
  ]
}

Read the highest score. If the top two are close, ask a clarifying question.

When this does not fit

There is no fixed list of objections, or you want the model to write the answer to the objection.

The full call, including the requests example, is on the API section.

Choose between fixed alternatives

Choose between fixed alternatives. Send the text and every answer you will accept. The Classifier returns a probability for each alternative and cannot add one.

The decision is closed. The answer has to be one of a list you wrote.

Call

POST https://api.theclassifier.ai/v1/classify

{
  "state": "The shipment arrived damaged and I want a replacement, not a refund.",
  "questions": [
    {
      "question": "Which label fits?",
      "choices": [
        {
          "choice": "replace"
        },
        {
          "choice": "refund"
        },
        {
          "choice": "none"
        }
      ]
    }
  ]
}

Example response (results only). Scores are a relative fit among the choices you sent.

{
  "results": [
    {
      "question": "Which label fits?",
      "selected": {
        "choice": "replace",
        "score": 0.93
      },
      "detailed_results": [
        {
          "choice": "replace",
          "score": 0.93
        },
        {
          "choice": "refund",
          "score": 0.05
        },
        {
          "choice": "none",
          "score": 0.02
        }
      ]
    }
  ]
}

Read the highest score. If the top two are close, ask a clarifying question.

When this does not fit

The answer is open-ended, or the correct label might sit outside the list. Add a none choice when that is possible.

The full call, including the requests example, is on the API section.

Train, save and load your own model

Start with a table of text and the correct category for each row. Training creates a new classifier; your original stays unchanged. Everything runs on your computer.

Install training support

pip install --upgrade 'theclassifier[train]>=0.2.0'

Train from a table

Your DataFrame needs two columns: text and its correct label. Both contain strings. Include at least two different labels.

import os
import pandas as pd
from theclassifier import Classifier

original = Classifier(api_key=os.environ["CLASSIFIER_API_KEY"])

df = pd.DataFrame({
    "text": ["Please close my account.", "I was charged twice."],
    "label": ["cancellation", "billing"],
})

fine_tuned = original.fine_tune(data=df)
result = fine_tuned.classify("Please cancel my account.")
print(result["results"][0]["selected"]["choice"])

The new classifier remembers your labels and runs locally automatically. NumPy also works: pass data=df.to_numpy(), with text in the first column and label in the second.

The example shows the format. Use representative examples for training, then check predictions on separate examples the model has not trained on. More training does not automatically mean better results.

Save it

fine_tuned.save("~/Downloads/my_classifier")

This writes a complete model and its labels. The folder must be empty. Saving leaves the model in memory unchanged, so you can keep using it.

Load it later

loaded = Classifier(
    api_key=os.environ["CLASSIFIER_API_KEY"],
    model_path="~/Downloads/my_classifier",
)
result = loaded.classify("Please cancel my account.")

Keep the whole saved folder together. Loading restores the labels and uses your computer automatically. The API key is required by the constructor but is not sent or checked during local use.

Optional settings

Defaults use the latest general model and choose an available NVIDIA GPU, otherwise the CPU. To choose a specialist model, set domain when creating the original classifier. version="1.1" pins model release 1.1.0.

original = Classifier(
    api_key=os.environ["CLASSIFIER_API_KEY"],
    domain="sentiment",
    version="1.1",
    device="cpu",
)

# A one-step check before a longer training run:
fine_tuned = original.fine_tune(data=df, max_steps=1, grad_accum=1)

You can also set epochs to control passes through the data, or provide a question and explicit choices. You do not need these settings to get started.

For the research behind the model, see the technical paper.

Machines can read llms.txt and sitemap.xml.