Bluestep JS Documentation
    Preparing search index...

    Class StreamingAiAgent

    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 by B.ai.streamingAgent().

    Index
    • 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.

      Type Parameters

      Parameters

      Returns StreamingAiAgent

    • Remove a tool from the registry by name. No-op when no tool with that name is registered. Returns this agent for chaining.

      Parameters

      • name: string

        Name of the tool to remove.

      Returns StreamingAiAgent

    • 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.

      Parameters

      • audio: InputStream | ByteArray

        PCM16 @ 24kHz mono audio source — an InputStream (read once) or a byte[].

      Returns AiCallResult

    • 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).

      Parameters

      Returns AiCallResult

    • 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.

      Parameters

      • apiKey: string

        Provider API key.

      Returns StreamingAiAgent

    • Set the usage gate tracking flag. Returns this agent for chaining.

      Parameters

      • flag: string

        Custom tracking flag reported to the usage gate.

      Returns StreamingAiAgent

    • Set the realtime model identifier. Falls back to the provider's configured realtime model when unset. Returns this agent for chaining.

      Parameters

      • model: string

        Realtime model identifier (e.g. "gpt-realtime").

      Returns StreamingAiAgent

    • Set the AI provider. Realtime audio is OpenAI-only, so this accepts only "openai" (or unset). Returns this agent for chaining.

      Parameters

      • provider: string

        Provider name; must be "openai".

      Returns StreamingAiAgent

    • Set the session instructions (system prompt). Returns this agent for chaining.

      Parameters

      • systemPrompt: string

        Session instructions / system prompt.

      Returns StreamingAiAgent