Skip to main content

API Errors

Error format change

The error format described on this page took effect on 29 September 2026. Responses returned before that date followed the previous format. If your integration still parses the previous format, update it to read the code field described below.

This page documents the error responses the API can return, how to read them, and what each error code means.

Every error carries a stable, machine-readable code. Branch on the code, not on the localised message, when handling errors in your client.

Response shape​

All error responses share the same JSON envelope, and a few errors add fields of their own:

{
"code": "validation_error",
"message": "One or more validation errors occurred.",
"documentationUrl": "https://docs.serenitystar.ai/docs/serenity-aihub/dev-tools/api-error-responses#validation_error",
"errors": { "conversation_closed": "The conversation is closed. Please start a new one." }
}
FieldAlways presentDescription
codeYesStable, machine-readable classification of the error. This is your discriminator.
messageYesHuman-readable summary. Localised.
documentationUrlYesDeep link to this error's section in these docs, so you can jump straight to the relevant reference.
errorsNoA map of key → message, included only when the error has specific detail to report. Each key identifies either the request field that was invalid or the specific rule that failed. The possible keys are documented per error below.
attemptsNoOnly on agent_execution_failed and aiservice_execution_failed. One entry per attempt to call the AI provider, each with its own code, message and errors.
filesNoOnly on aiservice_execution_failed from OCR. Groups the attempts per submitted file, in place of attempts. See OCR: attempts per file.

A few conventions apply to every response:

  • The message text shown here is representative English. The exact wording is localised and may change, so do not depend on it.

Quick reference​

codeHTTP statusCategory
unauthorized401Authentication & authorisation
forbidden403Authentication & authorisation
input_validation_error400Validation
validation_error400Validation
agent_execution_failed400, or 500 (server fault) / 429 (all rate-limit) / 502 (all-vendor)Execution failed
aiservice_execution_failed400, or 500 (server fault) / 429 (all rate-limit) / 502 (all-vendor)Execution failed
request_too_large413Validation
method_not_allowed405Validation
unsupported_media_type415Validation
resource_not_found404Not found
rate_limit_exceeded429Rate limiting
server_error500Unexpected

agent_execution_failed and aiservice_execution_failed represent a failed call to an AI provider. Some calls are retried (for example, an agent falls back to its fallback model), and the attempts array lists every try and why it failed.

The vendor_* codes are never the top-level code of a response. They only appear as attempts[].code inside agent_execution_failed and aiservice_execution_failed; see Vendor error codes.


Authentication & authorisation​

unauthorized​

HTTP 401. Authentication is missing or invalid — no credentials, an expired or malformed bearer token, or an invalid API key.

{ "code": "unauthorized", "message": "Authentication is required to access this resource." }

How to resolve: obtain or refresh a valid token / API key and retry with the Authorization header set.

forbidden​

HTTP 403. You are authenticated, but you do not have the required permissions to access the resource. You may be missing a role, permissions to a specific agent, or the resources may belong to another tenant or sub-tenant.

{ "code": "forbidden", "message": "You do not have permission to access this resource." }

How to resolve: this is not fixable by retrying with the same credentials. Check that you are using the correct token or API key and that it has the required permissions. If you still need access, ask your administrator to grant it.


Validation​

Client-side request problems (HTTP 4xx). The request should not be retried unchanged.

input_validation_error​

HTTP 400. The request itself failed a validation — a missing required field, a wrong type, or a body that isn't valid JSON. Rejected before the endpoint runs.

{
"message": "One or more validation errors occurred.",
"code": "input_validation_error",
"documentationUrl": "https://docs.serenitystar.ai/docs/serenity-aihub/dev-tools/api-error-responses#input_validation_error",
"errors": { "message": ["The field is required."] }
}

Unlike the other responses, each errors value here is an array of messages, since a single field can fail more than one validation rule at once.

Keys​

