sarvamai-go SDK Documentation

Examples

Runnable examples mapped to each SDK package and workflow.

How to run examples

From repository root:

export SARVAM_API_KEY="<your-api-key>"
go run ./examples/chat-completion

Example map

Use caseExample pathRelated package docs
Chat completions + streamexamples/chat-completion/main.gochat
Text translationexamples/translation/main.gotext
Text transliterationexamples/transliteration/main.gotext
Language detectionexamples/language-detection/main.gotext
STT RESTexamples/speech-to-text/main.gospeech-to-text / Transcribe
STT WebSocket streamexamples/speech-to-text-ws/main.gospeech-to-text / TranscribeStream, speech-streaming
STT translate RESTexamples/stt-translate/main.gotranslate
STT translate streamexamples/stt-translate-ws/main.gotranslate, speech-streaming
TTS RESTexamples/text-to-speech/main.gotts
TTS streamexamples/text-to-speech-ws/main.gotts
Document intelligenceexamples/document-intelligence/main.godocintel

Notes while adapting examples

  • Use your own audio/document paths; example paths are relative to repo root.
  • Streaming examples rely on Flush() to finalize output.
  • For job APIs (sttjob, translatejob), use this docs site’s workflow pages even though repository examples currently focus on non-job flows.

On this page