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-completionExample map
| Use case | Example path | Related package docs |
|---|---|---|
| Chat completions + stream | examples/chat-completion/main.go | chat |
| Text translation | examples/translation/main.go | text |
| Text transliteration | examples/transliteration/main.go | text |
| Language detection | examples/language-detection/main.go | text |
| STT REST | examples/speech-to-text/main.go | speech-to-text / Transcribe |
| STT WebSocket stream | examples/speech-to-text-ws/main.go | speech-to-text / TranscribeStream, speech-streaming |
| STT translate REST | examples/stt-translate/main.go | translate |
| STT translate stream | examples/stt-translate-ws/main.go | translate, speech-streaming |
| TTS REST | examples/text-to-speech/main.go | tts |
| TTS stream | examples/text-to-speech-ws/main.go | tts |
| Document intelligence | examples/document-intelligence/main.go | docintel |
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.