API Errors
Since the Tinfoil SDK wraps the OpenAI client, standard API errors (AuthenticationError, RateLimitError, etc.) pass through unchanged. The SDK re-exports them so you can import and catch them directly. See the OpenAI error documentation for details.
Example: handling an AuthenticationError
Example: handling an AuthenticationError
Client Errors
Tinfoil SDKs do more than just forwarding requests. They also verify attestations, pin certificates, and encrypt payloads before any data leaves your machine. This means you may encounter client-side errors related to attestation and security in addition to the usual server errors from the API. The SDK exposes typed errors so you can catch these failures and recover gracefully.TinfoilError, which extends the native Error class. Each error includes a message string and an optional cause property containing the underlying error.
| Error | Cause | What to do |
|---|---|---|
ConfigurationError | Bad or missing client options | Fix your code. Retrying will not help. |
FetchError | Network issue fetching attestation bundle | Call ready() again to retry. |
AttestationError | Attestation verification failed | Call reset() then ready(). |
ConfigurationError
ConfigurationError
Thrown when the client is set up incorrectly. Common causes:
- Missing required options (
serverURL,configRepo,apiKey) - Invalid option values
- Using the wrong client type for your environment
- Calling methods before the client is ready
FetchError
FetchError
Thrown when the SDK cannot retrieve attestation materials from the attestation transparency cache (ATC). Common causes:
- Network unreachable or DNS failure
- HTTP errors (404, 500, etc.)
- Response timeout
- Malformed response (bad JSON, unexpected schema)
ready() again will make a fresh attempt.AttestationError
AttestationError
Thrown when attestation verification fails. This is a security-relevant error. Common causes:
- Malformed attestation report or invalid encoding
- Sigstore signature verification failure
- Hardware certificate chain invalid
- Attestation report signature invalid
- Measurement mismatch (enclave code does not match the signed release)
- Policy violation (e.g. debug mode enabled, TCB level too low)
- Key binding mismatch (transport keys do not match attested keys)
AttestationError, call reset() to discard the current attestation state, then ready() to fetch and verify a fresh bundle. If the error persists, it may indicate a genuine security issue with the endpoint.Accessing the Underlying Cause
All errors support the standardcause property. When the SDK wraps a lower-level error, the original is available for debugging:
At the transport layer, HPKE and key-related errors trigger an automatic reset-and-retry once before surfacing to your code.

