Create a batch or training job
POST https://weights.fyi/run/v1/jobs[?model=<model>]
Authorization: Bearer <token> scope: submit
Content-Type: application/x-ndjson | application/json
[Idempotency-Key: <your key>]
[traceparent: <W3C trace context>]- Available since
- 2026-10-08, when the service went live on weights.fyi/run. Running a fine-tuned model through it: not available yet (Bring your own model).
429 overloaded, thekindcheck and recovered retries. - Answer time
- synchronous for the upload only; the work goes on afterwards. 200,000 pages uploaded in 129 s on the live service on 2026-10-08, and 5,000 in 0.8 s in the readiness run of 2026-10-09, the customer journey script run against the live service with the model asleep.
Sends a batch of any size as one job and answers once every page is stored; follow it with GET /v1/jobs/{job_id}. When the model is ready the work starts at once; when not, the job waits with waiting_for: "model" while the model is started, at no charge. Moves to new hardware: Jobs, progress and results. A body with "kind": "finetune" has its own page.
The upload is all or nothing: a bad line, or more pages than your available credit pays at the quote, refuses it whole and keeps nothing. Starting the model costs nothing, so a start the job causes needs only credit above zero; admission also needs room under the token's daily cap. It is written with the job in one step, and NDJSON is checked again after its last line. A refusal can come before your upload is read to the end, so some clients report a reset connection; curl prints the answer.
Request
| Name | Where | Required | Meaning |
|---|---|---|---|
Authorization | header | yes | Bearer and a token with submit; counts against its request rate. |
Content-Type | header | yes | application/x-ndjson (also application/ndjson, application/jsonl, application/x-jsonlines): read as it arrives, stored in slices of 256 pages. Or application/json: read whole, at most 16 MiB. Others: 415. |
Idempotency-Key | header | no | One string per batch; a retry with it returns the first answer, never a second job. |
traceparent, tracestate | header | no | W3C trace context: the job joins your trace; an unusable one is ignored, reported in Weights-Notice. |
model | query | no | The model, for NDJSON. Default laya-page-role; if the body names one too, they must agree. |
text | NDJSON line | yes | The page's text, non-empty, fitting one call to the model (16 MiB with its envelope). Blank lines are skipped. |
id | NDJSON line | no | Your identifier, a string or a whole number, returned with the result. |
pages | JSON body | yes | A list of pages, each a string or an object with text and an optional id. |
model | JSON body | no | The model, as in the query string. |
schedule | JSON body | no | When this batch may ask for the model to be started; JSON bodies only. The window's end is until (ISO 8601 UTC; latest_start_at and complete_by are read the same way) or window_hours (above 0, at most 192; 4 when neither is given), in the future and at most 8 days ahead. Optional: not_before; max_hourly_usd_micros or max_hourly_usd; max_startup_usd_micros or max_startup_usd; estimated_duration_seconds (1 to 604,800); prefer_low_cost_window (default true); profile. Unknown keys are refused. The job is stored at once either way. |
Return value
201 Created when every page is stored; the job exists from then on.
| Field | Meaning |
|---|---|
job_id | The job's identifier, job_ and 24 hexadecimal characters. |
model | The model the job runs. |
status | QUEUED; later RUNNING, then SUCCEEDED, FAILED or CANCELLED. |
items_total | The pages in the job; results are numbered 1 to this, in your order. |
traceparent | The job's own trace context (version 00), to link from your traces. |
model_state | The model's state at admission, as GET /v1/jobs/{job_id} shows it. |
cold_start | Only when the model was not ready: its model_state and expected_ready_seconds. The start is free. |
schedule | Only for a scheduled job: state, eligible_to_wake (whether the job asked for a start now), reason, not_before, until, latest_safe_start, optimal_hours_utc and window_progress. |
Location (header) | The job's path, /run/v1/jobs/<job_id>. |
traceparent, tracestate, Weights-Notice (headers) | The job's trace context; your valid tracestate echoed; traceparent_ignored or tracestate_ignored when yours could not be used. |
Errors
| Status | Code | When it happens | What to do |
|---|---|---|---|
400 | invalid_json, invalid_body | The JSON body is not JSON, or not an object with a pages list. | Send {"pages": [...]}. |
400 | invalid_json_line, invalid_line | An NDJSON line is not JSON, or not an object; line gives its number, never its content. | Fix that line. Blank lines are skipped and are not an error. |
400 | empty_page, invalid_text, invalid_id | A page is empty, its text cannot be read as UTF-8, or its id is neither a string nor a whole number; index or line says which. | Fix the page, or leave it out. |
400 | page_too_large | One page does not fit one call to the model. | Shorten the page; the limit is above. |
400 | no_pages | The body holds no page at all. | Send at least one. |
400 | model_not_available, model_conflict | The model is not one you can run (available lists those you can), or the body and the query string name different models. | Name laya-page-role, once. |
400 | invalid_idempotency_key | The Idempotency-Key header is present but empty. | Send a key, or no header. |
400 | invalid_schedule, invalid_schedule_window | schedule is not an object, holds an unknown or invalid key, or its window does not end in the future within 8 days; message says which. | Fix the field named. |
400 | encrypted_envelope_required | The workspace requires confidential transport, which this call does not carry. | Use the workspace's confidential calls. |
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 cost more than your available credit; pages_allowed says how many it pays for, and pages_queued how many you already have waiting. | Send at most pages_allowed pages, or add credit first. |
402 | token_daily_cap | The token's spend cap for the UTC day would be passed; resets_at says when the day ends. | Wait for the reset, use another token, 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; for a suspended account, talk to us. |
409 | idempotency_key_in_progress | An earlier request with this key is still being read or stored. | Wait for its answer, then send again with the same key. |
413 | body_too_large, line_too_large | A JSON body, or one NDJSON line, is larger than the limit given in limit_bytes. | Send a large batch as NDJSON; split a page that is too long. |
415 | unsupported_media_type | The Content-Type is not one of those above; accepted lists them. | Set the header. |
422 | idempotency_key_reused | The key was used before for a different request. | Use a new key for new work. |
429 | rate_limited | The token sends work faster than its request rate. | Wait the Retry-After seconds, then send again with the same key. |
429 | overloaded | The service holds as much unfinished work as it takes, for all accounts together (reason: queue_full); nothing was accepted. | Wait the Retry-After seconds, then send again with the same key. |
400 | unsupported_job_kind | A JSON body names a kind other than laya.classify or finetune. | Leave kind out for pages. |
500 | internal_error | A fault on our side. | See "Retrying safely" below. |
Examples
{"text": "Senior data engineer, Utrecht. Apply today.", "id": "page-000001"}
{"text": "All open positions: 24 results. Filter by city or team.", "id": "page-000002"}curl -s -i "https://weights.fyi/run/v1/jobs?model=laya-page-role" \
-H "Authorization: Bearer $WEIGHTS_API_KEY" -H "Content-Type: application/x-ndjson" \
-H "Idempotency-Key: pages-batch-1" \
--data-binary @pages.ndjsonHTTP/1.1 201 Created
Content-Type: application/json
Location: /run/v1/jobs/job_5e7c50ca2489d324a215b0ba
traceparent: 00-7a4dfea36c0049bd6c1e4f5d1d1087e7-5d25160c17fbf86e-01
{
"job_id": "job_5e7c50ca2489d324a215b0ba",
"model": "laya-page-role",
"status": "QUEUED",
"items_total": 2,
"traceparent": "00-7a4dfea36c0049bd6c1e4f5d1d1087e7-5d25160c17fbf86e-01"
}Patterns
Retrying safely with Idempotency-Key
Send one key per batch with every attempt: a stored first attempt is replayed (Idempotent-Replayed: true), a refused one freed the key, one still being read answers 409. A 5xx after the body was read is replayed too, so check GET /v1/jobs before using a new key. Errors and limits has the full rules.
History
- 2026-10-08: live with JSON and NDJSON,
Idempotency-Key,traceparentand admission at the quote. - 2026-10-08: admission's quote keeps the reference speed until 2,048 pages are measured (one page in a 4.4 s call had admitted 6,676 of 200,000).
- 2026-10-08:
"kind": "finetune"starts a training job. - 2026-10-09 (merged): admission and the job in one step; NDJSON checked after its last line.
- 2026-10-10 implementation review:
429 overloaded,400 unsupported_job_kind, recovered retries. - 2026-11-16: a start is free and needs no credit of its own; documented
scheduleon JSON bodies and themodel_state,cold_startandscheduleanswer fields.
See also
GET /v1/jobs/{job_id}/results, POST /v1/classify, GET /v1/quote, Classify pages.