Some AI models, particularly large ones like Sunflower or Whisper, may take time to process requests. Server-side timeouts (e.g., 408, 504) can occur if the request takes too long.
For large operations (like long audio files), consider using the asynchronous workflows or signed URL upload methods where available to avoid timeouts.
Several legacy endpoints (e.g. /tasks/stt, /tasks/tts, /tasks/sunflower_inference) still work but are deprecated. When you call one, the API returns Deprecation and Sunset response headers indicating that the route will be removed in a future release.
Inspect these headers in your client and migrate to the unified endpoints — /tasks/audio/transcriptions, /tasks/audio/speech, and /tasks/chat/completions — before the sunset date.
import requestsimport timedef call_api_robustly(url, headers, data, max_retries=3): for attempt in range(max_retries): response = requests.post(url, headers=headers, json=data) if response.status_code == 200: return response.json() if response.status_code in [429, 503]: wait_time = (2 ** attempt) # Exponential backoff print(f"Rate limited. Retrying in {wait_time}s...") time.sleep(wait_time) continue # Non-retryable error print(f"Error {response.status_code}: {response.text}") break return None
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Sunbird AI API","colors":{"primary":"#DC7828","light":"#DC7828","dark":"#DC7828"},"logo":{"light":"https://mintcdn.com/analyticssunbirdai/p5dqIvZVDHCsf_tB/logo/logo_light.png?fit=max\u0026auto=format\u0026n=p5dqIvZVDHCsf_tB\u0026q=85\u0026s=9e35440a8c31879452f811688f2db71e","dark":"https://mintcdn.com/analyticssunbirdai/o2R3vhcekRoJdUva/logo/logo_dark.png?fit=max\u0026auto=format\u0026n=o2R3vhcekRoJdUva\u0026q=85\u0026s=fb5b0b475c6531819f7499e09688219c"},"favicon":"https://mintcdn.com/analyticssunbirdai/lsnNQ_5VSHOkM4yt/sunbird-favicon.jpg?fit=max\u0026auto=format\u0026n=lsnNQ_5VSHOkM4yt\u0026q=85\u0026s=d09e99396a7680a793c8da05d92eb604","navbar":{"primary":{"type":"button","label":"Sunflower","href":"https://sunflower.sunbird.ai"}},"footer":{"socials":{"github":"https://github.com/SunbirdAI","x":"https://x.com/SunbirdAI","website":"https://sunbird.ai","linkedin":"https://www.linkedin.com/company/sunbird-ai"}},"fonts":{"family":"Open Sans"},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"analyticssunbirdai","hasAudioNarration":false,"actualSubdomain":"analyticssunbirdai","customDomains":["docs.sunbird.ai"],"gitSource":{"type":"github","owner":"sunbirdai","repo":"official-docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6ab4d4e96db8efdbd0b21b7a","collectionId":"9f1fc6af-58ff-4855-a1da-67d91a963e4c","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6ab4d4e96db8efdbd0b21b7a"},"entitlements":{},"buildId":"6ab4d4e96db8efdbd0b21b7a","clientVersion":"0.0.4054","searchFilterCounts":[{"language":"default","tag":"API Reference","count":23},{"language":"default","tag":"API Reference (Legacy)","count":19},{"language":"default","tag":"General","count":13},{"language":"default","tag":"Authentication","count":11},{"language":"default","tag":"Legacy Text to Speech","count":11},{"language":"default","tag":"Guides","count":7},{"language":"default","tag":"Resources","count":6},{"language":"default","tag":"Models","count":5},{"language":"default","tag":"Sunflower LLM","count":5},{"language":"default","tag":"Legacy Speech to Text","count":4}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[],"googleFontsInlined":true},"customCss":[],"page":{"pagePath":"guides/error-handling","slug":"/guides/error-handling","pageMetadata":{"title":"Error Handling","description":"Best practices for handling API errors","href":"/guides/error-handling"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Best practices for handling API errors\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,..._provideComponents(),...props.components},{CodeBlock,Heading,Table,Tip}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Tip)_missingMdxReference(`Tip`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`The Sunbird AI API uses standard HTTP status codes to indicate the success or failure of requests.`}),`\n`,_jsx(Heading,{level:`2`,id:`common-status-codes`,children:`Common Status Codes`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{style:{textAlign:`left`},children:`Code`}),_jsx(_components.th,{style:{textAlign:`left`},children:`Description`}),_jsx(_components.th,{style:{textAlign:`left`},children:`Action`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,style:{textAlign:`left`},children:_jsx(_components.code,{children:`200`})}),_jsxs(_components.td,{style:{textAlign:`left`},children:[_jsx(_components.strong,{children:`OK`}),`. The request was successful.`]}),_jsx(_components.td,{style:{textAlign:`left`},children:`Process the response body.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,style:{textAlign:`left`},children:_jsx(_components.code,{children:`400`})}),_jsxs(_components.td,{style:{textAlign:`left`},children:[_jsx(_components.strong,{children:`Bad Request`}),`. Invalid parameters or malformed JSON.`]}),_jsx(_components.td,{style:{textAlign:`left`},children:`Check your request payload and parameters.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,style:{textAlign:`left`},children:_jsx(_components.code,{children:`401`})}),_jsxs(_components.td,{style:{textAlign:`left`},children:[_jsx(_components.strong,{children:`Unauthorized`}),`. Missing or invalid API token.`]}),_jsxs(_components.td,{style:{textAlign:`left`},children:[`Verify your `,_jsx(_components.code,{children:`Authorization`}),` header.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,style:{textAlign:`left`},children:_jsx(_components.code,{children:`404`})}),_jsxs(_components.td,{style:{textAlign:`left`},children:[_jsx(_components.strong,{children:`Not Found`}),`. The endpoint or resource does not exist.`]}),_jsx(_components.td,{style:{textAlign:`left`},children:`Check the URL path.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,style:{textAlign:`left`},children:_jsx(_components.code,{children:`429`})}),_jsxs(_components.td,{style:{textAlign:`left`},children:[_jsx(_components.strong,{children:`Too Many Requests`}),`. Rate limit exceeded.`]}),_jsxs(_components.td,{style:{textAlign:`left`},children:[`Implement backoff and retry (see `,_jsx(_components.a,{href:`/guides/rate-limits`,children:`Rate Limits`}),`).`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,style:{textAlign:`left`},children:_jsx(_components.code,{children:`500`})}),_jsxs(_components.td,{style:{textAlign:`left`},children:[_jsx(_components.strong,{children:`Server Error`}),`. Internal system issue.`]}),_jsx(_components.td,{style:{textAlign:`left`},children:`Retry the request later.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,style:{textAlign:`left`},children:_jsx(_components.code,{children:`503`})}),_jsxs(_components.td,{style:{textAlign:`left`},children:[_jsx(_components.strong,{children:`Service Unavailable`}),`. Model is loading or overloaded.`]}),_jsx(_components.td,{style:{textAlign:`left`},children:`Retry with exponential backoff.`})]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`timeouts`,children:`Timeouts`}),`\n`,_jsxs(_components.p,{children:[`Some AI models, particularly large ones like Sunflower or Whisper, may take time to process requests. Server-side timeouts (e.g., `,_jsx(_components.code,{children:`408`}),`, `,_jsx(_components.code,{children:`504`}),`) can occur if the request takes too long.`]}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[`For large operations (like long audio files), consider using the `,_jsx(_components.strong,{children:`asynchronous workflows`}),` or `,_jsx(_components.strong,{children:`signed URL`}),` upload methods where available to avoid timeouts.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`deprecation-headers`,children:`Deprecation Headers`}),`\n`,_jsxs(_components.p,{children:[`Several legacy endpoints (e.g. `,_jsx(_components.code,{children:`/tasks/stt`}),`, `,_jsx(_components.code,{children:`/tasks/tts`}),`, `,_jsx(_components.code,{children:`/tasks/sunflower_inference`}),`) still work but are `,_jsx(_components.strong,{children:`deprecated`}),`. When you call one, the API returns `,_jsx(_components.code,{children:`Deprecation`}),` and `,_jsx(_components.code,{children:`Sunset`}),` response headers indicating that the route will be removed in a future release.`]}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[`Inspect these headers in your client and migrate to the unified endpoints — `,_jsx(_components.code,{children:`/tasks/audio/transcriptions`}),`, `,_jsx(_components.code,{children:`/tasks/audio/speech`}),`, and `,_jsx(_components.code,{children:`/tasks/chat/completions`}),` — before the sunset date.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`python-example`,children:`Python Example`}),`\n`,_jsx(_components.p,{children:`Here is a robust way to handle errors in Python:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`21`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`21`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` requests`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` time`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` call_api_robustly`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`url`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`headers`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`data`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`max_retries`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`3`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` for`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` attempt `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`in`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` range`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(max_retries):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` response `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` requests.post(url, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`headers`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`headers, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`json`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`data)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` response.status_code `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`==`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 200`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` response.json()`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` response.status_code `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`in`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`429`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`503`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` wait_time `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`2`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` **`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` attempt) `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Exponential backoff`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Rate limited. Retrying in `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`wait_time`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`s...\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` time.sleep(wait_time)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` continue`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # Non-retryable error`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Error `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`response.status_code`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`response.text`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` break`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` None`})]}),`\n`]})})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Error Handling","description":"Best practices for handling API errors","href":"/guides/error-handling"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Common Status Codes","slug":"common-status-codes","depth":2,"children":[]},{"title":"Timeouts","slug":"timeouts","depth":2,"children":[]},{"title":"Deprecation Headers","slug":"deprecation-headers","depth":2,"children":[]},{"title":"Python Example","slug":"python-example","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"analyticssunbirdai","siteName":"Sunbird AI API","title":"Error Handling - Sunbird AI API","navMaps":{"firstHrefInVersion":{"v2.1":{"href":"/guides/error-handling","matchLevel":0},"v1":{"href":"/guides/error-handling","matchLevel":0}},"firstHrefInLanguage":{}},"lastModified":"2026-06-18T11:08:32.543Z","originalFileLocation":"guides/error-handling.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Best practices for handling API errors\">\u003cmeta data-mint-head name=\"application-name\" content=\"Sunbird AI API\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/analyticssunbirdai/X6F_A1IF4FmJppsS/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/analyticssunbirdai/X6F_A1IF4FmJppsS/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/analyticssunbirdai/X6F_A1IF4FmJppsS/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/analyticssunbirdai/X6F_A1IF4FmJppsS/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/analyticssunbirdai/X6F_A1IF4FmJppsS/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/analyticssunbirdai/X6F_A1IF4FmJppsS/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/analyticssunbirdai/X6F_A1IF4FmJppsS/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/analyticssunbirdai/X6F_A1IF4FmJppsS/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/analyticssunbirdai/X6F_A1IF4FmJppsS/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Error Handling - Sunbird AI API\">\u003cmeta data-mint-head property=\"og:description\" content=\"Best practices for handling API errors\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Sunbird AI API\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.sunbird.ai/guides/error-handling\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://analyticssunbirdai.mintlify.app/_mintlify/api/og/v2?division=Guides\u0026amp;title=Error+Handling\u0026amp;description=Best+practices+for+handling+API+errors\u0026amp;theme=98c2a0250bceba930b99aceb\u0026amp;signature=ed3bacd25a896cca497e26bb7c2a4766c59ea6c59622dbbd969bee332bcbb203\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Error Handling - Sunbird AI API\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Best practices for handling API errors\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://analyticssunbirdai.mintlify.app/_mintlify/api/og/v2?division=Guides\u0026amp;title=Error+Handling\u0026amp;description=Best+practices+for+handling+API+errors\u0026amp;theme=98c2a0250bceba930b99aceb\u0026amp;signature=ed3bacd25a896cca497e26bb7c2a4766c59ea6c59622dbbd969bee332bcbb203\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/analyticssunbirdai/X6F_A1IF4FmJppsS/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Sunbird AI API\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#DC7828\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.sunbird.ai/guides/error-handling\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/guides/error-handling.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.sunbird.ai/#organization\",\"name\":\"Sunbird AI API\",\"url\":\"https://docs.sunbird.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/analyticssunbirdai/p5dqIvZVDHCsf_tB/logo/logo_light.png?fit=max\u0026auto=format\u0026n=p5dqIvZVDHCsf_tB\u0026q=85\u0026s=9e35440a8c31879452f811688f2db71e\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.sunbird.ai#website\",\"name\":\"Sunbird AI API\",\"url\":\"https://docs.sunbird.ai\",\"publisher\":{\"@id\":\"https://docs.sunbird.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.sunbird.ai/guides/error-handling#webpage\",\"url\":\"https://docs.sunbird.ai/guides/error-handling\",\"name\":\"Error Handling\",\"description\":\"Best practices for handling API errors\",\"dateModified\":\"2026-06-18T11:08:32.543Z\",\"isPartOf\":{\"@id\":\"https://docs.sunbird.ai#website\"},\"breadcrumb\":{\"@id\":\"https://docs.sunbird.ai/guides/error-handling#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.sunbird.ai/guides/error-handling#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Guides\",\"item\":\"https://docs.sunbird.ai/guides/speech-to-text\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Error Handling\",\"item\":\"https://docs.sunbird.ai/guides/error-handling\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.sunbird.ai/guides/error-handling#article\",\"headline\":\"Error Handling\",\"name\":\"Error Handling\",\"description\":\"Best practices for handling API errors\",\"url\":\"https://docs.sunbird.ai/guides/error-handling\",\"mainEntityOfPage\":{\"@id\":\"https://docs.sunbird.ai/guides/error-handling#webpage\"},\"dateModified\":\"2026-06-18T11:08:32.543Z\",\"publisher\":{\"@id\":\"https://docs.sunbird.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.sunbird.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Sunbird AI API\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Sunbird AI API","nav":{"global":null,"versions":[{"version":"v2.1","tag":"Latest","anchors":[{"anchor":"General","icon":"book-open","groups":[{"group":"Getting Started","pages":[{"title":"Introduction","href":"/introduction"},{"title":"Quickstart","href":"/quickstart"},{"title":"Authentication","href":"/authentication"},{"title":"Supported Languages","sidebarTitle":"Languages","href":"/languages"}]},{"group":"Guides","pages":[{"title":"Speech to Text","href":"/guides/speech-to-text"},{"title":"Text to Speech","href":"/guides/text-to-speech"},{"title":"Language Detection","href":"/guides/language-detection"},{"title":"Summarization","href":"/guides/summarization"},{"title":"Sunflower Chat","description":"Build conversational AI with the Sunflower models","href":"/guides/sunflower-chat"},{"title":"Error Handling","href":"/guides/error-handling"},{"title":"Rate Limits","description":"Understanding API rate limits and quotas","href":"/guides/rate-limits"}]},{"group":"Support","pages":[{"title":"FAQ","href":"/support/faq"},{"title":"Contact Support","href":"/support/contact"}]}]},{"anchor":"Models","icon":"layer-group","pages":[{"title":"Models","href":"/sunflower/overview"}]},{"anchor":"API Reference","icon":"code","pages":[{"title":"API Reference","href":"/api-reference/introduction"}]},{"anchor":"Resources","icon":"bookmark","pages":[{"title":"Resources","href":"/resources/changelog"}]}]},{"version":"v1","tag":"Deprecated","anchors":[{"anchor":"General","icon":"book-open","groups":[{"group":"Getting Started","pages":[{"title":"Introduction","href":"/introduction"},{"title":"Quickstart","href":"/quickstart"},{"title":"Authentication","href":"/authentication"},{"title":"Supported Languages","sidebarTitle":"Languages","href":"/languages"}]},{"group":"Guides","pages":[{"title":"Speech to Text","href":"/guides/speech-to-text"},{"title":"Text to Speech","href":"/guides/text-to-speech"},{"title":"Language Detection","href":"/guides/language-detection"},{"title":"Summarization","href":"/guides/summarization"},{"title":"Sunflower Chat","description":"Build conversational AI with the Sunflower models","href":"/guides/sunflower-chat"},{"title":"Error Handling","href":"/guides/error-handling"},{"title":"Rate Limits","description":"Understanding API rate limits and quotas","href":"/guides/rate-limits"}]},{"group":"Support","pages":[{"title":"FAQ","href":"/support/faq"},{"title":"Contact Support","href":"/support/contact"}]}]},{"anchor":"Models","icon":"layer-group","pages":[{"title":"Models","href":"/sunflower/overview"}]},{"anchor":"API Reference (Legacy)","icon":"triangle-exclamation","pages":[{"title":"API Reference (Legacy)","href":"/api-reference/legacy/introduction"}]}]}]},"basePath":"","title":"Error Handling - Sunbird AI API","buildId":"dpl_345ReqzYaAjzS9QpeJemsKdb7KDj","deploymentId":"dpl_345ReqzYaAjzS9QpeJemsKdb7KDj","dynamics":[],"chunks":[]}