For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
CommunityAPI StatusAPI PricingSign Up
DocumentationAPI ReferencesCookbookIntegrationDeveloper Tools
DocumentationAPI ReferencesCookbookIntegrationDeveloper Tools
  • Getting Started
    • Welcome
    • Quickstart
    • SDKs & Libraries
    • Models
    • Credits & Rate Limits
    • Errors & Troubleshooting
    • Talk to us
    • Pricing
    • Changelog
  • API Guides & Tutorials
LogoLogo
CommunityAPI StatusAPI PricingSign Up
On this page
  • Error response shape
  • HTTP status quick reference
  • SDK handling (Python)
  • SDK handling (JavaScript)
  • Retry with exponential backoff
  • Common pitfalls
  • Support workflow
  • Related pages
Getting Started

Errors & Troubleshooting

||View as Markdown|
Was this page helpful?
Previous

Talk to us

Next
Built with

Use this page when a request fails or behaves unexpectedly. Endpoint reference pages document per-field validation; this page explains what failed, how to fix it, and how to retry safely.

Error response shape

Most REST errors return JSON:

1{
2 "error": {
3 "message": "Human-readable description",
4 "code": "invalid_request_error"
5 }
6}
error.codeTypical HTTP statusMeaning
invalid_api_key_error403Missing, malformed, or unknown API key
invalid_request_error400 / 413 / 422Bad parameters, payload, or file
unprocessable_entity_error422Schema valid but business rule failed
insufficient_quota_error429Credits exhausted
rate_limit_exceeded_error429 / 503Too many requests or high load
internal_server_error500Server-side failure — retry with backoff

Auth failures use HTTP 403, not 401. Treat 403 with invalid_api_key_error as an authentication problem. See Authentication.

HTTP status quick reference

StatusWhen it happensWhat to do
400Invalid body or parametersFix request; do not retry blindly
403Invalid API key (or forbidden)Check error.code and key header
422Validation failed (e.g. wrong field name)Compare with OpenAPI / guides
429Rate limit or quotaBack off; see Credits & Rate Limits
500 / 503Transient server issuesRetry with exponential backoff

SDK handling (Python)

1from sarvamai import SarvamAI
2from sarvamai.core.api_error import ApiError
3
4client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")
5
6try:
7 response = client.speech_to_text.transcribe(
8 file=open("audio.wav", "rb"),
9 model="saaras:v3",
10 mode="transcribe",
11 )
12except ApiError as e:
13 if e.status_code == 403:
14 print("Check SARVAM_API_KEY — auth uses 403, not 401")
15 elif e.status_code == 429:
16 print("Rate limited — retry after delay")
17 else:
18 print(e.status_code, e.body)

SDK handling (JavaScript)

1import { SarvamAIClient } from "sarvamai";
2
3const client = new SarvamAIClient({
4 apiSubscriptionKey: process.env.SARVAM_API_KEY,
5});
6
7try {
8 const response = await client.speechToText.transcribe({
9 file: audioFile,
10 model: "saaras:v3",
11 mode: "transcribe",
12 });
13} catch (err) {
14 // SDK wraps HTTP errors — inspect status and body
15 console.error(err.statusCode, err.body);
16}

Retry with exponential backoff

Use retries only for 429, 500, and 503 — not for 400/403/422.

1import time
2
3def call_with_backoff(fn, max_retries=5):
4 delay = 1.0
5 for attempt in range(max_retries):
6 try:
7 return fn()
8 except ApiError as e:
9 if e.status_code not in (429, 500, 503) or attempt == max_retries - 1:
10 raise
11 time.sleep(delay)
12 delay = min(delay * 2, 60)

Common pitfalls

SymptomLikely causeFix
403 on every callWrong or missing api-subscription-keySet SARVAM_API_KEY; handle 403 not 401
422 on doc digitizationUsed language_code instead of languageUse job_parameters.language — see Document Digitization
400 output_formatSent "markdown"Use "md" or "html" only
405 on doc/STT downloadUsed GETUse POST with job_id + files array
TTS returns base64 stringExpected raw bytesbase64.b64decode(response.audios[0].audio) — see TTS REST
Chat 400Missing modelPass model="sarvam-105b" (or sarvam-30b)
Pronunciation dict JS 400Blob without JSON MIMEUse fetch + FormData workaround — see Pronunciation Dictionary
Batch webhook empty transcriptExpected text in webhookWebhook is JobStatusResponse only — download output JSON files

Support workflow

  1. Note timestamp, endpoint, and error.code from the response body.
  2. Reproduce with curl or SDK using the smallest failing request.
  3. Check API Status for incidents.
  4. Contact support via Talk to us with request ID if available.

Related pages

  • Authentication
  • Credits & Rate Limits
  • Pricing
  • SDKs & Libraries