Error Response Format
Errors return a JSON body with anerror object and an HTTP status code:
type field is the machine-readable discriminator.
type | Meaning |
|---|---|
authentication_error | Missing or invalid API key. |
invalid_request_error | Malformed request body or unsupported parameter. |
model_not_found | The requested model id is unavailable. |
upstream_error | The upstream provider failed or timed out. |
Status Codes
| Status | Meaning |
|---|---|
400 | Bad request, unknown model, or invalid parameter. |
401 | Missing or invalid API key. |
403 | Forbidden, for example insufficient credits. |
429 | Rate limited. |
500 | Gateway server error. |
502 | Upstream provider unavailable. |
503 | Service temporarily unavailable. |
SDK Handling
Retry Policy
Retry only transient errors:- Retry
429,500,502, and503with exponential backoff. - Do not retry
400or401until you fix the request or key. - If a confidential upstream verification fails, treat it as a failed security condition, not a normal retry loop, unless the API response documents it as transient.
Common Cases
Invalid API key
Invalid API key
Confirm the
Authorization: Bearer <API_KEY> header, check for whitespace, and create a fresh key from the Phala dashboard if needed.Unknown model
Unknown model
List valid model ids with
GET /v1/models. Do not assume a model id exists until it appears in the catalog.Unsupported parameter
Unsupported parameter
Some models support
max_tokens; others require max_completion_tokens. Check supported_parameters in /v1/models.Rate limited
Rate limited
Back off and retry. For sustained high volume, use dedicated models or dedicated GPU TEE capacity.
Upstream unavailable
Upstream unavailable
Best Practices
- Branch on HTTP status and
error.type, not message text. - Keep API keys in environment variables or a secret manager.
- Never log request bodies for sensitive prompts.
- Verify
x-receipt-idwhen the response is security-sensitive.

