Errors & troubleshooting

Identify the failing layer, correct the request, and retry only when it can help.

API guide · Reviewed 11 October 2026

Start with the request

SymptomWhat to check
404 at /api/Use https://formalengines.com/inference/v1/chat/completions for raw HTTP.
401 invalid_api_keyUse the complete key after “Bearer ”, not a masked value or fingerprint.
Malformed JSON / shell errorUse a single JSON object. A single quote inside a shell single-quoted payload ends that string. Use the quickstart heredoc.
No visible answerCheck finish_reason, reasoning output, and max_tokens. A very small budget can be exhausted before the answer.
Unknown modelCopy an exact model ID from GET /models.
SDK sends extra_body as a JSON fieldWith raw HTTP, put model-specific options at the top level. The SDK merges extra_body for you.

HTTP status codes

StatusMeaningAction
400 / 422Invalid input, unsupported parameter, or context overflowInspect error.code and message; correct the request.
401Missing, invalid, expired, or revoked keyCheck credentials or create a new key.
402Insufficient available credit for the request reservationCheck balance and holds; add credit or reduce the output reservation.
403Account not permitted to make the requestContact support; key rotation alone will not help.
404Unknown model or incorrect endpointCheck the URL and model ID.
413Request body too largeReduce the body size.
429Rate, concurrency, daily-spend, or admission limitInspect the error. Honor Retry-After when provided; reduce concurrency. A daily-spend limit needs a reset or limit change.
502 / 503 / 504Upstream or capacity failure / timeoutRetry transient failures with bounded exponential backoff and jitter.
Illustrative OpenAI-style error
{
  "error": {
    "message": "The request exceeds the model context window.",
    "type": "invalid_request_error",
    "param": null,
    "code": "context_length_exceeded"
  }
}

Retry deliberately

Do not retry authentication errors, malformed JSON, or an unchanged oversized request. For transient capacity errors, use a finite retry budget, exponential backoff with jitter, and Retry-After when supplied. Many SDKs already retry certain failures; account for that before adding another retry loop.

After a network timeout, a request may already have reached the model. There is no documented inference idempotency guarantee. Repeated requests may be separately billed. Streaming clients must also handle errors after the initial HTTP headers.

Include a request ID

Keep the HTTP status, model ID, timestamp, and response x-request-id when present. Send those details and a sanitized request to vatsal@formalengines.com. Never include your API key. Some rejections occur before a request ID is assigned.

Need a hand? Contact support with your request ID. Keep your API key private.