> ## Documentation Index
> Fetch the complete documentation index at: https://weights.fyi/run/llms.txt

# POST /v1/classify

```text
POST https://weights.fyi/run/v1/classify[?model=<model>]
Authorization: Bearer <token>                    scope: submit
Content-Type: application/json
[Idempotency-Key: <your key>]
[Prefer: respond-async]
[traceparent: <W3C trace context>]
{"model": "<model>", "pages": ["<text>" | {"text": "<text>", "id": "<your id>"} | {<fetched page>}, ...],
 ["options": {"rejectIfBusy": false, "waitCold": false}], ["jurisdictions": ["EU"]], ["retain": "none"],
 ["version_id": "<version>"], ["calibration_sha256": "<64 hex>"]}
```

**Available since:** 2026-10-08, when the service went live on weights.fyi/run. Running your own fine-tuned `ft_…` model through it is not available yet ([Bring your own model](/run/docs/your-model.md)).

**Answer time:** Results within 300 s when ready (`200`); otherwise an immediate queued job (`202`) with `Retry-After`.

Classifies up to 256 pages. A ready model answers `200` with every result, the job id and cost. If it is stopped, starting, stopping, moving, becomes unready during the wait, or exceeds 300 s, you receive `202` with the job, model state and `Retry-After`. Work continues; a stopped model starts automatically. Poll [GET /v1/jobs/{job_id}](/run/docs/reference/jobs-get.md) for results. `Prefer: respond-async` answers `202` after admission even when ready.

Two kinds of model answer this call. `laya-page-role`, the default, is the five-label page classifier and takes page text, as above. A specialist your catalog lists with `classify` among its `operations` takes fetched pages, is answered in the call by its own pool with no job queued, and returns its own `result`; fetched pages sent to `laya-page-role` reach a specialist of that id where your workspace has one. `Retry-After` is the time until the model is expected ready, else the job's expected finish, else 144 s; in the readiness run of 2026-10-09 a call to the sleeping model had its result 160.4 s later. Admission is that of [POST /v1/jobs](/run/docs/reference/jobs-create.md); a move is told in [Jobs, progress and results](/run/docs/jobs.md).

## Request

| Name | Where | Required | Meaning |
|---|---|---|---|
| `Authorization` | header | yes | `Bearer` and your token. The token needs the `submit` scope, and the call counts against the token's request rate. |
| `Content-Type` | header | yes | `application/json`. The body is read whole and may be at most 16 MiB. |
| `Idempotency-Key` | header | no | Any string you choose, one per piece of work. A retry with the same key returns the first answer, marked `Idempotent-Replayed: true`, and makes no second job. |
| `Prefer` | header | no | `respond-async` returns the admitted job immediately instead of waiting for results. |
| `traceparent`, `tracestate` | header | no | A W3C trace context. When it is valid, the job and its work join your trace; when it is not, it is ignored and `Weights-Notice` says so. |
| `pages` | body | yes | 1 to 256 pages, all of one kind. **Text:** a string, or an object with `text` and an optional `id` (a string or a whole number); each non-empty once trimmed and fitting one call to the model, 16 MiB with its envelope. **Fetched:** an object with `url` and `final_url` (http or https), `http_status`, `content_type`, `sha256` (of the fetched bytes, 64 lowercase hex, checked) and `body_b64` (those bytes, base64), plus an optional `id`: for a specialist that reads the page as it was fetched. |
| `model` | body or query | no | The model to run: `laya-page-role` by default, or any model your catalog lists with `classify` among its `operations` ([GET /v1/models](/run/docs/reference/models.md)). If you name it in both places, they must agree. |
| `options.rejectIfBusy` | body | no | `true` to be refused with `429 overloaded` when the model is not ready or every call slot is taken, instead of the `202` and a queued job; `false`, the default, keeps today's behaviour. The name and the behaviour follow Cloudflare's Workers AI. |
| `options.waitCold` | body | no | `true` keeps waiting for the results while the model starts, within the same 300 s, instead of answering `202` at once. Also `?wait_cold=true` or the header `X-Weights-Wait-Cold: true`. |
| `jurisdictions` | body, or header `X-Weights-Jurisdictions` | no | Country codes, `EU` or `EEA`, as a list or comma-separated: the call runs only where the model's known location is inside them. The body can narrow the header, never widen it. |
| `retain` | body, `?retain=none`, or header `X-Weights-Retain` | no | `none`, the only value: zero retention, no copy of the answer is kept. The call must then be answered in the call, so not with `Prefer: respond-async` or a `schedule`, and only by a specialist pool that answers at once. A retry with the same `Idempotency-Key` answers `409 replay_not_retained` with the first answer's SHA-256, never the answer itself. |
| `version_id`, `calibration_sha256` | body | no | Pin a registered version of the model, and its calibration's digest (64 lowercase hex). The version must have a bundle the service executes; its results carry both values. |
| `encrypted_envelope` | body | in a confidential workspace | The sealed request ([POST /v1/workspaces](/run/docs/reference/workspaces-post.md)); a plain call there answers `400 encrypted_envelope_required`. |

