Skip to content
Get API key

Errors

Every non-2xx response from https://api.mouse.dev uses a single JSON error envelope. Error messages name the offending field or limit and never echo your request content (state, instructions, or criteria).

{
"error": {
"type": "invalid_request_error",
"code": "state_too_long",
"message": "state is 71,204 tokens; mouse-preview-2026-10-13 reads at most 65,536. Nothing was truncated or billed.",
"param": "state"
}
}
FieldTypeDescription
error.typestringBroad error category: invalid_request_error, authentication_error, billing_error, rate_limit_error, or api_error.
error.codestringMachine-readable error code for programmatic branching (see table below).
error.messagestringHuman-readable explanation naming the limit or parameter. Never contains request content.
error.paramstring (optional)Dotted path of the offending request field (e.g. "state", "questions.intent.criteria", "examples") or header ("authorization").

Every error response includes Mouse-Request-Id, Mouse-Region, Mouse-Data-Retention: none, and Cache-Control: no-store. 4xx responses are never billed.

Statuserror.typeerror.codeparamDescription & resolution
400invalid_request_errorinvalid_calibration_profilecalibrationThe calibration token is malformed, truncated, tampered with, or signed with a retired key. Fit a new profile with POST /v1/calibrations.
401authentication_errormissing_api_key—Missing Authorization: Bearer sk_mouse_... header.
401authentication_errorinvalid_api_key—Key does not start with sk_mouse_, fails its CRC32 checksum, is expired, or has been revoked.
402billing_errorinsufficient_creditsauthorizationPrepaid credit balance is $0.00. Top up or enable auto-reload at /console/billing.
404invalid_request_errormodel_not_found—Unknown model string. Query GET /v1/models for active aliases (mouse-1, mouse) and snapshots.
409invalid_request_errorprofile_model_mismatch—The supplied calibration profile was fitted on a different model snapshot than the one serving this request. Pin the model version or refit the profile.
413invalid_request_errorrequest_too_largebodyRaw HTTP request body exceeds 4,000,000 bytes (4 MB).
422invalid_request_errorinvalid_schema<field.path>Request body failed schema validation (e.g. missing state or questions, unknown field inside a question, choice criteria passed as an array instead of an object, or invalid calibration label).
422invalid_request_errorstate_too_longstatestate exceeds 65,536 tokens. Nothing is truncated or billed; trim state to the fields relevant to your questions.
422invalid_request_errortoo_many_questionsquestionsMore than 128 questions in a single request.
422invalid_request_errortoo_many_optionsquestions.<id>.criteriaA question has more than 1,024 options.
422invalid_request_errortoo_few_examplesexamplesFewer than 200 examples sent to POST /v1/calibrations.
422invalid_request_errortoo_many_examplesexamplesMore than 5,000 examples sent to POST /v1/calibrations.
422invalid_request_errortoo_few_examples_per_questionexamplesNo question signature in POST /v1/calibrations had at least 50 labeled examples.
429rate_limit_errorrate_limited—Exceeded the per-key request rate limit (200 RPS, burst 400). Includes Retry-After.
429rate_limit_errortoken_rate_limited—Exceeded the per-key input token rate limit (20,000,000 TPM). Includes Retry-After.
503api_errorengine_timeout—The GPU worker did not respond within the 10-second engine deadline. Includes Retry-After: 2.

When calling POST /v1/systemone on a user-facing or hot agent path:

  1. Do not retry 400, 401, 402, 404, 409, 413, or 422: These are deterministic client errors; fix the request or fall back to baseline harness logic immediately.
  2. Honor Retry-After on 429 and 503: Both 429 Too Many Requests and 503 Service Unavailable include a Retry-After header (in integer seconds). On background or batch paths, retry with exponential backoff + jitter after Retry-After.
  3. Bound total latency on critical paths: In interactive agent loops (such as tool-call gating or message routing), set a per-request deadline (e.g. 1,500 ms to 3,000 ms) with 0 or 1 retry and fall back to your deterministic floor if the call times out.
async function systemOneWithFallback(payload: unknown) {
const res = await fetch("https://api.mouse.dev/v1/systemone", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.MOUSE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
signal: AbortSignal.timeout(2_500),
});
if (res.status === 429 || res.status === 503) {
const retryAfterSec = Number(res.headers.get("retry-after") ?? "1");
await new Promise((r) => setTimeout(r, retryAfterSec * 1_000));
// Optional single retry for background jobs
}
if (!res.ok) {
const { error } = await res.json();
throw new Error(`[${error.code}] ${error.message}`);
}
return res.json();
}