LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
  • Stream
  • Overview
  • Getting started
  • injectStream
  • Selectors
  • Interrupts & headless tools
  • Subagents & subgraphs
  • Fork & edit from a checkpoint
  • Submission queue
  • Multimodal media
  • Transports
  • Dependency injection
  • Type safety
  • Migrating to v1
LangGraph SDK
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Server
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
LangGraph Checkpoint Redis
  • Shallow
  • Store
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
  • Cli
LangGraph API
LangGraph CLI
LangGraph CUA
  • Utils
LangGraph Supervisor
LangGraph Swarm
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangGraph
WebChannelsPregelPrebuiltRemoteStream
OverviewGetting startedinjectStreamSelectorsInterrupts & headless toolsSubagents & subgraphsFork & edit from a checkpointSubmission queueMultimodal mediaTransportsDependency injectionType safetyMigrating to v1
LangGraph SDK
ClientAuthReactLoggingReact UiServer
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
LangGraph Checkpoint Redis
ShallowStore
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
Cli
LangGraph API
LangGraph CLI
LangGraph CUA
Utils
LangGraph Supervisor
LangGraph Swarm
Language
Theme
JavaScript@langchain/angularMultimodal media

Multimodal media

injectAudio, injectImages, injectVideo, and injectFiles assemble multimodal blocks from the protocol stream. Each hook returns an array of media handles (one per message containing a matching block in the target namespace).

Runnable example: The multimodal storybook in the streaming cookbook streams story text, generated images, audio narration, and video from scoped graph nodes.

Handle shape

Every media handle exposes the same core fields, plus media-specific extras:

Field Type Description
id string Stable id for the media block.
messageId string Owning message id.
partialBytes Uint8Array \| undefined Live-growing byte buffer during streaming.
blob Blob \| undefined Settled Blob — populated on message-finish.
objectURL string \| undefined Object URL for the settled Blob (auto-revoked).
error unknown Fail-loud error surface.
mimeType string \| undefined Declared MIME type.

Media-specific extras:

Hook Extras
injectAudio transcript?: string, duration?: number, sampleRate?: number
injectImages width?: number, height?: number
injectVideo duration?: number, width?: number, height?: number
injectFiles filename?: string, size?: number

Media hooks

import { injectAudio, injectImages, injectVideo, injectFiles } from "@langchain/angular";

const audios = injectAudio(stream);
const images = injectImages(stream);
const videos = injectVideo(stream);
const files = injectFiles(stream);

Each accepts an optional target argument (subagent / subgraph / { namespace }) to scope the subscription — see Selectors.

injectMediaUrl

injectMediaUrl turns a media handle into a stable blob URL you can pass to <audio/img/video src>:

import { injectAudio, injectMediaUrl } from "@langchain/angular";

function AudioReply({ stream }: { stream: AnyStream }) {
  const audios = injectAudio(stream);
  const latest = audios.at(-1);
  const url = injectMediaUrl(latest);
  return url ? <audio controls src={url} /> : null;
}

injectMediaUrl(undefined) returns undefined — safe to call unconditionally.

injectMediaUrl / injectMediaUrl

injectMediaUrl and injectMediaUrl provide opinionated player handles with play/pause/seek state, built on top of the media hooks:

import { injectAudio, injectMediaUrl } from "@langchain/angular";

function AudioPlayer({ stream }: { stream: AnyStream }) {
  const audio = injectAudio(stream).at(-1);
  const player = injectMediaUrl(audio, { autoPlay: true });

  return (
    <div>
      <button onClick={player.toggle}>{player.isPlaying ? "Pause" : "Play"}</button>
      <progress value={player.currentTime} max={player.duration} />
    </div>
  );
}

injectMediaUrl mirrors the same shape for video handles.

API reference

Classes

Class

MediaAssemblyError

Typed error thrown through media.stream / rejected from media.blob / media.objectURL when a handle fails before its message completes. Carries the bytes accumulated up to the failure point on `p

Functions

Function

injectAudio

Subscribe to a scoped audio-media stream. Each handle is yielded on its first matching content-block-start, exposes .partialBytes for live access, settles .blob / .objectURL / .transcript on

Function

injectImages

Subscribe to a scoped image-media stream. Pair with injectMediaUrl for <img src>.

Function

injectVideo

Subscribe to a scoped video-media stream. Pair with injectMediaUrl for <video src>.

Function

injectFiles

Subscribe to a scoped file-media stream. Pair with injectMediaUrl for an <a download href> target.

Function

injectMediaUrl

Resolve the lazy MediaBase.objectURL promise into a string suitable for direct use in <audio src> / <img src> / <video src> / <a href download>. Returns undefined until the URL is available.

Interfaces

Interface

AudioMedia

Shared surface across every media handle returned by MediaAssembler.

The handle is live while its parent message is active:

  • partialBytes is a snapshot of all bytes received so far.
  • stream i
Interface

ImageMedia

Shared surface across every media handle returned by MediaAssembler.

The handle is live while its parent message is active:

  • partialBytes is a snapshot of all bytes received so far.
  • stream i
Interface

VideoMedia

Shared surface across every media handle returned by MediaAssembler.

The handle is live while its parent message is active:

  • partialBytes is a snapshot of all bytes received so far.
  • stream i
Interface

FileMedia

Shared surface across every media handle returned by MediaAssembler.

The handle is live while its parent message is active:

  • partialBytes is a snapshot of all bytes received so far.
  • stream i

Types

Type

AnyMediaHandle