## Return value

**200 OK** when the model was ready and every page finished within the wait.

| Field | Meaning |
|---|---|
| `job_id` | The job's identifier, `job_` followed by 24 hexadecimal characters. |
| `status` | The job's final status: `SUCCEEDED` when every page has a result, `FAILED` when every page failed. |
| `model` | The model that classified the pages. |
| `traceparent` | The job's trace context, also sent as a header. |
| `results` | One result per page, in the order you sent them, each as below. |
| `cost` | The job's cost so far: `usd_micros`, the amount in micro-dollars; `final`, `true` once the job has ended (its pages are charged as their results land); `basis`, one sentence on how it is counted; `pages_counted` and `prices`; and `runs`, the runs of the model the job was served in, each with `started_at`, `ended_at` (`null` while the run goes on), `usd_micros` and `final`. |

Each result:

| Field | Meaning |
|---|---|
| `seq` | The page's number in the job, from 1, in the order you sent the pages. |
| `id` | Your own id for the page, as text, or `null` if you sent none. |
| `input_sha` | The SHA-256 of the page's UTF-8 text, in hexadecimal. |
| `input_sha` | For a fetched page, the SHA-256 of the fetched bytes. |
| `label` | The page's role: `detail`, `listing`, `landing`, `not_vacancy` or `unresolved`. A specialist or a registered version answers its own labels here, or `null` when it gives none. |
| `probabilities` | The model's calibrated probability for each of its labels, or `null`. |
| `version_id`, `calibration_sha256` | From a registered version only: the version that classified the page, and its calibration's digest. |
| `result` | From a specialist or a registered version only: its own answer for the page, an object whose fields are that model's (labels for a classifier, extracted fields for an extractor). A page it could not read is `failed`, error `unresolved`, with `{"unresolved": "<reason>"}`. |
| `status` | `done` for a page with a result; `failed` for a page the model could not classify. |
| `error` | The reason a page failed, as a code, or `null`. |

A specialist pool's `200` has no job: `status`, `model`, `request_id`, `results`, and the charged tokens as `usage`.

**202 Accepted** when the results are not in the answer.

| Field | Meaning |
|---|---|
| `job_id` | The job's identifier; the `Location` header holds its path. |
| `status` | `QUEUED` or `RUNNING`. |
| `model` | The model the job runs. |
| `traceparent` | The job's trace context. |
| `model_state` | The model's state: `state`, one of the codes of [GET /v1/endpoint](/run/docs/reference/endpoint.md), and `expected_ready_seconds`, the estimate until it is ready. it also carries `since`, `message` (the state in a sentence), `queued_work_preserved` and `recovery_action`, as [GET /v1/endpoint](/run/docs/reference/endpoint.md) does. |
| `retry_after_seconds` | The same figure as the `Retry-After` header: how long to wait before you read the job. |

## Errors

