Error Codes

A user-friendly reference for API error responses across the AI endpoints.

Common JSON Error Shape

rNet often returns an HTTP 200 OK status even when an error occurs. In these cases, the actual error status is provided inside the JSON response body using the errorCode field:

json
{
  "message": "Human-readable error message",
  "error": "Human-readable error message",
  "errorCode": 402
}

Your application should always check the errorCode in the response body to determine if the request was successful.

Grouped Error Codes

Each HTTP code appears once, with a clear description and the recommended next step.

HTTPMeaningDescriptionRecommended Action
400Bad requestThe request is missing required data, contains a model name that is not in the supported model list, has a malformed access token, or includes an invalid JSON body.Check the supported model name, access token, and request body before retrying.
401UnauthorizedThe access token signature is invalid or the access token has expired.Ask the user to sign in again or refresh the access token.
402Payment requiredThe account does not have enough available credits for the request, or the billing check failed.Show a billing message and let the user add credits or choose another account.
404Not foundThe requested AI model name does not match a supported model route on this server.Copy a supported model name from the Supported Models page.
422Unprocessable requestThe request is valid JSON, but the selected supported model cannot process this request body.Use the provider-specific body shape for the selected supported model.
429Too many requestsThe request limit has been reached for the current time window.Wait until the rate-limit window resets, then retry.
500Internal server errorThe server could not complete an internal verification, billing, usage, or startup step.Retry later. If it continues, contact rNet support with the request details.
502Bad gatewayThe server could not connect to the upstream AI provider.Retry after a short delay or check provider availability.

Endpoint Notes

/ai uses these errors for non-streaming requests. If the upstream AI provider returns a non-2xx response, rNet passes that provider response through directly.

/ai/stream uses the same pre-start checks before opening the event stream.

Streaming Errors After Start

After HTTP 200 OK and Content-Type: text/event-stream are sent, later failures are delivered as Server-Sent Events because the HTTP status has already been sent:

text
event: billing_error
data: {"message":"Insufficient funds","errorCode":402}

// OR

event: billing_error
data: {"message":"Could not parse usage for billing","errorCode":500}

If the provider fails during the stream, rNet passes through the available chunks and then closes the connection.