Content पर जाएं

AI क्लाइंट्स के लिए त्रुटि प्रबंधन ​

SandBase एक सार्वभौमिक त्रुटि schema उजागर नहीं करता। पहले HTTP status पर branch करें, फिर endpoint family के लिए दस्तावेज़ित response shape को parse करें। यह न मानें कि हर response में code, param, request_id, या कोई विशिष्ट message string होती है।

सार्वजनिक response shapes ​

Core /v1/* middleware और कई model या resource 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"}}

OpenAI-compatible gateways एक OpenAI-compatible envelope बनाए रखते हैं। POST /v1/messages Anthropic-compatible envelope बनाए रखता है:

json
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "max_tokens is required"
  }
}

HTTP status handling ​

StatusMeaningClient action
400अमान्य input या असमर्थित parameterचयनित endpoint और model schema का उपयोग करके request को ठीक करें।
401credential अनुपस्थित, अमान्य, revoked, या expired हैcredential को बदलें या rotate करें; बिना बदलाव के retry न करें।
402request को fund नहीं किया जा सकता या spending limit पहुँच गईretry करने से पहले billing या key limits हल करें।
403credential के पास अनुमति नहीं है, या compatibility surface किसी spending failure को 403 पर map करती हैदस्तावेज़ित envelope की जाँच करें और एक authorized key का उपयोग करें।
404model या resource नहीं मिलावर्तमान model name या resource ID सत्यापित करें।
409resource state conflictretry सुरक्षित है या नहीं, यह तय करने से पहले नवीनतम resource state पढ़ें।
429organization per-minute request limit या concurrency limitbounded exponential backoff और jitter के साथ retry करें।
500, 502, 503, 504SandBase या upstream transient failureकेवल तभी retry करें जब operation को दोहराना सुरक्षित हो।

Authentication और rate-limit messages ​

दस्तावेज़ित 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 अपने स्वयं के envelope में वही code लौटाते हैं।

LLM rate-limit message है organization rate limit exceeded (organization की requests-per-minute limit, जो उसके सभी API keys द्वारा साझा की जाती है)। Image और free-model (:free) limits एक ऐसा message लौटाते हैं जो limit और उसे बढ़ाने वाले top-up का नाम बताता है। 429 response में वर्तमान में Retry-After या X-RateLimit-* headers शामिल नहीं होते। Defaults account level पर निर्भर करते हैं; देखें Rate limits और Concurrency limits।

Model और resource lookup ​

Enabled model IDs खोजने के लिए GET /v1/models का उपयोग करें और execution से पहले किसी model की जाँच करने के लिए GET /v1/models/{id_or_name} का उपयोग करें। किसी resource ID को opaque मानें और संबंधित list या get operation से उसे सत्यापित करें। किसी ID prefix से अलग polling URL न बनाएँ।

Retry algorithm ​

Bounded exponential backoff with jitter का उपयोग करें:

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

इन नियमों को लागू करें:

  • 429 को client-computed delay के बाद retry करें;
  • transient 5xx responses को केवल थोड़ी, bounded संख्या में retry करें;
  • किसी अपरिवर्तित 400, 401, 402, 403, या 404 request को retry न करें;
  • किसी भी create, trigger, या external-action request को दोहराने से पहले idempotency जाँचें;
  • stream विफल होने पर partial output बनाए रखें और तय करें कि जारी रखना या पुनः आरंभ करना सुरक्षित है या नहीं;
  • अंतिम HTTP status और sanitized endpoint-specific error को caller तक पहुँचाएँ।

Agents platform errors ​

Agents, Sessions, Skills, MCP connections, और Secrets एक ही envelope लौटाते हैं। अधिकांश codes के लिए, message एक fixed, सुरक्षित वाक्य होता है; invalid_request एक संक्षिप्त explanation दे सकता है, जैसे कौन-सा 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 है।

HTTPcodeMeaningWhat to do
400invalid_requestMalformed या unknown fields, validation विफल, या असमर्थित optionrequest को ठीक करें; बिना बदलाव के retry न करें
400skill_not_foundसंदर्भित Skill या version उपलब्ध नहीं हैAgent's skills को ठीक करें
401unauthorizedMissing, invalid, या conflicting API key headersAuthorization / X-API-Key जाँचें
402spending_limit_exceededKey spending limit या organization balance समाप्तcredits जोड़ें या limit बढ़ाएँ
403insufficient_scopekey scoped है और Agents resources का उपयोग नहीं कर सकतीstandard Console-created 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 message के साथ 503 के रूप में लौटाया जाता है।

Streaming failures ​

Streaming response शुरू होने के बाद, failure नए HTTP status के बजाय protocol के stream format में आ सकता है। stream को incomplete मानें, उसे बंद करें, application के लिए आवश्यक कोई भी partial content बनाए रखें, और केवल तभी retry करें जब request को दोहराना सुरक्षित हो।

यह भी देखें ​

  • Error Codes — सार्वजनिक response formats और सामान्य HTTP statuses
  • Rate limits — 429 handling और request smoothing
  • Errors and retries — implementation patterns
  • Authentication — समर्थित credentials और key lifecycle