Improvement
API, SDK, CLIBreakingRequest errors say what to fix
Every rejected request now returns a code and a message you can act on, schema failures list each invalid field, and malformed requests get their own codes.
A request that failed validation used to come back in the validator's own shape: { data, error, success } on /image/* and /video/*, { success, errors } elsewhere, with no code and your request echoed back. Now every request error has the same body:
{
"code": "VALIDATION_ERROR",
"message": "model \"flux.2-pro\" is not supported. Did you mean \"black-forest-labs/flux.2-pro\"? See https://mynth.io/models, or GET /models, for the model IDs.",
"issues": [{ "path": ["model"], "message": "model \"flux.2-pro\" is not supported. …" }]
}message states every problem, so it is safe to show as it is. issues has one { path, message } per field that failed the schema. An unknown model suggests the closest id, and an invalid size lists the forms it takes.
Two new codes cover requests that never reach validation:
INVALID_JSON(400) for a body that is not valid JSON, with the parser's position. It used to be plain text.UNSUPPORTED_MEDIA_TYPE(415) for a JSON endpoint called withoutContent-Type: application/json, orPOST /image/uploadwithoutmultipart/form-data. Such a body used to be read as empty, so the error blamed a missingprompt.
A size a pinned model cannot produce, such as 16:9_4k on a model without 4k, is now rejected at create with 400 VALIDATION_ERROR and the size to use instead. It used to be accepted and then fail the task with CAPABILITY_NOT_SUPPORTED. With model: "auto" nothing changes.
Other messages got more specific too: input, resolution, duration, and audio errors list what the model accepts, UNAUTHORIZED says what is wrong with the credential, balance and spending-limit errors state the amounts, upload errors name the file, and a 404 names the route.
If your code reads error, errors, or data from a 400, read code, message, and issues instead. MynthAPIError in the SDK now carries issues and a useful message, and the CLI exits with 2 for both new codes. See errors.