API त्रुटियाँ
SandBase मानक HTTP status codes का उपयोग करता है, लेकिन यह एक सार्वभौमिक error body नहीं देता। पहले HTTP status के आधार पर branch करें, फिर उस endpoint के लिए documented response schema parse करें जिसे आपने call किया है। हर error में code, param, message, या request_id होना आवश्यक न मानें।
Response shapes
Core middleware और कई /v1/* endpoints एक flat error लौटाते हैं:
{"error":"organization rate limit exceeded"}Agents platform resources (/v1/agents*, /v1/mcp-connections*, /v1/secrets*, /v1/skills*) एक OpenAI-style object लौटाते हैं जिसमें एक stable code होता है। देखें Agents platform errors:
{"error":{"type":"invalid_request_error","code":"invalid_request","param":null,"message":"invalid request"}}Webhook Events API (/events/webhooks*) {"code":<http status>,"message":"..."} लौटाती है। देखें Webhooks.
OpenAI-compatible endpoints एक OpenAI-compatible envelope बनाए रखते हैं। POST /v1/messages एक Anthropic-compatible envelope बनाए रखता है:
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "max_tokens is required"
}
}सार्वजनिक operation के exact status codes और schemas के लिए OpenAPI specification का उपयोग करें।
HTTP status handling
| Status | सामान्य अर्थ | Client action |
|---|---|---|
400 | अमान्य input या असमर्थित parameter | endpoint और चुने गए model schema का उपयोग करके request ठीक करें। |
401 | credential अनुपस्थित, अमान्य, revoked, या expired है | credential को replace या rotate करें; unchanged request को retry न करें। |
402 | request को fund नहीं किया जा सकता या spending limit पहुँच गई | retry करने से पहले balance या key limit resolve करें। |
403 | credential के पास permission नहीं है, या compatibility endpoint spending failure को 403 पर map करता है | endpoint-specific envelope inspect करें और authorized key का उपयोग करें। |
404 | model या resource caller के लिए unavailable है | current model ID या resource ID verify करें। |
409 | resource state conflict | retry safe है या नहीं तय करने से पहले latest state पढ़ें। |
422 | semantically invalid resource input | documented field values सही करें। |
429 | organization per-minute request limit या concurrency limit | operation को repeat करना safe हो तो bounded backoff और jitter के साथ retry करें। |
500, 502, 503, 504 | SandBase या upstream failure | operation को repeat करना safe हो तभी retry करें। |
हर endpoint इस table में हर status को document नहीं करता। operation का OpenAPI response map authoritative है।
Authentication errors
Documented authentication messages में शामिल हैं:
missing API key in Authorization headerinvalid API keyAPI key has been revokedAPI key has expired
Scope के बाहर उपयोग किया गया scoped key इसके बजाय nested body के साथ 403 लौटाता है: {"error":{"code":"insufficient_scope","message":"API key is not authorized for this endpoint","request_id":"..."}}. Agents platform resources अपने own envelope में वही code लौटाते हैं।
Standard endpoints के लिए Authorization: Bearer $SANDBASE_API_KEY का उपयोग करें। POST /v1/messages x-api-key भी स्वीकार करता है; protocol-compatible Google endpoints अपने supported key headers स्वयं document करते हैं।
Revoked key को फिर से सक्षम नहीं किया जा सकता। एक replacement बनाएं, consuming application को update करें, उसे verify करें, और फिर पुराने key के remaining references हटा दें।
Rate limits
organization rate limit exceeded (429) का अर्थ है कि आपकी organization अपनी LLM requests-per-minute limit तक पहुँच गई है, जिसे उसकी सभी API keys साझा करती हैं। Default आपके account level पर निर्भर करता है; SandBase द्वारा आपकी organization के लिए set की गई limit उसे replace कर देती है। Image और free-model (:free) requests की अपनी per-minute limits होती हैं; उनका 429 message Image rate limit reached या Free model rate limit reached से शुरू होता है और limit तथा उसे बढ़ाने वाले top-up का नाम बताता है। Protocol-compatible endpoints ये errors अपने own envelope में लौटाते हैं। संख्याओं के लिए Rate limits देखें।
यदि response में Retry-After शामिल है, तो उसका पालन करें। अन्यथा bounded exponential backoff with jitter का उपयोग करें। request-smoothing patterns के लिए Rate limits देखें।
Task submissions में दो अतिरिक्त checks होते हैं। organization concurrency limit exceeded (429) का अर्थ है कि आपकी organization के पास पहले से ही account level द्वारा अनुमत जितने tasks हो सकते हैं, उतने in progress हैं; जब कोई running task समाप्त होती है, यह clear हो जाता है। Bronze और Silver पर यह POST /v1/run और /v1/api/* पर हर model type पर लागू होता है, और अन्य endpoints पर video submissions पर भी। Gold और Platinum पर केवल video tasks count किए जाते हैं। insufficient credit for estimated video cost (402) का अर्थ है कि estimated cost आपकी balance plus credit line से अधिक है; retry करने से पहले top up करें। देखें Concurrency limits.
Retry safety
इस decision order का उपयोग करें:
- निर्धारित करें कि operation पहले से externally visible effect उत्पन्न कर चुका है या नहीं।
- एक unchanged
400,401,402,403,404, या422request को retry न करें। 409के लिए, retry करने से पहले current resource state पढ़ें।429और transient5xxresponses को केवल कुछ, bounded times तक retry करें।- create, trigger, upload, या external-action request को दोहराने से पहले, पुष्टि करें कि operation idempotent है या आपका application duplicates को reconcile कर सकता है।
उपयुक्त delay है:
delay = min(base_delay * 2^attempt, max_delay) + random_jitterAgents platform त्रुटियाँ
Agents, Sessions, Skills, MCP connections, और Secrets एक ही envelope लौटाते हैं। अधिकांश codes के लिए, message एक निश्चित, सुरक्षित वाक्य होता है; invalid_request में एक संक्षिप्त व्याख्या हो सकती है, जैसे कौन-सा input shape या option समर्थित नहीं है। message पर नहीं, code पर branch करें।
{"error":{"type":"invalid_request_error","code":"conflict","param":null,"message":"conflicting request"}}type 401 के लिए authentication_error, 5xx के लिए server_error, और अन्यथा invalid_request_error होता है।
| HTTP | code | अर्थ | क्या करें |
|---|---|---|---|
| 400 | invalid_request | गलत स्वरूप वाले या अज्ञात fields, validation विफल, या असमर्थित option | request ठीक करें; बिना बदले retry न करें |
| 400 | skill_not_found | संदर्भित Skill या version उपलब्ध नहीं है | Agent के skills ठीक करें |
| 401 | unauthorized | गायब, अमान्य, या परस्पर विरोधी API key headers | Authorization / X-API-Key जाँचें |
| 402 | spending_limit_exceeded | key spending limit या organization balance समाप्त हो गया | credits जोड़ें या limit बढ़ाएँ |
| 403 | insufficient_scope | key scoped है और Agents resources का उपयोग नहीं कर सकती | Console से बनाई गई standard key का उपयोग करें |
| 403 | org_disabled | organization को Agents चलाने की अनुमति नहीं है | support से संपर्क करें |
| 404 | not_found | resource आपकी organization में मौजूद नहीं है | ID जाँचें |
| 409 | conflict | पुराना row_version, ऐसी state जो बदलाव की अनुमति नहीं देती, या अलग body के साथ पुन: उपयोग किया गया Idempotency-Key | resource फिर से पढ़ें, फिर निर्णय लें |
| 409 | session_input_pending | पहले का input अभी भी deliver हो रहा है | प्रतीक्षा करें; नए key के साथ फिर से न भेजें |
| 409 | session_input_expired | input admission समाप्त हो गया | फिर से भेजने से पहले history जाँचें |
| 409 | session_environment_unavailable | execution environment उपलब्ध नहीं है | प्रतीक्षा करें या नया Session बनाएँ |
| 413 | request_too_large | request body, या उससे frozen Session configuration, size limit से अधिक है | छोटा body भेजें; बिना बदले retry न करें |
| 429 | quota_exceeded | Agents quota पार हो गई | बाद में retry करें |
| 502 | executor_rejected, executor_contract_error | execution layer ने request अस्वीकार की या अप्रत्याशित रूप से उत्तर दिया | Agent configuration जाँचें, फिर retry करें |
| 503 | executor_unavailable, storage_unavailable, skill_unavailable, tenant_unavailable, tenant_provisioning_failed, authorization_unavailable, admission_unavailable, internal_error | कोई dependency अस्थायी रूप से उपलब्ध नहीं है | backoff के साथ और उसी Idempotency-Key के साथ retry करें |
skill_runtime_incompatible भी दिखाई दे सकता है; इसे internal error संदेश के साथ 503 के रूप में लौटाया जाता है।
Streaming विफलताएँ
Stream शुरू होने के बाद, error नए HTTP response के बजाय उस protocol के stream format में आ सकता है। Stream को अधूरा मानें, आपकी application को जितना partial output चाहिए उसे सुरक्षित रखें, और केवल तभी retry करें जब request को फिर से generate करना सुरक्षित हो। यह न मानें कि हर provider एक ही terminal event या finish reason emit करता है।
Operational debugging
endpoint, HTTP status, चुना गया model या resource ID, timestamp, और server द्वारा लौटाया गया कोई भी सुरक्षित request identifier रिकॉर्ड करें। कभी भी authorization headers, API keys, credential values, या संवेदनशील prompt content log न करें।
organization request history inspect करने के लिए Developer → Activities का उपयोग करें। किसी persistent failure की रिपोर्ट करते समय, sanitized request metadata और सबसे छोटा reproducible request शामिल करें।