Skip to content

Errors

The Layer REST API uses conventional HTTP status codes and returns a consistent, machine-readable error body following RFC 7807 Problem Details.

Errors are returned with the application/problem+json content type and this shape:

{
"type": "https://api.layer.ai/errors/WORKSPACE_NOT_FOUND",
"title": "Workspace not found",
"status": 404,
"detail": "Workspace 2489e9ad-… doesn't exist or you're not a member.",
"error_code": "WORKSPACE_NOT_FOUND"
}
  • error_code: the machine-readable error code. Branch on this, not on the human-readable title or detail.
  • type: a stable URI ending in the same code.
  • status: mirrors the HTTP status.
  • detail: a human-readable explanation. For 4xx errors this is specific; for 5xx errors it’s scrubbed to a generic message.
  • field: the request field the error is about, by its name in the body (on a tool run, in input), so you can mark it without parsing detail. Only the errors that name one carry it, so far INFERENCE_TOOL_PIN_MISMATCH and INFERENCE_TOOL_UPSCALE_COPIES_SOURCE; on any other error it is absent, even when detail names a field.
Code Status Meaning
UNAUTHENTICATED 401 Missing or invalid bearer token. See Authentication.
INVALID_ROLE_OVERRIDE 400 The role override headers name a role that can’t apply: only one header sent, an id that doesn’t parse, or a role that is archived or not available in the workspace.
FORBIDDEN 403 The authenticated user lacks permission for this action or workspace.
INSUFFICIENT_BALANCE 402 Not enough Creative Units. See Creative Units & billing.
RATE_LIMITED 429 Too many requests. See Rate limits.
WORKSPACE_NOT_FOUND 404 Workspace doesn’t exist or you’re not a member.
MODEL_NOT_FOUND 404 Model not found or not available in this workspace.
BASE_MODEL_NOT_FOUND 404 No base model has that ID, slug, name or alias, or it isn’t one you can run in the workspace: retired, hidden, or not allowed by your AI policy.
WORKFLOW_NOT_FOUND 404 Workflow not found or not linked to this workspace.
INFERENCE_NOT_FOUND 404 Inference (forge) run doesn’t exist.
RUN_NOT_FOUND 404 Workflow run doesn’t exist.
INFERENCE_TOOL_NOT_FOUND 404 A tool route’s path names no Layer tool, or one none of whose models the workspace runs. A key in a body or query is UNKNOWN_INFERENCE_TOOL instead.
TREND_NOT_FOUND 404 No trend has that id, or it is no longer listed on the Trends page.
PROJECT_NOT_FOUND 422 Project doesn’t exist in this workspace.
PROJECT_ARCHIVED 422 Project is archived: unarchive it in the app to add work.
PROJECT_DELETED 422 Project is deleted and can’t take new work.
PROJECT_ACCESS_DENIED 403 You’re not a member of the project, and either you’re not a workspace admin or the project is private.
PROJECT_ACCESS_CHANGE_FORBIDDEN 403 You can edit the project as a workspace admin, but only a member of the project can change its visibility.
INVALID_INPUTS 422 Malformed parameters, UUIDs, or an invalid pagination cursor.
REFUSAL_NOT_REWRITABLE 422 POST …/inferences/{id}/prompt-rewrite was asked about a run that a model’s content check did not refuse for its prompt: a run that succeeded, failed for another reason, has no prompt, or was refused for what the model generated.
UNKNOWN_INFERENCE_TOOL 422 A run’s inference_tool_key, in its body or query, is not a Layer tool. A key in a tool route’s path is INFERENCE_TOOL_NOT_FOUND instead.
INFERENCE_TOOL_MODEL_NOT_IN_POOL 422 A run or a schema request for a tool names a model the tool doesn’t run, or a run leaves the model to be picked.
INFERENCE_TOOL_PIN_MISMATCH 422 A run that names a tool changes a value the tool fixes. field and detail name the field.
INFERENCE_TOOL_MODEL_TAKES_NO_MASK 422 A run that names a tool sends a mask on a model that edits by reference, with no image to keep outside the mask. The tool’s schema on that model says x-source.takes_mask: false.
INFERENCE_TOOL_NO_REFRAME 422 A run that names a reframe tool doesn’t ask for a reframe.
INFERENCE_TOOL_UPSCALE_COPIES_SOURCE 422 A run that names the video upscale tool asks for a 1x size with no frame rate, which would copy its source. field names the scale factor: upscale_factor, or upscale_ratio in the body of POST …/workspaces/{id}/inferences.
UPLOAD_FAILED 502 A file could not be downloaded or stored.
INTERNAL_ERROR 500 An unexpected server error. Retry later; contact support if it persists.

Generation is asynchronous, and not every failure surfaces as an HTTP error. In particular, your Creative Unit balance is not checked when you submit a run: an underfunded run is accepted with 202 and later reaches a terminal failed/failure state carrying error_code: INSUFFICIENT_BALANCE.

Guardrails and provider content policies judge a generation after it is accepted, so a refusal never comes back as a 4xx. The run fails with one of these error_code values, and carries a refusal object that says why:

Code Meaning
INPUT_GUARDRAIL_VIOLATION A guardrail your workspace or project set blocked the request. Nothing was sent to the provider.
CONTENT_POLICY_VIOLATION The model provider refused the request under its content policy.
PROMPT_INTELLECTUAL_PROPERTY The model provider refused the request because it asked for protected intellectual property.
NO_MEDIA_GENERATED The provider returned no output. It can be a passing provider failure, a silent refusal of the prompt, or an input the model found nothing in. Run it again before rewriting the prompt.
{
"inference_id": "6f1c…",
"status": "failed",
"error": "This request was blocked by your workspace's “No Nintendo IP” guardrail. The prompt names Mario.",
"error_code": "INPUT_GUARDRAIL_VIOLATION",
"refusal": {
"inference_id": "6f1c…",
"code": "INPUT_GUARDRAIL_VIOLATION",
"guardrails": [
{
"guardrail_id": "0b6e…",
"name": "No Nintendo IP",
"category": "custom",
"reason": "The prompt names Mario."
}
]
}
}
  • guardrails: for INPUT_GUARDRAIL_VIOLATION, every guardrail that blocked the request, with its id, its name, the reason it gave, and its category: copyright_infringement, ip_trademark_infringement or artist_style_mimicry for the guardrails Layer ships, custom for a rule your workspace wrote. Empty for every other code.

refusal is null on every other outcome. A workflow run that a refused generation stopped fails with BlueprintInvalidRuntimeValueError and lists every refused generation in refusals, oldest first, in the same shape. Webhook deliveries carry the same fields, since their data is the matching GET body.

Resubmitting the same inputs is refused the same way. Change the prompt or the reference images, or ask a workspace admin about the guardrail it names.

Content checks refuse a prompt that names a character, game, studio, brand or logo, even when your studio owns or licenses it. For a CONTENT_POLICY_VIOLATION or PROMPT_INTELLECTUAL_PROPERTY refusal of the prompt, POST /v2/workspaces/{workspace_id}/inferences/{inference_id}/prompt-rewrite returns the prompt with each such name replaced by a plain description, and the names it replaced. Submit it as a new run with the same settings. A refusal of what the model generated (its error says the generated output was rejected) is not rewritable: try another model.

  • Retry 429 after the Retry-After interval, and 5xx with exponential backoff.
  • Do not blindly retry 4xx errors other than 429. Fix the request first.
  • A retry of an execute request that actually succeeded server-side creates a duplicate run unless you sent an idempotency key with it. Send one on every submit, or prefer polling an existing run over re-submitting.