All API endpoints are authenticated using API Subscription Keys provided by Sarvam AI when you sign up. Include these keys in the header of each API request as follows:
To authenticate your requests, include the API-Subscription-Key in the headers of your HTTP requests. Here’s an example using SarvamAI SDK:
Auth failures return HTTP 403, not 401. Sarvam returns 403 Forbidden for both invalid/missing API keys and forbidden-but-authenticated requests. If you’re catching exceptions or branching by status code, handle 403 as covering both “forbidden” and “invalid/missing API key”.
The response body’s error.code distinguishes the two:
invalid_api_key_error — the key is missing, malformed, or unknown*_error codes — authenticated but not allowed for the requested resource