Install a ready-to-use Hono server for Sarvam Vision batch processing.
bunx shadcn@latest add rajatsandeepsen/sarvam-simple/vision-serverGet your key from sarvam.ai
SARVAM_API_KEY=your_api_key_hereimport { Hono } from "hono";
import simpleVisionServer from "./sarvam/vision/server";
const app = new Hono();
app.route("/vision", simpleVisionServer());
export default app;After mounting on /vision, available endpoints are:
POST /vision/uploadPOST /vision/:id/statusPOST /vision/:id/downloadconst form = new FormData();
form.set("file", file); // File or multiple files with same key
form.set("language", "en-IN");
form.set("output_format", "md"); // html | md | json
const uploadRes = await fetch("/vision/upload", {
method: "POST",
body: form,
});
const { id } = await uploadRes.json();const statusRes = await fetch(`/vision/${id}/status`, {
method: "POST",
});
const status = await statusRes.json();
console.log(status.job_state);const downloadRes = await fetch(`/vision/${id}/download`, {
method: "POST",
});
const files = await downloadRes.json();
console.log(files); // [{ filename, url }]