API Error Handling
Error handling reference for the Skytells API v1 — error codes, rate limits, and resolution guides.
Errors
When a request fails, Skytells returns structured JSON so you can branch on stable error_id values (not on human-readable messages).
Which shape you get depends on the route:
- Simple / unified REST body —
error_idandmessage(and related fields). See Simple API error body. - Inference routes (Chat, Responses, Embeddings) — a different top-level layout; no unified
status/responsewrapper. See Inference error response. - Predictions — may use the structured envelope. Full field definitions: Error objects.
Two error levels
Errors fall into two buckets: problems with the request or access (API-level), or problems while running the model after the job was accepted (prediction-level).
| Level | What it means |
|---|---|
| API-level | Invalid input, missing parameters, auth, permissions, credits, rate limits — before work is queued to prediction serving. |
| Prediction-level | Model or serving failed after the job was accepted — e.g. model not found, not authorized, unsupported use case, policy/moderation, or bad output. Often appears on the prediction resource as status: "failed". |
How the two levels differ in practice
API-level: Your request fails validation or policy before anything is queued to prediction serving.
Prediction-level: Validation passed; the job was queued and ran in serving, but inference failed. For predictions, the HTTP status on GET can still be 200 OK while the JSON body shows status: "failed" and an error message.
Safety controls apply during serving; a policy violation can surface as a failed prediction with an error string.
Learn more: Prediction-level errors.
Error shapes
Skytells returns different JSON shapes depending on the API surface:
| Shape | Typical routes |
|---|---|
| Unified REST (standard envelope) | Auth, models, predictions, rate limits, and most v1 REST — see Predictions API structured error |
| Inference | Chat, Responses, Embeddings (OpenAI-compatible; no top-level status / response) — Inference error response |
| Failed prediction object | Failed predictions — failed prediction object |
Unified REST (API-level example) — returned before a prediction is queued:
{
"status": false,
"response": "short summary",
"error": { "http_status": http_status_code, "message": "human-readable reason", "details": "extra context", "error_id": "error_code_value" }
}Inference — nested error object (serving or generation failure after the request reaches inference infrastructure):
{
"error": { "http_status": http_status_code, "message": "human-readable reason", "details": "extra context", "error_id": "error_code_value" }
}This covers cases where the language model fails to produce output, parameters are wrong for the model, or the model is not authorized — see Inference errors.
Failed prediction — job was accepted and reached a terminal failed state:
{
"status": "failed",
"error": "Failed to generate image / video / audio ..etc.",
"output": null,
"data_removed": true,
"metrics": {
"predict_time": 1.082823234,
"total_time": 1.094474004
},
"model": "truefusion",
"source": "api"
}The full prediction object can include additional fields; see Error objects.
HTTP status codes (quick reference)
| Status | Meaning |
|---|---|
| 400 | Bad request — malformed query, invalid parameters, or client-fixable input |
| 401 | Unauthorized — missing or invalid API key |
| 402 | Payment / credits — negative balance or insufficient credits |
| 403 | Forbidden — policy, security, or model access rules |
| 404 | Not found — unknown model slug or resource |
| 422 | Unprocessable — valid JSON but semantic validation failed |
| 429 | Too many requests — rate or quota limits |
| 500 | Internal error — unexpected server failure |
| 502 | Bad gateway — prediction serving error (see Prediction errors) |
| 503 | Service unavailable — temporary overload (e.g. prediction handler) |
- Inference errors — Chat, Responses, Embeddings:
error_idcatalog and HTTP behavior. - Prediction errors — Predictions routes, HTTP codes per
error_id, andstatus: "failed"on the prediction resource.
Where in the pipeline did it fail?
| Level | What failed |
|---|---|
| API-level | Request, access, or validation — before serving starts |
| Prediction-level | Model / serving run — after the prediction exists |
Error resources
Error objects
Linkable JSON shapes: unified REST envelope (status, response, error), Inference nested error, failed predictions.
Prediction errors
Predictions-only route tables, serving/access codes, and resources not duplicated on API errors.
Safety Controls
Learn about the safety controls applied to the model inference.
Inference API Errors
OpenAI-compatible error schema for the /v1/chat/completions, /v1/responses, and /v1/embeddings endpoints.
API-level errors
These occur before the request is queued to prediction serving.
Branch on error_id in your code — never on the message string. Messages are for humans and may change without notice.
400 — Bad Request / infrastructure
The request was malformed or invalid.
error_id | Description | Resolution |
|---|---|---|
INVALID_INPUT | One or more input fields failed validation against the model's input_schema. | Check the model's input schema for required and valid fields. |
INVALID_PARAMETER | A query parameter is out of range (e.g. Predictions list: per_page not 1–50) or a required parameter is missing / invalid on other routes (e.g. Inference: missing model, messages not an array). | Fix the parameter per error.details / param — Inference errors · Prediction errors. |
INVALID_PARAMETER_COMBINATION | Predictions: query parameters or input fields conflict or cannot be used together. | Adjust the request per error.details — Prediction errors. |
UNSUPPORTED_MEDIA_TYPE | The Content-Type header is not application/json. | Set Content-Type: application/json on all POST requests. |
MISSING_REQUIRED_FIELD | A required top-level field (model, input) is absent from the request body. | Include all required fields in your request payload. |
INVALID_DATE_FORMAT | Predictions list filters: from / to must be Y-m-d. | Use calendar dates in YYYY-MM-DD form — Prediction errors. |
INFRASTRUCTURE_ERROR | Content Rejected or Internal infrastructure error, such as a server error or a network issue. | Retry the request. If it persists, check status.skytells.ai for active incidents and contact support. |
INVALID_REQUEST | Malformed or invalid input when using Inference API. | Validate JSON; match model and API schema. Set Content-Type: application/json. |
For Inference-specific validation errors, see Inference API errors.
401 — Unauthorized
Authentication failed or the account cannot make requests.
error_id | Description | Resolution |
|---|---|---|
UNAUTHORIZED | The x-api-key header is missing or the key is invalid / revoked. | Verify your API key in the Console and pass it as x-api-key. |
ACCOUNT_SUSPENDED | Your account has been suspended. | Contact support. |
Never expose your API key in client-side code, public repositories, or logs. If you suspect your key has been compromised, rotate it immediately from the Console.
402 — Payment required
Insufficient balance or credits for the operation.
error_id | Description | Resolution |
|---|---|---|
PAYMENT_REQUIRED | Your account has a negative balance. | Top up your balance in the Billing section. |
INSUFFICIENT_CREDITS | You do not have enough credits to run this prediction. | Purchase additional credits or use a lower-cost model. |
403 — Forbidden
The request was understood but refused.
error_id | Description | Resolution |
|---|---|---|
SECURITY_VIOLATION | The request was flagged as malicious (e.g. prompt injection, abuse patterns). | Review your input for policy violations. Repeated violations may lead to account suspension. |
MODEL_ACCESS_DENIED | Your plan does not include access to this model. | Upgrade your plan or use a model available on your current tier. |
MODEL_NOT_ACTIVE | The model exists but is not active. | Choose another model or retry later — Prediction errors. |
MODEL_NOT_BILLABLE | The model has no billable price configured. | Use a billable model — Prediction errors. |
PARAMETER_NOT_ALLOWED | Input uses a restricted field (e.g. enterprise-only). | Adjust the request body — Prediction errors. |
Repeated SECURITY_VIOLATION errors may result in automatic account suspension. Ensure your inputs comply with the Skytells usage policies.
404 — Not found
The requested resource does not exist.
error_id | Description | Resolution |
|---|---|---|
MODEL_NOT_FOUND | No model exists with the given slug (Predictions list / create — wrong model slug). | Check the slug against the Models reference. |
Note: Predictions GET /v1/predictions/{uuid} does not return 404 for a missing prediction. Use 502 with an error_id in the structured envelope — Prediction errors — Get one.
409 — Conflict
The request conflicts with the current state of a resource.
error_id | Description | Resolution |
|---|---|---|
PREDICTION_NOT_CANCELLABLE | The prediction has already completed, failed, or been cancelled. | No action needed — the prediction is already in a terminal state. |
422 — Unprocessable entity
The body was well-formed but could not be applied (semantic or policy failure).
error_id | Level | Description | Resolution |
|---|---|---|---|
UNPROCESSABLE_ENTITY | API, Prediction Level | The request was well-formed but was unable to be followed due to semantic errors. | Contact support. |
MODERATION_ERROR | API, Prediction Level | The request was well-formed but was unable to be followed due to moderation errors. | Contact support. |
CONTENT_POLICY_VIOLATION | API, Prediction Level | The request was well-formed but was unable to be followed due to content policy violations. | Contact support. |
USE_CASE_NOT_SUPPORTED | API, Prediction Level | The request was well-formed but was unable to be followed due to use case not supported. | Contact support. |
MODEL_NOT_AUTHORIZED | API, Prediction Level | The request was well-formed but was unable to be followed due to model not authorized. | Contact support. |
VALIDATION_ERROR | API | Predictions create failed validation (e.g. missing model or input). | Fix the body; shape: Predictions API structured error. See Prediction errors — Request validation. |
MODEL_NOT_SUPPORTED | API | Model type not supported for this operation (e.g. not image/video/audio). | Use a supported model — Prediction errors. |
For prediction-level failures, the error may appear inside the prediction object rather than only as a top-level API error.
If the prediction returns status: "failed" with an error field, inference failed after the job was accepted. Shape: failed prediction object. Details: Prediction errors — Prediction-level errors.
Common causes:
- The model could not produce output from the given prompt or parameters.
- Safety controls triggered.
- The model is temporarily unavailable.
- The model is not authorized for this request.
- An error at the edge of model serving.
429 — Too many requests
You exceeded a gateway or API-surface limit for your account. Limits apply per account (across API keys) and may be scoped by model, time window, tokens, and route — not one global counter.
Typical causes: burst traffic, tight polling on GET endpoints, or high concurrency on the same model.
See Account tiers for plan ceilings, and Rate limits for x-skytells-ratelimit-* headers and backoff.
error_id | Description | Resolution |
|---|---|---|
RATE_LIMIT_EXCEEDED | Too many requests (or tokens) in the window for this account / model / route. | Use Retry-After when present; otherwise details.reset if returned, or exponential backoff with jitter. Reduce concurrency or spread load. |
Example body (shape may vary slightly by endpoint):
{
"error_id": "RATE_LIMIT_EXCEEDED",
"message": "Too many requests. Please wait before retrying."
}Response headers
| Header | Role |
|---|---|
Retry-After | Optional on 429. When present, whole seconds to wait before retrying. May be omitted when the wait is not positive — do not assume it is always set. |
x-skytells-ratelimit-* | May mirror gateway state on the error response; see Rate limits — Response headers. |
Prefer Retry-After when present. Use exponential backoff and jitter so many clients do not retry in lockstep. For large prompts, watch token headers on 2xx responses to stay under limits before hitting 429. Full semantics and 503 edge cases: Rate limits.
451 — Unavailable for legal reasons
The request was refused due to legal reasons.
error_id | Description | Resolution |
|---|---|---|
LEGAL_REASONS | The request was refused due to legal reasons. | Contact support. |
When you encounter this error, contact support.
500 — Internal server error
An unexpected error occurred on the Skytells backend.
error_id | Description | Resolution |
|---|---|---|
INTERNAL_ERROR | An unhandled server-side error occurred. | Retry the request. If it persists, check status.skytells.ai or contact support. |
MODEL_UNAVAILABLE | The model service is temporarily unavailable. | Retry after a short delay or check API Status. |
5xx errors are often transient. Retry with backoff before escalating. If problems last more than a few minutes, check status.skytells.ai for incidents.
502 — Bad gateway
The prediction serving layer returned an error while running or loading a prediction, or access was denied for a private resource. Responses use the unified API error envelope with HTTP 502 and a stable error_id.
error_id | Description | Resolution |
|---|---|---|
ACCESS_DENIED | Private or non-sharable model, prediction, or resource; or not your prediction. | Do not retry — fix id, model access, or account; see Prediction errors — ACCESS_DENIED. |
| other | Prediction serving runtime failure (error_id in body). | Branch on error_id; see Prediction errors and 502 example. |
503 — Service unavailable
Temporary overload or an empty handler result on Predictions create (e.g. PREDICTION_ERROR). Often safe to retry with backoff.
Resolution: Prediction errors — PREDICTION_ERROR.
Handling errors in code
Error handling
const res = await fetch('https://api.skytells.ai/v1/predictions', {
method: 'POST',
headers: {
'x-api-key': YOUR_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({ model: 'skytells/truefusion-pro', input: { prompt: '...' } }),
});
if (!res.ok) {
const body = await res.json();
const err = body.error;
const error_id = err?.error_id;
const message = err?.message;
switch (error_id) {
case 'INSUFFICIENT_CREDITS':
// redirect to billing
break;
case 'RATE_LIMIT_EXCEEDED':
// implement backoff
break;
default:
console.error(error_id, message);
}
}Error response shapes
Canonical JSON for Inference ({ "error": { ... } }) and unified REST (status, response, error) is on Error objects — Inference error response and Predictions API structured error. Per-error_id behavior for Inference: Inference API errors.
Related
- Error objects — Linkable error JSON shapes (simple body, Inference, Predictions)
- Prediction errors — Predictions API error codes and troubleshooting
- Rate limits — Gateway headers,
Retry-After, and backoff - Inference API errors —
error_idcatalog, resolutions, and code samples - TypeScript SDK Error Handling —
SkytellsErrorclass and SDK error handling patterns - TypeScript SDK Reliability — Automatic retries and timeout configuration
- Predictions API — Creating and managing predictions
- Models API — Model discovery and schemas
- Responsible AI — Content safety policies
How is this guide?
Reference
Complete type reference for all Skytells Inference sub-APIs — Chat, Responses, and Embeddings. Every request parameter, response object, and stream event is defined here.
Prediction Errors
Predictions-only error catalog — routes, `error_id` values, and shapes not repeated on the main API errors page.