• Home
  • Vision
  • Audio
  • Docs
  • GitHub
Sarvam Logo

Audio Server Webhook

Install a Hono Audio server with webhook + KV support for async speech-to-text workflows.

Install

bunx shadcn@latest add rajatsandeepsen/sarvam-simple/audio-server-webhook

Environment Variable

Get your key from sarvam.ai

SARVAM_API_KEY=your_api_key_here

Mount in your Hono app

import { Hono } from "hono";
import audioServer from "./sarvam/audio/server";
 
const app = new Hono();
 
app.route(
	"/audio",
	audioServer({
		SARVAM_API_KEY: process.env.SARVAM_API_KEY,
		kvBinding: "KEYVALUE",
		webHook: {
			baseUrl: "https://your-domain.com/api/vision",
			authToken: "your-callback-token", // optional
			sendEmail: async (email, files) => {
				// write your own logic
				// files => [{ filename, url }]
			},
		},
	}),
);
 
export default app;

Routes

  • POST /audio/upload
  • POST /audio/:id/upload
  • POST /audio/:id/status
  • POST /audio/:id/download
  • POST /audio/:id/email
  • POST /audio/:id/webhook

Usage flow

  1. Client uploads files to /audio/upload and receives { id }.
  2. Server stores { job_id, email? } in KV (if configured).
  3. Sarvam calls /audio/:id/webhook after processing.
  4. Server resolves id -> job_id, downloads transcript URLs, then runs sendEmail(email, files).

Note

If webhook.authToken is set, webhook requests must include:

  • X-SARVAM-JOB-CALLBACK-TOKEN: <your-callback-token>