API errors
A refused call answers a 4xx or 5xx status with a JSON body that names the problem and the details to act on. A refused request is not kept and not charged: no job, no dataset rows, no plan. Two calls need a second look, described under What a refusal leaves behind.
Status. Written on 2026-11-14 from the service's error handling and corrected on 2026-11-16 for batch pack registration and dry-run findings; every code is listed in Errors and limits.
The error body
{
"error": "queue_exceeds_credit",
"pages": 5000,
"pages_allowed": 1018,
"available_usd_micros": 1000,
"message": "Your available credit, $0.0010, pays for about 1,018 more pages at $0.0010 per 1,000 pages; this job has 5,000. Send fewer pages, or add credit first."
}| Field | Meaning |
|---|---|
error | The code to branch on, such as queue_exceeds_credit or rate_limited. |
message | One sentence for a person, when the code alone does not say what to do. |
retryable | true when the same request may pass later, as on 429 overloaded and 429 campaign_concurrency_limited. |
retry_after_seconds | The same value as the Retry-After header. |
| Other fields | The details of that code: a line or index, the bounds low and high, the amount needed, the scope required. |
A refusal never quotes your page text.
What a refusal leaves behind
| Call | What a refusal or an error finding means |
|---|---|
| Every call but the two below | Nothing was accepted. Fix or wait, then send it again. |
A batch of packs, POST /v1/streams/{stage_id}/packs with packs | Sources are checked first: a failed source check (400 source_...) registers nothing. After that the packs are registered one by one, each on its own, so a later 409 or 429 stream_backpressure leaves the earlier packs registered. Keep your identifiers and content, read the backlog and send the same batch again: registered packs answer unchanged and the rest register. |
| A dry run, POST /v1/compute/plans/dry-run | A plan the rules refuse is not an HTTP error: the answer is 200 with ok: false and findings, each with a code. Read ok, plan_valid and findings, not the status. Only a malformed body, a missing scope or a busy service (429 dry_run_busy) answers 4xx. |
| A stage failure you report, POST .../fail | Not a refusal but worth knowing here: it ends that stage and the stages that depend on it, not the plan's independent stages. |
OpenAI-compatible calls
The chat and model-list calls (/v1/chat/completions and /v1/proxy/...) refuse in OpenAI's shape, so an OpenAI SDK raises its own error types:
{
"error": {
"message": "Authentication required.",
"type": "authentication_error",
"code": "unauthorized",
"request_id": "3f2b8c1e-9a4d-4e7b-8c21-5d6f7a8b9c0d"
}
}code is the same code as elsewhere, with one exception on the drop-in base https://weights.fyi/run/v1/proxy: there code is a short stable set (rate_limited for every 429, credit_exhausted for every 402) and reason carries the detailed code, such as campaign_concurrency_limited. Branch on the status and retryable first. type follows the status:
| Status | type |
|---|---|
400, 404, 413, 422 | invalid_request_error |
401 | authentication_error |
402 | insufficient_credit |
403 | permission_error |
429 | overloaded |
502 | api_error |
503 | model_not_ready, or service_unavailable when no price is available |
Every such answer carries X-Request-Id, the same id as request_id; send your own UUID in X-Request-Id and the answer uses it. Quote it when you report a problem.
Status codes
| Status | Meaning | What to do |
|---|---|---|
400 | The request is not what the call takes; line, index or the field named says where. | Fix it and send it again. |
401 | No key, or one that no longer works. | See Authentication. |
402 | Not enough credit, or the key's spend cap for the UTC day; nothing ran. | Add credit, send less, or wait for resets_at. |
403 | The key lacks the call's scope, or the account may not do this. | Use a key with the scope named in required. |
404 | It does not exist, or it is another workspace's; you never learn which. not_configured means a feature is off on this service. | Check the id, or the feature's page. |
405 | A method the path does not take; Allow lists those it does. | Check the call against the reference. |
408 | A dataset upload stalled past its limits. | Send the file again to the same address. |
409 | The current state does not allow the call, or the first request with this Idempotency-Key is still running. | Read the current state, then act. |
413, 415 | The body is too large, or of a type the call does not take. | Split it, or send JSON or NDJSON. |
422 | The same Idempotency-Key with a different request. | Use a new key for new work. |
429 | The key's request rate, or a capacity limit. A single refused request was not accepted; a batch of packs can be accepted in part (above). On a chat turn it is ordinary backpressure at the capacity edge. | Wait Retry-After seconds, within a deadline of your own (Rate limits). |
500, 502, 503 | A fault on our side, or in a service behind the call. | Retry with the same Idempotency-Key, waiting longer each time. |
Idempotency and retries
POST /v1/classify and POST /v1/jobs take an Idempotency-Key header: any string, one per piece of work, sent with every attempt of it.
curl -s https://weights.fyi/run/v1/jobs \
-H "Authorization: Bearer $WEIGHTS_API_KEY" -H "Content-Type: application/json" \
-H "Idempotency-Key: nightly-2026-11-14" \
-d '{"pages": ["First page text", "Second page text"]}'- Same key, same request: the first answer again, with
Idempotent-Replayed: true; no second job. - Same key, different request:
422 idempotency_key_reused. - Same key while the first attempt still runs:
409 idempotency_key_in_progress; try again shortly. - A
4xxrefusal frees the key: fix the request and send it with the same key. - A
5xxafter the body was read is kept and replayed, because work may have started. - Keys are kept 24 h; after that the same key makes a new job.
Compute plans and packs replay on their own identifiers and content instead of a key. Making a key (POST /v1/tokens) or a payment page takes no key, so a retry makes a second one.