Content पर जाएं

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 लौटाते हैं:

json
{"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:

json
{"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 बनाए रखता है:

json
{
  "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 या असमर्थित parameterendpoint और चुने गए model schema का उपयोग करके request ठीक करें।
401credential अनुपस्थित, अमान्य, revoked, या expired हैcredential को replace या rotate करें; unchanged request को retry न करें।
402request को fund नहीं किया जा सकता या spending limit पहुँच गईretry करने से पहले balance या key limit resolve करें।
403credential के पास permission नहीं है, या compatibility endpoint spending failure को 403 पर map करता हैendpoint-specific envelope inspect करें और authorized key का उपयोग करें।
404model या resource caller के लिए unavailable हैcurrent model ID या resource ID verify करें।
409resource state conflictretry safe है या नहीं तय करने से पहले latest state पढ़ें।
422semantically invalid resource inputdocumented field values सही करें।
429organization per-minute request limit या concurrency limitoperation को repeat करना safe हो तो bounded backoff और jitter के साथ retry करें।
500, 502, 503, 504SandBase या upstream failureoperation को repeat करना safe हो तभी retry करें।

हर endpoint इस table में हर status को document नहीं करता। operation का OpenAPI response map authoritative है।

Authentication errors ​

Documented authentication messages में शामिल हैं:

  • missing API key in Authorization header
  • invalid API key
  • API key has been revoked
  • API 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 का उपयोग करें:

  1. निर्धारित करें कि operation पहले से externally visible effect उत्पन्न कर चुका है या नहीं।
  2. एक unchanged 400, 401, 402, 403, 404, या 422 request को retry न करें।
  3. 409 के लिए, retry करने से पहले current resource state पढ़ें।
  4. 429 और transient 5xx responses को केवल कुछ, bounded times तक retry करें।
  5. create, trigger, upload, या external-action request को दोहराने से पहले, पुष्टि करें कि operation idempotent है या आपका application duplicates को reconcile कर सकता है।

उपयुक्त delay है:

text
delay = min(base_delay * 2^attempt, max_delay) + random_jitter

Agents platform त्रुटियाँ ​

Agents, Sessions, Skills, MCP connections, और Secrets एक ही envelope लौटाते हैं। अधिकांश codes के लिए, message एक निश्चित, सुरक्षित वाक्य होता है; invalid_request में एक संक्षिप्त व्याख्या हो सकती है, जैसे कौन-सा input shape या option समर्थित नहीं है। message पर नहीं, code पर branch करें।

json
{"error":{"type":"invalid_request_error","code":"conflict","param":null,"message":"conflicting request"}}

type 401 के लिए authentication_error, 5xx के लिए server_error, और अन्यथा invalid_request_error होता है।

HTTPcodeअर्थक्या करें
400invalid_requestगलत स्वरूप वाले या अज्ञात fields, validation विफल, या असमर्थित optionrequest ठीक करें; बिना बदले retry न करें
400skill_not_foundसंदर्भित Skill या version उपलब्ध नहीं हैAgent के skills ठीक करें
401unauthorizedगायब, अमान्य, या परस्पर विरोधी API key headersAuthorization / X-API-Key जाँचें
402spending_limit_exceededkey spending limit या organization balance समाप्त हो गयाcredits जोड़ें या limit बढ़ाएँ
403insufficient_scopekey scoped है और Agents resources का उपयोग नहीं कर सकतीConsole से बनाई गई standard key का उपयोग करें
403org_disabledorganization को Agents चलाने की अनुमति नहीं हैsupport से संपर्क करें
404not_foundresource आपकी organization में मौजूद नहीं हैID जाँचें
409conflictपुराना row_version, ऐसी state जो बदलाव की अनुमति नहीं देती, या अलग body के साथ पुन: उपयोग किया गया Idempotency-Keyresource फिर से पढ़ें, फिर निर्णय लें
409session_input_pendingपहले का input अभी भी deliver हो रहा हैप्रतीक्षा करें; नए key के साथ फिर से न भेजें
409session_input_expiredinput admission समाप्त हो गयाफिर से भेजने से पहले history जाँचें
409session_environment_unavailableexecution environment उपलब्ध नहीं हैप्रतीक्षा करें या नया Session बनाएँ
413request_too_largerequest body, या उससे frozen Session configuration, size limit से अधिक हैछोटा body भेजें; बिना बदले retry न करें
429quota_exceededAgents quota पार हो गईबाद में retry करें
502executor_rejected, executor_contract_errorexecution layer ने request अस्वीकार की या अप्रत्याशित रूप से उत्तर दियाAgent configuration जाँचें, फिर retry करें
503executor_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 शामिल करें।

यह भी देखें ​