Error Response Format
Errors return a JSON body with anerror object and an HTTP status code:
type field is the machine-readable discriminator.
Status Codes
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.No zero-data-retention route
No zero-data-retention route
A request with
provider: {"zdr": true} returns 404 when the selected model has no available zero-data-retention route. Query GET /v1/models?zdr=true before sending sensitive prompts that require this property.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.
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.

