Errors

Every error code the API returns, what causes it, and which ones you retry.

The error envelope

Every JSON error uses one shape. The HTTP status carries the class. The code carries the reason.

{ "error": { "code": "string", "message": "string" } }

The envelope is the same on the seven capability endpoints and on the OpenAI-compatible endpoints.

One case falls outside the envelope. A wrong method or an unrouted path returns the plain text 404 Not Found, with content type text/plain. A GET on a capability path hits this case.

Codes

CodeStatusCause
invalid_request400The body failed validation. The facade also raises it for a chat request with no user text, and for a tool_choice that names a tool outside tools.
invalid_schema400An extract schema is not an object with properties.
unsupported_request400A chat request the model does not serve: plain chat, response_format of text or json_object, or tool_choice: "none" without a usable response_format.
model_not_found404A wrong model id on POST /v1/chat/completions, or a wrong id on GET /v1/models/{id}.
runner_error502Inference failed on one slot, then failed the retry on a second slot. The message reads Inference failed twice. Retry.
overloaded529No inference slot became free inside the wait window. The message reads Every inference slot stayed busy. Retry with backoff.
http_errorfrom the exceptionAn internal HTTP exception reached the error handler.
internal_error500Anything else. The message reads Internal Server Error.

The spec declares 502 and 529 on the seven capability endpoints. It declares 529, but not 502, on POST /v1/chat/completions.

Validation messages

invalid_request reports the first three validation issues. Each issue reads path: message. The issues join with ; , and the path is body when the rule covers the whole object.

{"error":{"code":"invalid_request","message":"labels: Too small: expected array to have >=2 items"}}

The message body: provide text or texts, not both also appears when you send neither field. Check that your body carries text or texts before you hunt for a duplicate. yes-no is the exception: it accepts both keys, and it accepts neither.

OpenAI-compatible errors

The facade rejects requests it cannot map to a capability.

{"error":{"code":"unsupported_request","message":"decision-machine-1 decides, it does not chat. Send response_format.json_schema for structured extraction, tools for function calling, or use the capability endpoints under /v1/decision-machine-1/."}}
{"error":{"code":"model_not_found","message":"Unknown model \"gpt-4o\". Use \"decision-machine-1\"."}}

A wrong id on GET /v1/models/{id} returns a shorter message.

{"error":{"code":"model_not_found","message":"Unknown model. Use \"decision-machine-1\"."}}

Which errors you retry

StatusRetry?Action
400NoFix the request. The same body fails again.
404NoFix the model id, the path, or the method.
500NoDo not loop. Capture the message and the request body, then report them.
502Yes, once or twiceThe service already retried on a second slot. Wait, then send the call again.
529Yes, with backoffEvery slot stayed busy. Back off and send the call again.

The spec declares no Retry-After header on any response. Pick your own delays.

Use exponential backoff with jitter on 502 and 529. Cap the attempts at three. Treat 529 as backpressure, not as a fault. Lower your concurrency when you see it often.

Retry code

The examples below retry 502 and 529 only, and give up after three attempts.

for attempt in 1 2 3; do
code=$(curl -s -o /tmp/dm.json -w '%{http_code}' \
-X POST https://api.milliseconds.ai/v1/decision-machine-1/yes-no \
-H 'Content-Type: application/json' \
-d '{"text":"The server returned a 500.","statement":"This reports an outage."}')
if [ "$code" != "502" ] && [ "$code" != "529" ]; then break; fi
sleep $((attempt * 2))
done
cat /tmp/dm.json

No API key is required during the launch period. The API documents no 401 and no 403. If you see one, check the network path in front of the API.

Next

  • Limits and rate limits lists every field limit that raises invalid_request.
  • Input shows how to shape text and texts correctly.
  • Extract documents the schema rules behind invalid_schema.