Error Response Format
All errors return a consistent JSON structure:Complete Error Reference
| HTTP | Type | Cause | Fix |
|---|---|---|---|
400 | bad_request | Malformed JSON, invalid parameters, unsupported param for model | Check request body against the API reference |
401 | auth_error | Missing, invalid, or revoked API key | Verify your Authorization: Bearer sk-samurai-... header |
402 | insufficient_credits | PAYG credit balance is $0.00 | Add credits at dashboard/billing |
403 | permission_denied | Model requires a higher plan tier | Check pricing plans and upgrade |
404 | not_found | Model ID doesn’t exist or is unavailable | Check models list for valid IDs |
422 | validation_error | Parameter values failed validation (e.g. temperature > 2) | Check parameter ranges in the docs |
429 | rate_limit_exceeded | Daily request limit hit for your plan | Wait until midnight UTC or upgrade plan |
500 | server_error | Internal server error | Retry with exponential backoff |
503 | model_unavailable | Upstream provider (OpenAI, Anthropic, etc.) is down | Try a fallback model or retry |
Common Errors & Solutions
401 — Invalid API Key
401 — Invalid API Key
Symptoms: Every request fails immediately with
auth_errorCauses & Fixes:- Key starts with
sk-samurai-but was revoked → Create a new key in the dashboard - Passing
OPENAI_API_KEYinstead of your Samurai key → UseSAMURAI_API_KEY - Extra spaces or newlines in the key → Strip whitespace with
.strip() - Header format wrong → Must be
Authorization: Bearer sk-samurai-YOUR_KEY
402 — Insufficient Credits
402 — Insufficient Credits
Symptoms: Requests to Pro models (o1, Sora, DALL-E 3 HD) fail with
insufficient_creditsFix:- Go to Dashboard → Billing
- Purchase PAYG credits ($5 minimum)
- Credits are applied instantly
403 — Permission Denied
403 — Permission Denied
Symptoms: Request works for some models but not othersCause: Your current plan doesn’t include that model class.
Fix: Upgrade at Dashboard → Billing
| Model Class | Minimum Plan |
|---|---|
| Open-source (Llama, Mistral, DeepSeek) | Free |
| Closed-source (GPT-4o, Claude, Gemini) | Free (limited) |
| Pro (o1, Sora, DALL-E 3 HD) | Pro + PAYG credits |
429 — Rate Limit Exceeded
429 — Rate Limit Exceeded
Symptoms: Requests fail mid-session, especially for high-volume usePlan limits (requests per day):
Fix: Implement exponential backoff (see below) or upgrade your plan.
| Plan | Open-source | Closed-source | Pro |
|---|---|---|---|
| Free | 150 | 70 | 0 |
| Starter | 2,000 | 1,000 | 0 |
| Pro | 4,500 | 2,500 | 650 |
503 — Model Unavailable
503 — Model Unavailable
Retry with Exponential Backoff
Model Fallback Pattern
Node.js Error Handling
Error Response Format
All errors return a consistent JSON structure:Error Code Reference
| HTTP Status | Type | Cause | Solution |
|---|---|---|---|
400 | bad_request | Invalid request parameters | Check your request body |
401 | auth_error | Missing or invalid API key | Verify your API key |
402 | insufficient_credits | PAYG credit balance depleted | Add credits in dashboard |
403 | permission_denied | Model requires higher plan | Upgrade your plan |
404 | not_found | Model ID doesn’t exist | Check /reference/models |
422 | validation_error | Request failed validation | Check parameter types |
429 | rate_limit_exceeded | Daily request limit hit | Wait until midnight UTC |
500 | server_error | Internal server error | Retry with backoff |
503 | model_unavailable | Upstream provider is down | Try again or use another model |
Common Errors & Fixes
401 - Invalid API Key
401 - Invalid API Key
Problem: Your API key is missing, malformed, or revoked.Fix: Check that:
- You’re passing
Authorization: Bearer sk-samurai-YOUR_KEY - The key hasn’t been deleted from your dashboard
- There are no leading/trailing spaces in your key
403 - Permission Denied
403 - Permission Denied
Problem: The model requires a higher subscription plan.Fix: Check which plan includes your target model at /reference/pricing. Upgrade from your dashboard.
402 - Insufficient Credits
402 - Insufficient Credits
Problem: Your PAYG credit balance is $0.Fix: Add credits from Dashboard → Billing. Pro models require PAYG credits on top of your subscription.
429 - Rate Limit Exceeded
429 - Rate Limit Exceeded
Problem: You’ve hit your daily request limit.Fix: Wait until midnight UTC for the limit to reset, implement request queuing, or upgrade your plan.
503 - Model Unavailable
503 - Model Unavailable