Documentation
Jobs and results
View .mdOpenAPI

Create a batch or training job

POSThttps://weights.fyi/run/v1/jobsscope: submit
text
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, the kind check 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

NameWhereRequiredMeaning
AuthorizationheaderyesBearer and a token with submit; counts against its request rate.
Content-Typeheaderyesapplication/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-KeyheadernoOne string per batch; a retry with it returns the first answer, never a second job.
traceparent, tracestateheadernoW3C trace context: the job joins your trace; an unusable one is ignored, reported in Weights-Notice.
modelquerynoThe model, for NDJSON. Default laya-page-role; if the body names one too, they must agree.
textNDJSON lineyesThe page's text, non-empty, fitting one call to the model (16 MiB with its envelope). Blank lines are skipped.
idNDJSON linenoYour identifier, a string or a whole number, returned with the result.
pagesJSON bodyyesA list of pages, each a string or an object with text and an optional id.
modelJSON bodynoThe model, as in the query string.
scheduleJSON bodynoWhen 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.

FieldMeaning
job_idThe job's identifier, job_ and 24 hexadecimal characters.
modelThe model the job runs.
statusQUEUED; later RUNNING, then SUCCEEDED, FAILED or CANCELLED.
items_totalThe pages in the job; results are numbered 1 to this, in your order.
traceparentThe job's own trace context (version 00), to link from your traces.
model_stateThe model's state at admission, as GET /v1/jobs/{job_id} shows it.
cold_startOnly when the model was not ready: its model_state and expected_ready_seconds. The start is free.
scheduleOnly 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

StatusCodeWhen it happensWhat to do
400invalid_json, invalid_bodyThe JSON body is not JSON, or not an object with a pages list.Send {"pages": [...]}.
400invalid_json_line, invalid_lineAn 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.
400empty_page, invalid_text, invalid_idA 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.
400page_too_largeOne page does not fit one call to the model.Shorten the page; the limit is above.
400no_pagesThe body holds no page at all.Send at least one.
400model_not_available, model_conflictThe 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.
400invalid_idempotency_keyThe Idempotency-Key header is present but empty.Send a key, or no header.
400invalid_schedule, invalid_schedule_windowschedule 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.
400encrypted_envelope_requiredThe workspace requires confidential transport, which this call does not carry.Use the workspace's confidential calls.
401unauthorized, invalid_token, token_revoked, token_expiredNo token, or one that does not work (any more).Use a valid token.
402no_creditYour available credit is zero or less.Add credit.
503price_unavailableA price cannot be set right now; nothing was admitted or charged.Send again after Retry-After.
402queue_exceeds_creditThe 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.
402token_daily_capThe 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.
403scope_required, account_suspendedThe token lacks submit, or the account is suspended.Use a token with submit; for a suspended account, talk to us.
409idempotency_key_in_progressAn earlier request with this key is still being read or stored.Wait for its answer, then send again with the same key.
413body_too_large, line_too_largeA 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.
415unsupported_media_typeThe Content-Type is not one of those above; accepted lists them.Set the header.
422idempotency_key_reusedThe key was used before for a different request.Use a new key for new work.
429rate_limitedThe token sends work faster than its request rate.Wait the Retry-After seconds, then send again with the same key.
429overloadedThe 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.
400unsupported_job_kindA JSON body names a kind other than laya.classify or finetune.Leave kind out for pages.
500internal_errorA fault on our side.See "Retrying safely" below.

Examples

json
{"text": "Senior data engineer, Utrecht. Apply today.", "id": "page-000001"}
{"text": "All open positions: 24 results. Filter by city or team.", "id": "page-000002"}
sh
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.ndjson
text
HTTP/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, traceparent and 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 schedule on JSON bodies and the model_state, cold_start and schedule answer fields.

See also

GET /v1/jobs/{job_id}/results, POST /v1/classify, GET /v1/quote, Classify pages.