Skip to content

Language Detection

Detect the language and script of input text using the Sarvam AI Language Detection API.

This example assumes using SarvamAI; is in scope and apiKey contains your SarvamAI API key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
using var client = new SarvamAIClient(apiKey);

// Detect the language and script of Hindi text
var response = await client.DetectLanguageAsync(
    request: new DetectLanguageRequest
    {
        Input = "नमस्ते, आप कैसे हैं?",
    });

Console.WriteLine($"Language: {response.LanguageCode}");
Console.WriteLine($"Script: {response.ScriptCode}");