@fishaudio/agent-client
v0.0.1
Published
Fish Audio voice-agent client SDK for browsers: sessions, realtime audio, transcripts, client tools.
Readme
@fishaudio/agent-client
Framework-agnostic JavaScript/TypeScript SDK for embedding Fish Audio voice agents into any website or web app: realtime voice over WebRTC, live transcripts, text input, and client tools — behind one small, event-driven API.
Using React? @fishaudio/agent-react wraps this SDK in hooks and components.
Installation
npm install @fishaudio/agent-clientQuickstart
import { AgentSession } from "@fishaudio/agent-client";
// Session token from your backend — or { agentId } for a public agent.
const sessionToken = await fetch("/api/voice-session", { method: "POST" }).then((r) => r.json());
const session = await AgentSession.start({
sessionToken,
callbacks: {
onModeChange: (mode) => setOrbState(mode), // "listening" | "thinking" | "speaking"
onMessage: ({ role, text }) => renderChatBubble(role, text),
onDisconnect: ({ reason }) => showCallEnded(reason),
},
});
// Later:
session.sendUserMessage("Can you summarize that?");
await session.end();Starting a session requests microphone access; call start() from a user gesture (button click) for the best permission and autoplay behavior.
Documentation
- Quickstart — first call, with or without a backend.
- Authentication — server-created session tokens vs. public agents.
- Sessions —
start()options, the session API, lifecycle and reconnection. - Events — event reference and live transcripts.
- Client tools — let the agent call functions in the browser.
- Customization — per-session overrides and dynamic variables.
- Errors —
FishAgentErrorcodes.