| Status | Code | When it happens | What to do |
|---|---|---|---|
| `400` | `invalid_json`, `invalid_body` | The body is not JSON, or not an object with a `pages` list. | Send `{"pages": [...]}`. |
| `400` | `empty_page`, `invalid_text`, `invalid_id` | A page is empty or unreadable, or its `id` is neither a string nor a whole number; `index` says which, from 0. | Fix the page. |
| `400` | `page_too_large` | One page does not fit a call to the model. | Shorten it. |
| `400` | `no_pages`, `too_many_pages` | No page at all, or more than `max`. | Send 1 to 256 pages; use [POST /v1/jobs](/run/docs/reference/jobs-create.md) for more. |
| `400` | `model_not_available`, `model_conflict` | A model you cannot run (`available` lists those you can), or two different models named. | Name one model your catalog lists, once. |
| `400` | `invalid_body` | Text pages sent to a specialist that reads fetched pages only; `expected` shows the fetched shape. | Send fetched pages. |
| `400` | `invalid_jurisdictions` | `jurisdictions` is not a list of country codes, `EU` or `EEA`. | Fix the list. |
| `400` | `invalid_retain`, `retain_none_requires_sync` | `retain` is not `none`, or it came with `Prefer: respond-async` or a `schedule`. | Send `none`, and wait for the answer. |
| `400` | `encrypted_envelope_required` | A plain call from a confidential workspace. | Send the sealed request. |
| `409` | `jurisdiction_refused` | No eligible capacity has a known location inside `jurisdictions`. | Widen them, or wait. |
| `409` | `retain_none_unavailable` | Zero retention was asked of the five-label classifier or of a registered version's bundle, which both keep results. | Use a specialist pool that answers in the call, or drop `retain`. |
| `409` | `replay_not_retained` | A retry of a zero-retention call; `response_sha256` is the first answer's digest. | Keep the first answer yourself. |
| `409` | `version_not_executable`, `bundle_not_executable` | The pinned version has no bundle the service can execute. | Pin another version, or none. |
| `401` | `unauthorized`, `invalid_token`, `token_revoked`, `token_expired` | No token, or one that does not work (any more). | Use a valid token. |
| `402` | `no_credit` | Your available credit is zero or less. | Add credit. |
| `503` | `price_unavailable` | A price cannot be set right now; nothing was admitted or charged. | Send again after `Retry-After`. |
| `402` | `queue_exceeds_credit` | The pages, with your pages already waiting, cost more than your available credit; `pages_allowed` says how many it pays for. | Send fewer pages, or add credit. |
| `402` | `token_daily_cap` | The token's spend cap for the UTC day would be passed; `resets_at` says when it resets. | Wait, or raise the cap on your panel. |
| `403` | `scope_required`, `account_suspended` | The token lacks `submit`, or the account is suspended. | Use a token with `submit`. |
| `409` | `idempotency_key_in_progress` | A request with this key is still running. | Wait for it, then send again with the same key. |
| `413` | `body_too_large` | The body is larger than `limit_bytes`. | Send fewer or shorter pages. |
| `422` | `idempotency_key_reused` | The key was used for a different request. | Use a new key. |
| `429` | `rate_limited` | The token sends work faster than its request rate. | Wait `Retry-After` seconds and send again with the same key. |
| `429` | `overloaded` | The service holds as much unfinished work as it takes (`reason: queue_full`, or `concurrency_limit` for single calls), or you sent `rejectIfBusy` and the model is not ready (`capacity_unavailable`, with the model's state in `recovery`) or busy (`concurrency_limit`). Nothing was accepted. | Wait `Retry-After` seconds and send again. |
| `400` | `invalid_options` | `options.rejectIfBusy` or `options.waitCold` is not `true` or `false`. | Send booleans. |
| `500` | `internal_error` | A fault on our side. | See [Errors and limits](/run/docs/errors.md#retries). |

## Examples

Two pages while the model is ready:

```sh
curl -s -i https://weights.fyi/run/v1/classify \
  -H "Authorization: Bearer $WEIGHTS_API_KEY" -H "Content-Type: application/json" \
  -H "Idempotency-Key: first-call-2" \
  -d '{"model": "laya-page-role", "pages": [{"text": "Senior data engineer, Utrecht. Apply today.", "id": "p1"}, "All open positions: 24 results. Filter by city or team."]}'
```

```text
HTTP/1.1 200 OK
Content-Type: application/json
traceparent: 00-bab95d936f1061465864482cc2494dce-1c86517d7012893b-01

{
  "job_id": "job_a9f211eac4050afa06474fa0",
  "status": "SUCCEEDED",
  "model": "laya-page-role",
  "traceparent": "00-bab95d936f1061465864482cc2494dce-1c86517d7012893b-01",
  "results": [
    {
      "seq": 1,
      "id": "p1",
      "input_sha": "0e9d03893cf9b487b46c69b99a496bc5859890f184509f4a97d5cc1f3bb3cb8f",
      "label": "detail",
      "probabilities": {"detail": 0.912, "listing": 0.041, "landing": 0.022, "not_vacancy": 0.019, "unresolved": 0.006},
      "status": "done",
      "error": null
    },
    {
      "seq": 2,
      "id": null,
      "input_sha": "831b6f101815b4590022ea3ffed074ed5af35cfca7ecf93dda70861e50e913e4",
      "label": "listing",
      "probabilities": {"detail": 0.027, "listing": 0.893, "landing": 0.061, "not_vacancy": 0.011, "unresolved": 0.008},
      "status": "done",
      "error": null
    }
  ],
  "cost": {
    "usd_micros": 7,
    "final": true,
    "basis": "the sum of the job's charges so far, each posted as its results landed, at the prices it was admitted at",
    "prices": {"usd_per_1m_pages": 2.288525},
    "pages_counted": 3,
    "runs": [
      {"started_at": "2026-10-09T08:28:09.790Z", "ended_at": null, "usd_micros": 7, "final": false}
    ]
  }
}
```

## Patterns

### Handling both answers

On `200`, take the results; on `202`, wait `Retry-After`, then poll the job no faster than every 5 s and read its results once final. For a burst, start the model with [POST /v1/endpoint/warm](/run/docs/reference/endpoint-warm.md) and keep calling; each page renews its 144 s ready.

## History

- 2026-10-08: live: results in the answer while ready, `202` with `Retry-After` otherwise, `Idempotency-Key`, `traceparent`; `runs` in the cost.
- 2026-10-08: `Retry-After` uses the median start of hardware that served the model before (the first live run said 440 s for a 132 s start).
- 2026-10-10 implementation review: `rejectIfBusy`, `429 overloaded`, `model_state` with `since`, `message`, `queued_work_preserved` and `recovery_action`, recovered retries.
- 2026-11-16: fetched pages, `waitCold`, `jurisdictions`, `retain` and version pins documented.

## See also

[POST /v1/jobs](/run/docs/reference/jobs-create.md), [GET /v1/jobs/{job_id}/results](/run/docs/reference/jobs-results.md), [Classify pages](/run/docs/classify.md), [Errors and limits](/run/docs/errors.md).
