Skip to main content

Errors

HPP Router returns standard HTTP status codes and a JSON error envelope. Handle these in your client to distinguish auth, quota, and upstream failures.

Status codes

CodeMeaningTypical cause
400Bad RequestMalformed body, or an unroutable/unsupported model.
401UnauthorizedMissing or invalid API key. See Authentication.
429Too Many Requests / Quota ExceededRate limit hit, or insufficient quota.
500Internal Server ErrorUnexpected gateway or upstream error.
503Service UnavailableQuota state could not be verified (fail-closed).

Error envelope

Errors are returned as JSON. Two shapes are possible.

Simple form

{
"error": "unauthorized",
"message": "Invalid API key"
}

Structured form (upstream/provider errors)

{
"error": {
"message": "The model is overloaded.",
"type": "upstream_error",
"code": "overloaded",
"provider": "openai",
"upstream_status": 503,
"retryable": true
}
}
FieldMeaning
error.messageHuman-readable description.
error.typeError category.
error.codeMachine-readable code.
error.providerUpstream provider, when the error originated there.
error.upstream_statusThe provider's HTTP status, when applicable.
error.retryableWhether the request can be safely retried.

Smart-routing errors

When using hpprouter/auto, you may encounter:

ErrorCause
400 smart_routing_failedBaskets/tiers/streaming-fallback not configured, or the provider is not allowed.
400 unsupported_modelThe resolved model has no registered pricing.

Handling guidance

  • 401 — fix your API key; do not retry blindly.
  • 429 — back off and retry; if it's a quota issue, top up via HPP Hub.
  • 5xx with retryable: true — retry with exponential backoff.
  • 5xx with retryable: false — surface the error; retrying will not help.