Lightweight client for Roboflow's hosted inference API with WebRTC streaming support for real-time computer vision in the browser.
npm install @roboflow/inference-sdkimport { useStream, connectors } from '@roboflow/inference-sdk';
import { useCamera } from '@roboflow/inference-sdk/streams';
const stream = await useCamera({ video: { facingMode: "environment" } });
const connection = await useStream({
source: stream,
connector: connectors.withProxyUrl('/api/init-webrtc'), // Use backend proxy
wrtcParams: { workflowSpec: { /* ... */ } },
onData: (data) => console.log("Inference results:", data)
});
const videoElement.srcObject = await connection.remoteStream();See the sample app for a complete working example.
Never expose your API key in frontend code. Always use a backend proxy for production applications. The sample app demonstrates the recommended proxy pattern.
For a complete working example with backend proxy setup, see: github.com/roboflow/inferenceSampleApp
See the main repository for license information.