LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
  • Overview
  • Getting started
  • useStream
  • Selectors
  • Interrupts & headless tools
  • Subagents & subgraphs
  • Fork & edit from a checkpoint
  • Submission queue
  • Multimodal media
  • Transports
  • Suspense
  • StreamProvider & context
  • Type safety
  • Migrating to v1
LangGraph SDK
  • Ui
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Utils
  • Server
  • Stream
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
  • Store
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
WebChannelsPregelPrebuiltRemote
OverviewGetting starteduseStreamSelectorsInterrupts & headless toolsSubagents & subgraphsFork & edit from a checkpointSubmission queueMultimodal mediaTransportsSuspenseStreamProvider & contextType safetyMigrating to v1
LangGraph SDK
UiClientAuthReactLoggingReact UiUtilsServerStream
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
Store
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/reactMultimodal media

Multimodal media

useAudio, useImages, useVideo, and useFiles 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
useAudio transcript?: string, duration?: number, sampleRate?: number
useImages width?: number, height?: number
useVideo duration?: number, width?: number, height?: number
useFiles filename?: string, size?: number

Media hooks

import { useAudio, useImages, useVideo, useFiles } from "@langchain/react";

const audios = useAudio(stream);
const images = useImages(stream);
const videos = useVideo(stream);
const files = useFiles(stream);

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

useMediaURL

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

import { useAudio, useMediaURL } from "@langchain/react";

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

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

useAudioPlayer / useVideoPlayer

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

import { useAudio, useAudioPlayer } from "@langchain/react";

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

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

useVideoPlayer mirrors the same shape for video handles.

API reference

Classes

Class

MediaAssemblyError

Typed error thrown through media.stream / rejected from

Functions

Function

useAudio

Subscribe to a scoped audio-media stream. Returns an array of

Function

useImages

Subscribe to a scoped image-media stream. See useAudio for

Function

useVideo

Subscribe to a scoped video-media stream. See useAudio for

Function

useFiles

Subscribe to a scoped file-media stream. See useAudio for

Function

useMediaURL

Resolve the lazy MediaBase.objectURL promise into a string

Function

useAudioPlayer

Progressive audio playback for AudioMedia handles with a

Function

useVideoPlayer

Bind a VideoMedia handle to a caller-owned <video> element.

Interfaces

Interface

AudioPlayerHandle

Player controls + live state returned by useAudioPlayer.

Interface

VideoPlayerHandle

Controls + live state returned by useVideoPlayer. Mirrors

Interface

AudioMedia

Shared surface across every media handle returned by

Interface

ImageMedia

Shared surface across every media handle returned by

Interface

VideoMedia

Shared surface across every media handle returned by

Interface

FileMedia

Shared surface across every media handle returned by

Types

Type

AnyMediaHandle