@ohm_studio/sdk
v0.12.0
Published
OHM Studio SDK for JavaScript / TypeScript / React. Voice-to-structured-JSON clinical extraction APIs.
Maintainers
Readme
OHM SDK · @ohm_studio/sdk
The short name is
OHM SDK. The full npm name is@ohm_studio/sdk— that's what you install. Both names refer to the same package.
OHM Studio SDK for JavaScript / TypeScript / React — turn voice into structured clinical JSON, FHIR-ready, multi-language. Works in the browser, Node 18+, and Next.js (server actions, route handlers, edge runtime).
For React Native, install
@ohm_studio/sdk-react-native(OHM RN SDK) instead.
Install
npm install @ohm_studio/sdk
# or
pnpm add @ohm_studio/sdk
# or
yarn add @ohm_studio/sdkQuickstart
import { OHM } from "@ohm_studio/sdk";
// OHM is hospital-deployed. Each hospital exposes its own API URL
// (e.g. `api.<hospital>.example`). Set `baseUrl` to the URL of the
// hospital you're integrating with — your hospital admin gives you this.
// `https://api.ohm.doctor` is just OHM's own demo hospital and has no
// special status.
const ohm = new OHM({
apiKey: process.env.OHM_API_KEY!, // ohms_live_* or ohms_test_*
baseUrl: process.env.OHM_API_URL!, // e.g. https://api.kauvery.example
});
// Text → structured JSON
const { data } = await ohm.extract({
apiSlug: "opd-clinic",
text: transcript,
});
// Audio → structured JSON in one call
// `transcript` is always English — Tamil, Hindi, Telugu, Bengali, or any
// code-mixed consult is translated server-side before extraction runs.
const { transcript, data } = await ohm.audio.extract({
apiSlug: "opd-clinic",
file: blob, // File / Blob / { buffer, name?, type? }
});
// Summarize free text — patient / handover / executive / progress-note
const { summary } = await ohm.summarize({
text: longConsult,
style: "patient",
maxLines: 5,
});React hooks
import { OHM } from "@ohm_studio/sdk";
import { OhmProvider, useOhmAudioExtract } from "@ohm_studio/sdk/react";
const ohm = new OHM({ apiKey: process.env.NEXT_PUBLIC_OHM_TEST_KEY });
export default function App({ children }) {
return <OhmProvider client={ohm}>{children}</OhmProvider>;
}
function Recorder() {
const { mutateAsync, data, isPending, error } = useOhmAudioExtract({
apiSlug: "opd-clinic",
});
// ...
}Cancellation, upload progress, and discovery (v0.6+)
Every method now accepts a signal?: AbortSignal. audio.transcribe
and audio.extract accept an onProgress callback. ohm.apis.list()
enumerates published Studio APIs.
const controller = new AbortController();
const { data } = await ohm.audio.extract({
apiSlug: "opd-clinic",
file: blob,
signal: controller.signal, // user clicks Cancel → controller.abort()
onProgress: ({ percent }) => setUploadPct(percent),
});
const apis = await ohm.apis.list(); // [{ slug, name, status, version }]The React hooks (useOhmExtract, useOhmAudioExtract,
useOhmSummarize, useRecorder) auto-abort on unmount and on the next
mutation, so navigating away mid-upload never debits a half-finished
call. Aborts surface as OHMAbortError (code: "aborted") — pattern
match to ignore them.
Error handling
import {
OHMAuthError,
OHMRateLimitError,
OHMValidationError,
OHMAbortError,
} from "@ohm_studio/sdk";
try {
await ohm.extract({ apiSlug: "opd", text });
} catch (e) {
if (e instanceof OHMAbortError) return; // user cancelled
if (e instanceof OHMRateLimitError) await sleep(e.retryAfterSec! * 1000);
if (e instanceof OHMAuthError) rotateKey();
if (e instanceof OHMValidationError) showFieldErrors(e.fields);
}Typed data with the Studio CLI
Pair this SDK with @ohm_studio/cli
to generate TypeScript interfaces from your published Studio API
schemas:
npm install -D @ohm_studio/cli
npx ohm-studio pull-all --out src/ohmimport type { OpdClinicData } from "./ohm/opd-clinic";
const { data } = await ohm.extract<OpdClinicData>({
apiSlug: "opd-clinic",
text: transcript,
});
// `data` is typed against your Studio schemaBundle size
@ohm_studio/sdk core ships < 25 KB gzipped. React hooks subentry adds ~3 KB. Zero polyfills for Node 18+ / modern browsers.
Documentation
Full reference, cookbook, and OpenAPI playground: docs.ohm.doctor
License
MIT
