The examples use the OneSay JavaScript SDK (@onesay/sdk), which is not on npm. Access. The SDK's repository is private. To ask for access, write to sdk@onesay.com.
The examples do not set up a
Project or Room for you: they use the resources, credentials and Consent
decisions that your application already has.
Choose the service
| Service | Example | What it shows |
|---|---|---|
| Task Voice | JavaScript Quickstart | Sending PCM audio that you supply, ACK and replay, Task completion, and reading back the Artifact and Usage. Your application supplies the identity, the existing resources and the Human's Consent decisions. |
| RTC audio | examples/rtc-browser | Connect, publish, subscribe, receive, end and close, with client.rtc.connect. |
| RTC Agent | examples/rtc-agents.ts | Create an Agent, request its stop and read back what the server observed. |
Task Voice and RTC are separate services. Connecting to RTC or publishing a microphone starts neither a Task nor an Agent. An Agent's transcription result is not the Task dictation service. The examples use public OneSay objects only; the SDK exposes no native Room, Track or token API.
For a device, see the ESP32 Quickstart.
The examples in the repository
The SDK's repository has these examples, in examples/. Importing one of the three short files starts no media and makes no request. They import from the repository's own source, so read them there, and use the package's name in your own app.
| Example | What it shows | What it needs |
|---|---|---|
canonical-pcm.ts | A browser token provider, and converting float samples to PCM16LE | Nothing |
node-raw-pcm.ts | Wrapping raw PCM as a source, and the signal backlog's acknowledgements | Nothing |
rtc-agents.ts | Creating an Agent, requesting its stop and reading back what the server observed | A client, and an authorized Room, AppSession and publications from your app |
rtc-browser | A browser page for an RTC session, with its own README. We have not yet run it in a browser | An authorized Room, AppSession, Source and token |
Never put a Platform API key, Service key or Provider key into a browser page.
Handle the lifecycle
- Keep each resource ID, idempotency key and policy version you used. If a response is lost, send the same request with the same key, or read the original resource.
- An accepted request records intent: an accepted subscription, packet policy, Agent stop or revoke does not prove that it has taken effect.
- A data receiver must select the publication and start its reader. In the
example,
nextDataFramereads one frame and then closes that reader. - Cancelling a local wait does not roll back an operation the server has already committed.
- Close the RTC session when you are done, and stop every Agent execution you created: closing the session does not stop an Agent.
- When an outcome is uncertain, read the original resource and use your application's Consent flow. Do not change keys, chase newer policy versions or create replacement work automatically.
With JavaScript SDK v0.2.0, pass microphoneSourceId to client.rtc.connect
so connection admission covers your microphone and returns
session.microphonePublicationId, then call session.audio.publishLocalMicrophone()
to capture and publish directly with no extra server call. To hear an Agent,
call session.audio.enablePlayback() directly from a user gesture once you are
connected; you do not wait for playback or send a separate subscription
request. In v0.2.0, session.capabilities.autoSubscribe is true under
LiveKit's stock auto-subscribe defaults, so LiveKit delivers the Agent's audio
to your connection automatically. To mute or unmute one remote participant
locally, call session.audio.setPeerSubscribed(peer, subscribed) with a handle
from session.peers. To check the Agent's state itself, read
client.rtc.agents.get(roomId, agentExecutionId) at most once every 2 seconds.
See the AI Agent Quickstart and
JavaScript Quickstart.
Report a problem
Keep the operation, the returned error code and the resource IDs together in an access-controlled report. Leave out bearer tokens, connection material, private exception text and customer media.