API Errors and Limits
Rivya API public error codes، HTTP status values، rate limits، idempotency conflicts، اور retry decisions handle کریں۔
2026/05/11 کو آخری review
Rivya API JSON میں stable public error codes return کرتی ہے۔ error.code value کو integration contract سمجھیں۔
Error Shape
{
"error": {
"code": "api_key_missing",
"message": "A valid Bearer API key is required.",
"requestId": "req_..."
}
}Failed API request investigate کرنے کے لیے Rivya support سے رابطہ کرتے وقت اپنے logs میں requestId رکھیں۔
Stable Error Codes
| Code | HTTP status | Meaning | Suggested action |
|---|---|---|---|
public_api_disabled | 503 | Public API calls temporarily disabled ہیں۔ | بعد میں retry کریں یا Studio manually استعمال کریں۔ |
api_key_missing | 401 | Request میں Bearer API key شامل نہیں تھی۔ | Authorization: Bearer rvya_sk_... بھیجیں۔ |
api_key_invalid | 401 | Key verify نہیں ہو سکتی۔ | Key check کریں اور ضرورت ہو تو rotate کریں۔ |
api_key_revoked | 401 | Key Settings میں revoke ہو چکی ہے۔ | New key create کریں۔ |
api_key_expired | 401 | Key اب valid نہیں رہی۔ | New key create کریں۔ |
api_scope_denied | 403 | Key کے پاس required scope نہیں ہے۔ | Needed scope کے ساتھ key create کریں۔ |
rate_limited | 429 | Current window میں بہت زیادہ requests ہیں۔ | Back off کریں اور بعد میں retry کریں۔ |
validation_failed | 400 | Body، model، prompt، یا params invalid ہیں۔ | اپنی body کو model reference سے compare کریں۔ |
not_found | 404 | Requested task موجود نہیں یا account کی owned نہیں ہے۔ | Public task ID اور account boundary check کریں۔ |
webhook_url_rejected | 400 | Webhook endpoint URL allowed نہیں ہے۔ | Credentials، fragments، localhost، یا private network addresses کے بغیر HTTPS public URL استعمال کریں۔ |
chat_model_not_supported | 400 | Selected model Chat API کے لیے available نہیں ہے۔ | /api/v1/models read کریں اور available chat model choose کریں۔ |
chat_session_conflict | 409 | Chat session اس request کے لیے use نہیں ہو سکتی۔ | Same account اور model کی owned API-created session استعمال کریں۔ |
chat_attachment_not_supported | 400 | Chat attachment supported نہیں ہے۔ | Files API کے ذریعے image upload کریں اور اس کا file_id pass کریں۔ |
idempotency_conflict | 409 | Same idempotency key different input کے ساتھ reuse ہوئی۔ | New key استعمال کریں یا exact same body resend کریں۔ |
insufficient_credits | 402 | Account کے پاس کافی credits نہیں ہیں۔ | Credits add کریں یا lower-cost request choose کریں۔ |
internal_error | 500 | Request complete نہیں ہو سکی۔ | Idempotency کے ساتھ retry کریں یا requestId کے ساتھ support سے رابطہ کریں۔ |
Rate Limits
Rivya ہر API key پر application-level Public API rate limits apply کرتا ہے۔ Default production limit PUBLIC_API_RATE_LIMIT_PER_MINUTE سے configured ہے۔
جب آپ کو rate_limited ملے تو exponential backoff استعمال کریں۔ Tight loop میں retry نہ کریں۔
Idempotent Retries
ہر production POST /api/v1/generations اور POST /api/v1/chat/completions request کے ساتھ Idempotency-Key بھیجیں۔
Recommended pattern:
- ہر logical generation request کے لیے unique key generate کریں
- same key صرف same body retry کرتے وقت reuse کریں
- returned public task ID کو اپنے job record کے ساتھ store کریں
- Chat API کے لیے، اسی conversation کو continue کرنا ہو تو returned
session_idstore کریں - ایک key کو different model، prompt، یا params کے لیے reuse نہ کریں
اگر submission کے بعد network fail ہو جائے تو same body اور same Idempotency-Key کے ساتھ retry کریں۔ Rivya duplicate task create کرنے کے بجائے stored public response return کر سکتا ہے۔
Retry Decisions
ان کو backoff کے ساتھ retry کریں:
public_api_disabledrate_limitedinternal_error- temporary network failures
Input change کیے بغیر ان کو retry نہ کریں:
api_key_invalidapi_key_revokedapi_scope_deniedvalidation_failedwebhook_url_rejectedchat_model_not_supportedchat_session_conflictchat_attachment_not_supportedidempotency_conflictinsufficient_credits
Related Pages
API Credits
سمجھیں کہ Rivya API calls account credits، balance checks، reserved credits، failed task refunds، اور credit troubleshooting کیسے استعمال کرتی ہیں۔
فائلز API
MIME checks، size limits، اور duration tokens کے ساتھ Rivya API generation requests کے لیے image، video، یا audio reference files upload کریں۔