Skip to main content
Planck AI Gateway automatically tries multiple billing methods to ensure your requests succeed. When one method fails, it falls back to alternatives and returns the most actionable error to help you fix issues quickly.

How Fallback Works

The AI Gateway supports two billing methods:

Pass-Through Billing (PTB)

Pay-as-you-go with Planck credits. Simple, no provider account needed.

Bring Your Own Keys (BYOK)

Use your own provider API keys. You’re billed directly by the provider.
Automatic Fallback: When you configure both methods, the gateway tries BYOK first. If your provider key cannot serve the request, the gateway can fall back to PTB when credits and a managed provider route are available.

Error Priority Logic

When both billing methods fail, the gateway returns the most actionable error to help you resolve the issue:

Priority Order

  1. 403 Forbidden → Critical access issue, contact support
  2. 401 Unauthorized → Fix your provider API key
  3. 400 Bad Request → Fix your request format
  4. 500 Server Error → Provider issue or configuration problem
  5. 429 Rate Limit → Only shown if all attempts hit rate limits
Why this order? If you configured BYOK, errors from your provider keys (401, 500) are more actionable than PTB’s “insufficient credits” (429). You chose BYOK for a reason!

Common Error Scenarios


Fallback Scenarios

Setup: You have a valid provider key configured or providedResult: ✅ Request completes using Bring Your Own KeysError: None - successful response
Setup: Your provider key fails, but you have Planck credits and a managed route is availableResult: ✅ Request completes using Pass-Through BillingError: None - successful response
Setup: Your provider key fails and PTB is unavailable or also failsResult: ❌ Request failsError Returned: The most actionable error from the failed attemptsWhy: If your provider key is invalid, that error is usually more actionable than a generic fallback failure.Example:
Setup: No Planck credits and no provider keys configuredResult: ❌ Request failsError Returned: 429 Insufficient creditsWhy: No alternative billing method availableExample:
Solutions:
  1. Add Planck credits
  2. Configure provider keys
  3. Enable automatic retries with Planck-Retry-Enabled: true to handle transient failures
Retries can help! If you’re experiencing temporary rate limits or server errors, use Planck retry headers to automatically retry failed requests with exponential backoff.

Understanding Error Sources

When you see an error, you can determine which billing method it came from: PTB Errors:
  • 429: “Insufficient credits” → Add credits
  • 403: “Wallet suspended” → Contact support
BYOK Errors:
  • 401: “Invalid API key” → Check provider keys
  • 500: “Provider error” → Check provider status
  • 503: “Service unavailable” → Provider having issues

Best Practices

Configure Both Methods

Set up both PTB and BYOK for maximum reliability. If one fails, the other serves as backup.

Monitor Credit Balance

Keep track of your Planck credits to avoid 429 errors during critical requests.

Enable Automatic Retries

Use Planck retry headers to automatically retry transient errors (429, 500, 503) with exponential backoff.

Log Error Details

Log the full error response to debug provider-specific issues quickly.

Error Handling in Code

Prefer built-in retries: Instead of implementing your own retry logic, use Planck’s automatic retry headers by adding Planck-Retry-Enabled: true to your requests. This handles exponential backoff automatically.

Retry Logic Example

Error Classification


Need Help? If you’re seeing unexpected errors or need assistance configuring fallback, contact us at support@inquantum.ai.