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

# Classify API

> Score prompts you format yourself with the Qwen3 reranker

`POST https://api.pinference.ai/api/v1/classify` runs [Qwen3 Reranker 0.6B](https://docs.primeintellect.ai/inference/models/qwen3-reranker) on prompts you format yourself. For each prompt it returns the model's probability of answering "yes" over "no", and the logit behind it. The [Rerank API](https://docs.primeintellect.ai/api-reference/inference-rerank.md) builds the same prompts from one query and a list of documents. Use classify to score pairs with different queries in one request, to write your own question, or to work with logits.

## Prompt format

Qwen publishes this prompt for the model. `{instruction}`, `{query}` and `{document}` are your text:

```text theme={null}
<|im_start|>system
Judge whether the Document meets the requirements based on the Query and the Instruct provided. Note that the answer can only be "yes" or "no".<|im_end|>
<|im_start|>user
<Instruct>: {instruction}
<Query>: {query}
<Document>: {document}<|im_end|>
<|im_start|>assistant
<think>

</think>

```

The prompt ends with two newlines after `</think>`. The Rerank API uses exactly this template, with the default instruction below. This function builds the same string:

```python theme={null}
DEFAULT_INSTRUCTION = "Given a web search query, retrieve relevant passages that answer the query"


def format_pair(query: str, document: str, instruction: str = DEFAULT_INSTRUCTION) -> str:
    return (
        "<|im_start|>system\nJudge whether the Document meets the requirements based on the Query "
        'and the Instruct provided. Note that the answer can only be "yes" or "no".<|im_end|>\n'
        "<|im_start|>user\n"
        f"<Instruct>: {instruction}\n<Query>: {query}\n<Document>: {document}"
        "<|im_end|>\n<|im_start|>assistant\n<think>\n\n</think>\n\n"
    )
```

The API sends each prompt to the model unchanged and reads the model's preference for "yes" over "no" at the prompt's last token. It doesn't check the format. A prompt that asks a yes-or-no question and ends with the exact assistant suffix, `<|im_start|>assistant\n<think>\n\n</think>\n\n`, gets a meaningful score. Before the suffix you can change the system message, the field labels and the instruction. A prompt without the suffix still returns a score, but that score has no defined meaning.

## Classify prompts

Send one prompt as a string, or up to 1,000 as an array. This example uses `format_pair` from above:

```python theme={null}
import os
import requests

prompts = [
    format_pair("Which planet is known as the Red Planet?", "Mars is often referred to as the Red Planet."),
    format_pair("Which planet is known as the Red Planet?", "Venus is often called Earth's twin because of its similar size."),
]
response = requests.post(
    "https://api.pinference.ai/api/v1/classify",
    headers={"Authorization": f"Bearer {os.environ['PRIME_API_KEY']}"},
    json={"model": "qwen/qwen3-reranker-0.6b", "input": prompts},
    timeout=120,
)
response.raise_for_status()
for item in response.json()["data"]:
    print(item["index"], item["label"], round(item["probs"][0], 3))
```

The request returns:

```json theme={null}
{
  "id": "req_...",
  "object": "list",
  "created": 1794009600,
  "model": "qwen/qwen3-reranker-0.6b",
  "data": [
    {"index": 0, "label": "yes", "probs": [0.997], "num_classes": 1, "logit": 5.73},
    {"index": 1, "label": "no", "probs": [0.025], "num_classes": 1, "logit": -3.65}
  ],
  "usage": {"prompt_tokens": 183, "total_tokens": 183, "completion_tokens": 0}
}
```

With curl, the prompt is a JSON string with its newlines and quotes escaped:

```bash theme={null}
export PRIME_API_KEY="your-api-key"

curl https://api.pinference.ai/api/v1/classify \
  -H "Authorization: Bearer $PRIME_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen/qwen3-reranker-0.6b",
    "input": "<|im_start|>system\nJudge whether the Document meets the requirements based on the Query and the Instruct provided. Note that the answer can only be \"yes\" or \"no\".<|im_end|>\n<|im_start|>user\n<Instruct>: Given a web search query, retrieve relevant passages that answer the query\n<Query>: Which planet is known as the Red Planet?\n<Document>: Mars is often referred to as the Red Planet.<|im_end|>\n<|im_start|>assistant\n<think>\n\n</think>\n\n"
  }'
```

To charge a team, add `-H "X-Prime-Team-ID: your-team-id"` to each request. See [team billing](https://docs.primeintellect.ai/inference/overview.md#team-billing).

## Request body

| Field | Type | Description |
| - | - | - |
| `model` | string | `qwen/qwen3-reranker-0.6b`. |
| `input` | string or array of strings | 1 to 1,000 prompts. Each must be a non-empty string of at most 32,768 tokens. A longer prompt is refused with a 400, and nothing is truncated. |

The whole request body can be at most 16 MiB.

## Response

| Field | Description |
| - | - |
| `id` | The request's ID, the same as the `X-Inference-Id` response header. Share it with support to trace a request. |
| `object` | Always `list`. |
| `created` | When the response was made, in Unix seconds. |
| `model` | The model ID from the request. |
| `data` | One entry per prompt, in request order. |
| `data[].index` | The prompt's position in `input`, counting from 0. |
| `data[].probs` | A one-element array with the probability, from 0 to 1, of "yes" over "no". |
| `data[].label` | `yes` when that probability is at least 0.5, otherwise `no`. |
| `data[].logit` | The model's raw score. The probability is its sigmoid. |
| `data[].num_classes` | Always 1. The model has one output. |
| `usage.prompt_tokens` | The tokens the model read, summed over all prompts. |
| `usage.total_tokens` | The same as `prompt_tokens`. |
| `usage.completion_tokens` | Always 0. Nothing is generated. |

Pick your own threshold for decisions. At a probability of 0.5 the model is undecided between "yes" and "no". When two probabilities both round to 1.0, compare their logits to order them.

## Usage and billing

Classification is billed on input tokens, `usage.prompt_tokens`, at \$0.20 per million. There is no output charge.

## Errors

Most errors return an `error` object with `message`, `type` and `code`, as the [Chat Completions API](https://docs.primeintellect.ai/api-reference/inference-chat-completions.md) does. A 401, a 404, or a 503 while authentication is unavailable returns a `detail` message instead.

| Status | Cause |
| - | - |
| 400 | `Invalid classify request (input).` means `input` is missing or empty, holds an empty string or a non-string, or holds a prompt longer than 32,768 tokens. `Invalid classify request (too_many_inputs).` means more than 1,000 prompts. |
| 401 | The API key is missing or invalid. |
| 402 | The billed account has insufficient funds. See [troubleshooting](https://docs.primeintellect.ai/inference/troubleshooting.md). |
| 404 | The request didn't name a reranker, or its body isn't JSON. A misspelled model ID, a missing `model` and a non-JSON body all return a `detail` of `Not Found`. This check comes before the API key check, so a wrong model with a bad key returns 404. |
| 413 | The request body is larger than 16 MiB. |
| 429 | The model has no free capacity. Retry after the number of seconds in the `Retry-After` header. |
| 502 or 503 | The model failed to answer. Retry the request. |

## vLLM compatibility

The request and response follow vLLM's classification API, with `logit` added.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.