The errors keys are the names of the offending request fields (in the API's JSON casing, dot-separated for nested members). Each value is an array of messages for that field. The key set is therefore dynamic — it depends on your request model — not a fixed vocabulary.

validation_error​

HTTP 400. A business rule rejected the request inside the application (for example, a required input is missing, the agent is inactive, or a quota is exhausted). message is a generic summary; the specific reasons are in errors.

{
"code": "validation_error",
"message": "One or more validation errors occurred.",
"errors": { "input_keys_duplicated": "Duplicate input keys are not allowed: message" }
}

Some conditions return a single message with no errors map:

{ "code": "validation_error", "message": "<the specific reason>" }

Keys​

Each errors key identifies the specific rule that failed. The keys you may encounter on the execution and conversation endpoints:

Request input​
  • message_required — no message was supplied for the agent.
  • invalid_request_body — the request body is structurally invalid for this endpoint.
  • input_keys_duplicated — the same input key appears more than once.
  • multiple_inputs — more than one input was provided where a single one is required.
  • required_parameters_missing — one or more required input parameters were not provided.
  • required_parameters_null — a required parameter was provided as null.
  • required_parameters_empty — a required parameter was provided but empty.
  • parameter_type_mismatch — a parameter value does not match its expected type.
  • missing_variables — the request omits variables the agent expects.
  • invalid_messages — the supplied message list is invalid.
  • audio_input_not_supported — audio input was sent to an agent/model that does not accept it.
Agent state​
  • agent_inactive — the target agent is not active.
  • agent_code_invalid — the agent code does not resolve to an agent.
  • agent_version_inactive — the requested agent version is not active.
  • ai_model_not_allowed — the selected model is not permitted for this agent.
  • invalid_model — the requested model is invalid.
AI services​
  • invalid_model — the selected model can't be used for this service: it isn't available to your organisation, or it is the wrong kind of model (for example, a chat model sent to Decisions).
  • connection_settings_not_found — no connection to the model's provider is configured.
  • missing_model_price — the selected model has no price configured.
Conversation​
  • conversation_closed — the conversation is closed and cannot accept new messages.
  • conversation_context_not_found — the referenced conversation context does not exist.
Response format & reasoning options​
  • invalid_response_format_type — the requested response-format type is invalid.
  • invalid_response_format_schema — the supplied response-format schema is invalid.
  • response_format_not_supported_by_model — the model does not support the requested response format.
  • invalid_reasoning_effort — the requested reasoning-effort value is invalid.
  • invalid_reasoning_detail — the requested reasoning-detail value is invalid.
  • reasoning_effort_not_supported_by_model — the model does not support a reasoning-effort setting.
  • reasoning_detail_not_supported_by_model — the model does not support a reasoning-detail setting.
Skills & tools​
  • invalid_skills_options — the supplied skills options are invalid.
  • conflicting_skills_options — the supplied skills options conflict with each other.
  • tool_approval_pending — the run is paused waiting for a tool call to be approved.
  • tool_approval_skill_not_found — the skill referenced by a tool approval does not exist.
  • tool_approval_ambiguous_tool — a tool approval matched more than one tool.
Quota & balance​
  • insufficient_balance — the account balance is insufficient to run the request.
  • monthly_quota_exceeded — the monthly usage quota is exhausted.
  • user_quota_exceeded — the per-user usage quota is exhausted.
  • organisation_quota_exceeded — the organisation-wide usage quota is exhausted.
  • model_quota_exceeded — the quota for the specific model is exhausted.
  • excluded_bonified_execution_insufficient_balance — balance is insufficient for a non-bonified execution.

Agent-configuration (designer) endpoints emit additional, feature-specific keys following a namespaced pattern (e.g. model_is_required, skills_email_<code>_required_recipients). Those are documented with their respective endpoints.

agent_execution_failed​

HTTP 400 when any attempt was client-fixable. Otherwise, on a non-streaming run: 500 when any attempt was a server-side fault (neither yours nor the provider's); when every attempt failed at the provider, 429 if they were all rate limits, otherwise 502 (each attempt's own upstream status stays on its attempts[].statusCode). An agent run failed after exhausting all of its attempts (the primary model plus any fallbacks). Every attempt is listed individually.

On the 429 case the response also carries a Retry-After header: the longest wait any attempt reported, or a 30-second default when none did. This is distinct from rate_limit_exceeded, which is the API's own limit.

{
"code": "agent_execution_failed",
"message": "All retry attempts with the base and fallback model have failed.",
"errors": { "vendor_error": "…" },
"attempts": [
{ "index": 0, "modelType": "main", "code": "vendor_service_error", "statusCode": 503, "message": "…", "errors": { "vendor_error": "…" } },
{ "index": 1, "modelType": "fallback", "code": "vendor_rate_limit_error", "statusCode": 429, "message": "…", "errors": { "vendor_error": "…" } }
]
}
  • attempts[] — one entry per attempt, in order. index is 0-based. modelType is main or fallback. Each attempt renders exactly as that same error would on its own: the same code, message, and errors you would get if it were returned standalone. So an attempt's code is typically one of the vendor error codes, and a not-found attempt reads "code": "resource_not_found" with the specific resource as a key inside its errors (see resource_not_found). code is omitted only when the standalone error itself has none. A vendor-fault attempt keys its errors by vendor_error (the raw provider detail); the specific category is the code.
  • attempts[].statusCode — present on any attempt that carried an upstream HTTP status: a vendor fault, or a client-fixable vendor_validation_error (raw 400/413/415/422). It is the raw status the provider returned (e.g. 429, 503, 529, 400), so you can see the exact upstream status without parsing code. It does not drive our response status. A vendor_timeout_error or vendor_cancellation_error attempt carries 504 even though the provider never answered. It is omitted when the provider returned no status (vendor_context_length_error, or a vendor_service_error with no status) and for non-vendor failures.
  • Top-level errors mirrors the last attempt's errors only.

A deterministic failure that isn't worth retrying, such as a context-length overflow, still arrives in this same envelope with a single attempt whose code identifies the cause. A context-length overflow reads vendor_context_length_error and the run stays 400.

On a streaming run this is delivered as an error event with attempts[].model_type and attempts[].status_code (snake_case). When the run was exhausted on rate limits, the event carries a retry_after_seconds field in place of the Retry-After header the stream can't set.

aiservice_execution_failed​

HTTP 400 when any attempt was client-fixable (for example, a vendor_validation_error). Otherwise 500 when any attempt was a server-side fault (neither yours nor the provider's, for example a server_error attempt), 429 when every attempt failed on a provider rate limit, or 502 for any other provider fault (each attempt's own upstream status stays on its attempts[].statusCode). An AI service request failed at the provider. The provider error is always listed under attempts, even when there was only one attempt, so a request that makes a single call returns a one-element attempts array and the shape never changes.

On the 429 case the response also carries a Retry-After header: the longest wait any attempt reported, or a 30-second default when none did, the same as agent_execution_failed.

{
"code": "aiservice_execution_failed",
"message": "The image couldn't be generated. Please try again.",
"errors": { "vendor_error": "…" },
"attempts": [
{ "index": 0, "code": "vendor_service_error", "statusCode": 503, "message": "The AI provider returned a server error (HTTP 503) (Code 0086)", "errors": { "vendor_error": "…" } }
]
}

The shape is identical to agent_execution_failed with one exception: AI service attempts carry no modelType, because these endpoints have no main/fallback model distinction.

  • attempts[] — one entry per attempt, in order; index is 0-based. Each attempt renders exactly as that same error would on its own (the same code, message, and errors), so an attempt's code is typically one of the vendor error codes, with a vendor-fault attempt keying its errors by vendor_error.
  • attempts[].statusCode — the raw upstream HTTP status, present on any vendor attempt that carried one (a vendor fault or a client-fixable vendor_validation_error). It is informational and does not drive the response status.
  • Top-level errors mirrors the last attempt's errors only.

This response is returned by every AI service endpoint: embeddings generation, image generation, vision, speech generation, audio transcription, OCR and Decisions. Embeddings generation may retry, adding one attempt per try; the others make a single call per request (per file for OCR). On Decisions, an input the selected model doesn't accept (for example, an image sent to a text-only model) or an input over the model's limits arrives as a vendor_validation_error attempt, so the response is 400. On a streaming request (speech generation with stream: true) the same envelope is delivered as an error event with attempts[].status_code (snake_case) and, on the rate-limit case, a retry_after_seconds field in place of the Retry-After header.

OCR: attempts per file​

OCR processes each submitted file separately, so the OCR endpoints (/api/v2/Ocr, /api/v2/Ocr/base64, /api/v2/Ocr/url and /api/v2/Ocr/file) nest the attempts per file under files instead of a top-level attempts. A batch in which only some files failed is not an error: it returns 200 with a per-file error string in the result body. This response is returned only when every file failed.

{
"code": "aiservice_execution_failed",
"message": "The text couldn't be extracted from any of the files. Please try again.",
"errors": { "invoice.pdf": "The AI provider returned a server error (HTTP 503) (Code 0086)", "scan.png": "The AI provider rejected the request as invalid (HTTP 422) (Code 0065)" },
"files": [
{ "index": 0, "source": "invoice.pdf",
"attempts": [ { "index": 0, "code": "vendor_service_error", "statusCode": 503, "message": "The AI provider returned a server error (HTTP 503) (Code 0086)", "errors": { "vendor_error": "…" } } ] },
{ "index": 1, "source": "scan.png",
"attempts": [ { "index": 0, "code": "vendor_validation_error", "statusCode": 422, "message": "The AI provider rejected the request as invalid (HTTP 422) (Code 0065)", "errors": { "vendor_error": "…" } } ] }
]
}
  • files[] — one entry per submitted file; index (0-based) and source match the success body's files[].
  • files[].attempts[] — every attempt made for that file, even when there was only one; each renders as described above. A provider timeout is an attempt with vendor_timeout_error.
  • Top-level errors — keyed by file (source, or index when there is none), each value being that file's last attempt message.
  • The status follows the same rule across every file's attempts: 400 when any file was rejected as client-fixable (so a mix of one bad file and one outage is a 400), 429 when every attempt was a rate limit (with a Retry-After header), otherwise 502.

An empty file, or a URL that isn't an absolute http/https address, is rejected before the provider is called: as an input_validation_error for uploaded, base64 and URL input (keyed by the request field, for example files or urls), or as a validation_error for an empty stored file on /file.

request_too_large​

HTTP 413. The request body exceeds the configured maximum size.

{ "code": "request_too_large", "message": "The request is too large." }

method_not_allowed​

HTTP 405. The route exists but does not support the HTTP method used.

{ "code": "method_not_allowed", "message": "The HTTP method is not allowed for this resource." }

unsupported_media_type​

HTTP 415. The request Content-Type is not supported by the endpoint (for example, sending text/plain to a JSON endpoint).

{ "code": "unsupported_media_type", "message": "The request media type is not supported." }

Not found​

resource_not_found​

HTTP 404. The requested resource does not exist, either because no route matched or because a lookup for a specific resource came back empty. Every 404 shares this single code. The body then takes one of two shapes.

When there is a known resource to report, message is a generic summary and the errors map holds one entry whose key identifies what was missing (the same way validation_error carries its reason). Branch on that key:

{
"code": "resource_not_found",
"message": "The resource you're trying to see was not found (Code 0040)",
"errors": { "agent_version_not_found": "No published agent version found for this agent code: <code>" }
}

When there is no specific resource key, the detail is carried in message and there is no errors map. A no-route 404 (nothing matched the URL) also takes this shape:

{
"code": "resource_not_found",
"message": "The requested model was not found."
}

Keys​

When present, the errors map holds exactly one entry whose key identifies the missing resource:

  • agent_code_invalid — the agent code does not resolve to an agent, or has no version resolvable for the request.
  • agent_version_not_found — the agent has no published version, or a specific requested version does not exist.
  • conversation_not_found — the referenced conversation does not exist (or is not visible to the caller).
  • aimodel_not_found — the requested model was not found: an inference model (vendor + model code, or model code alone), the model on a direct AI-service path (vision, audio, image, OCR), or a decision model (no model matches the aiModelId, or no decision model matches the vendor + modelCode pair).

An unspecified miss (the embeddings endpoint when a model isn't found, and any no-route 404) carries no errors map; read its detail from message. Vision, audio, image, OCR and Decisions model-not-found errors do carry the aimodel_not_found key above, with a generic top-level message.


Rate limiting​

rate_limit_exceeded​

HTTP 429. You have exceeded the allowed number of requests for your IP or client. A Retry-After response header indicates how long to wait before retrying.

{ "code": "rate_limit_exceeded", "message": "You have exceeded the allowed number of requests. Please try again later." }

How to resolve: back off and retry after the Retry-After interval. This limit is enforced by the API itself; it is distinct from a provider rate limit, which arrives as a vendor_rate_limit_error attempt inside an agent_execution_failed or aiservice_execution_failed response.


Vendor error codes​

These codes classify a failure of the upstream AI provider. They are never the top-level code of a response: they only appear as attempts[].code inside agent_execution_failed and aiservice_execution_failed (for OCR, files[].attempts[].code). Branch on the attempt's code.

A vendor error code carries no HTTP status of its own. The response status is resolved from all the attempts together (see each envelope), and the status the provider actually returned is kept on attempts[].statusCode. The code classifies the kind of fault, so one code (notably vendor_service_error) covers several provider statuses:

Provider statusattempts[].codeCounts as
400 / 413 / 415 / 422vendor_validation_errorclient-fixable → the run reads 400
context-window overflowvendor_context_length_errorclient-fixable → the run reads 400
401 / 403vendor_authentication_errorvendor fault
429vendor_rate_limit_errorvendor fault (a run of only these reads 429)
any other status (5xx, 404, 408, …), or nonevendor_service_errorvendor fault
no response: the request timed outvendor_timeout_errorvendor fault
no response: the call was cancelledvendor_cancellation_errorvendor fault

When every attempt is a vendor fault the run reads 429 if they were all rate limits, otherwise 502; any client-fixable attempt makes it 400. A vendor-fault attempt keys its errors by vendor_error, carrying the provider's own detail.

vendor_validation_error​

The provider rejected the request as client-fixable: a 400/422, or a 413 (payload too large) / 415 (unsupported media type), where you have to change what you sent. A context-length overflow has its own code, vendor_context_length_error. Any such attempt makes the run 400.

{ "index": 0, "code": "vendor_validation_error", "statusCode": 400, "message": "The AI provider rejected the request as invalid (HTTP 400) (Code 0065)", "errors": { "vendor_error": "<provider-supplied detail>" } }

vendor_context_length_error​

The prompt exceeded the model's context window. Client-fixable: shorten the input, or raise the model's token limit. It isn't retried, so an agent run that hits it has a single attempt and reads 400. Carries no statusCode.

{ "index": 0, "modelType": "main", "code": "vendor_context_length_error", "message": "The request exceeded the model's context window.", "errors": { "vendor_error": "<provider-supplied detail>" } }

vendor_rate_limit_error​

The provider rate-limited the request (429). When every attempt is a rate limit the run reads 429 with a Retry-After header (on a stream, a retry_after_seconds field): the longest wait the provider asked for, or a 30-second default.

{ "index": 0, "code": "vendor_rate_limit_error", "statusCode": 429, "message": "The AI provider rejected the request due to rate limiting (HTTP 429) (Code 0085)", "errors": { "vendor_error": "…" } }

vendor_authentication_error​

The provider rejected the configured credentials (401/403). This is a configuration problem, not something the end user can fix by retrying.

{ "index": 0, "code": "vendor_authentication_error", "statusCode": 401, "message": "The AI provider rejected the credentials (HTTP 401) (Code 0084)", "errors": { "vendor_error": "…" } }

vendor_service_error​

The catch-all upstream code: the provider is unavailable or overloaded, or returned any status not classified above (5xx, 404, 408, …). statusCode holds that status, and is omitted when the fault carried none (for example, a network failure). Retrying later may succeed.

{ "index": 0, "code": "vendor_service_error", "statusCode": 503, "message": "The AI provider returned a server error (HTTP 503) (Code 0086)", "errors": { "vendor_error": "…" } }

vendor_timeout_error​

The request to the AI provider timed out before a response was received. This is distinct from a provider that returns a 408/504, which reads vendor_service_error. The attempt carries statusCode: 504 even though no status was received. Retrying may succeed.

{ "index": 0, "code": "vendor_timeout_error", "statusCode": 504, "message": "…", "errors": { "vendor_error": "…" } }

vendor_cancellation_error​

The call to the AI provider was cancelled before it completed, for a reason other than a timeout or a client-requested cancellation. Carries statusCode: 504, like a timeout. Retrying may succeed.

{ "index": 0, "code": "vendor_cancellation_error", "statusCode": 504, "message": "…", "errors": { "vendor_error": "…" } }

vendor_error​

The fixed errors map key that carries the provider's raw detail on any vendor attempt that includes one, whatever its category (the category is the attempt's code). It is also reserved as a vendor error code for a provider fault that has only a message and no status; such faults are currently reported as vendor_service_error.

"errors": { "vendor_error": "<provider-supplied detail>" }

Unexpected​

server_error​

HTTP 500. A catch-all for unexpected server-side failures. The response never exposes internal detail.

{ "code": "server_error", "message": "An unexpected error occurred." }

How to resolve: retry after a short delay; if it persists, contact support.


Streaming (SSE) errors​

When you invoke an agent with streaming enabled, the response is already 200 text/event-stream before a failure can occur, so an error is not delivered as an HTTP status. Instead it arrives in-band as an error event:

event: error
data: {"type":"error","code":"…","message":"…","documentation_url":"…","errors":{…}}

The same code values apply, and documentation_url is carried in-band as well, present on every error event (serialised as null when no deep link is available). Streaming payloads are serialised snake_case (documentation_url, agent_result, model_type, generated_json, retry_after_seconds) rather than camelCase, and other null fields are omitted.

When every attempt failed on an AI provider is caused by rate limit, the event is an agent_execution_failed error, and because an open stream can't set an HTTP header, the wait time is delivered in-band as a retry_after_seconds field instead of a Retry-After header. The API's own rate limit (rate_limit_exceeded) is applied before the stream opens, so it always arrives as a regular 429 JSON response with a Retry-After header.

See more about streaming in the Streaming guide.