Add a tool to the agent's tool registry, exposed to the model during the session. Same AiTool objects as AiAgent. Returns this agent for chaining.
Tool to add to the registry.
Remove a tool from the registry by name. No-op when no tool with that name is registered. Returns this agent for chaining.
Name of the tool to remove.
Stream audio to the model over a live realtime session and return the response. The audio source is read once and streamed straight to the provider (no whole-clip buffering); the model transcribes it, may call the registered tools (executed in-script, results fed back automatically), and returns its final text. Audio must already be PCM16 @ 24kHz mono.
Accepts a Java InputStream (e.g. B.net.request.inputStream() for a live mic upload, or a
document's content stream) or a byte[] of PCM16 audio. Returns an AiCallResult with the
assistant text, stop reason, token usage, and the tool calls that were executed.
PCM16 @ 24kHz mono audio source — an InputStream (read once) or a byte[].
Like sendAudio(audio), but also persists the audio to the given Relate document field
as a WAV file. The audio is captured to a temporary file, streamed to the model, and —
when non-empty — written to the field wrapped in a WAV header (PCM16 @ 24kHz mono), so the
saved recording is directly playable. Returns the same AiCallResult as sendAudio(audio).
PCM16 @ 24kHz mono audio source.
A Relate document field (e.g. record.field('recording')) to save the WAV into.
Set an API key to call the provider directly. When present, the call bypasses the web-global usage gate (no preflight, no metering). Returns this agent for chaining.
Provider API key.
Set the usage gate tracking flag. Returns this agent for chaining.
Custom tracking flag reported to the usage gate.
Set the realtime model identifier. Falls back to the provider's configured realtime model when unset. Returns this agent for chaining.
Realtime model identifier (e.g. "gpt-realtime").
Set the AI provider. Realtime audio is OpenAI-only, so this accepts only "openai" (or unset). Returns this agent for chaining.
Provider name; must be "openai".
Set the session instructions (system prompt). Returns this agent for chaining.
Session instructions / system prompt.
Reusable streaming AI agent for realtime audio (OpenAI only). Shares the connection setters and tool registry of AiAgent, but
sendAudio(...)streams audio to the model over a live session and returns the response (text + executed tool calls) as an AiCallResult. One-shot per call: no chatHistory or onTurn. Audio must be PCM16 @ 24kHz mono. Returned byB.ai.streamingAgent().