Authentication
Sarvam AI uses a dual authentication pattern depending on the endpoint.
Getting an API Key
- Sign up at sarvam.ai
- Navigate to your dashboard to obtain your API subscription key
- The same key works for all endpoints — the SDK handles the dual auth automatically
Usage
1 2 3 | |
Dual Auth Pattern
Sarvam AI uses two different auth headers depending on the endpoint:
| Endpoint | Auth Header |
|---|---|
/v1/chat/completions |
Authorization: Bearer <key> |
| All other endpoints | api-subscription-key: <key> |
The SDK's PrepareRequest hook in SarvamAIClient.Auth.cs handles this
automatically — you don't need to manage it.
Environment Variables
For integration tests, set the SARVAMAI_API_KEY environment variable:
1 | |