Possible Errors

When integrating with BHASHINI APIs, requests are validated at both the API Gateway (Dhruva) layer and the individual AI Model Inference layer. When an issue occurs, the server returns an HTTP status code accompanied by a structured JSON error payload.

Standard Error Response Format

The gateway returns standard JSON error responses formatted as follows:

Gateway Error Response Format
{
  "status": 400,
  "error": "Bad Request",
  "message": "Invalid sourceLanguage 'eng'. Expected 2-letter ISO-639-1 code (e.g. 'en').",
  "details": {
    "field": "inputData.sourceLanguage",
    "received": "eng",
    "expectedFormat": "ISO-639-1"
  },
  "timestamp": "2026-09-12T12:00:00.000Z"
}

HTTP Status Codes & Diagnostic Guide

Status CodeError NameRoot Cause & Actionable Resolution
400Bad Request
Cause:Request JSON schema violation, missing mandatory keys (e.g. taskType, serviceId, sourceLanguage), or malformed parameters.
Resolution:Validate request body against the respective Pipeline Compute schema. Ensure language codes adhere to ISO-639-1 standards.
401Unauthorized
Cause:Missing, malformed, or expired inference API key in the Authorization header.
Resolution:Ensure your API key is passed verbatim without enclosing quotes or Bearer prefix. Verify active keys in the BHASHINI Dashboard.
403Forbidden
Cause:The organization account is pending DIBD verification, or the requested service ID is restricted for this tier.
Resolution:Contact the DIBD support team (digitalindiabhashinidivision@gmail.com) to verify enterprise access permissions.
404Not Found
Cause:The specified pipelineId or serviceId does not exist, or the target endpoint URL is mistyped.
Resolution:Verify the endpoint base URL (https://dhruva-api.bhashini.gov.in). Re-query the Pipeline Search API to obtain active pipeline and service IDs.
413Payload Too Large
Cause:Input payload exceeds gateway limits (text > 5,000 characters or audio file > 50 MB).
Resolution:Split long paragraphs into sentence batches, or segment audio recordings into 30–60 second chunks before dispatching requests.
422Unprocessable Entity
Cause:The server received the payload but could not process the media content (corrupted WAV header, invalid base64 string, or unsupported sampling rate).
Resolution:Re-encode audio to 16 kHz mono 16-bit PCM WAV. Validate base64 strings with a strict RFC 4648 decoder.
429Too Many Requests
Cause:Rate limiting triggered due to exceeding requests-per-second (RPS) or concurrency caps.
Resolution:Implement exponential backoff with random jitter in client code. Request rate limit quota increases for high-volume enterprise deployments.
500 / 503Internal Server / Service Unavailable
Cause:Downstream AI model worker pod timeout, GPU out-of-memory, or gateway node restart.
Resolution:Transient server-side condition. Retry after a short delay (1–3 seconds) using exponential backoff.
504Gateway Timeout
Cause:The model did not respond within the gateway's time limit, usually because of long audio, a large input or a busy model.
Resolution:Retry with exponential backoff. For long audio or large inputs, split the request into shorter segments.

Resilient Retry Implementation

Production integrations should always implement Exponential Backoff with Full Jitter for transient 429, 500, 502, 503, and 504 errors:

fetchWithRetry.js
async function fetchWithRetry(url, options, maxRetries = 3, baseDelayMs = 1000) {
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
    try {
      const response = await fetch(url, options);
      
      // If success or non-retryable 4xx client error, return immediately
      if (response.ok || (response.status >= 400 && response.status < 500 && response.status !== 429)) {
        return response;
      }


      if (attempt === maxRetries) {
        return response;
      }
    } catch (err) {
      if (attempt === maxRetries) throw err;
    }


    // Exponential backoff with random jitter: (2^attempt * baseDelay) + random(0, 500)
    const delay = Math.pow(2, attempt) * baseDelayMs + Math.random() * 500;
    console.warn(`[Retry] Attempt ${attempt + 1} failed. Retrying in ${Math.round(delay)}ms...`);
    await new Promise((res) => setTimeout(res, delay));
  }
}