LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
LangGraph React SDK
  • React Ui
  • Server
LangGraph Vue SDK
LangGraph Svelte SDK
LangGraph Angular SDK
LangGraph SDK
  • Ui
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Utils
  • Server
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
LangGraph React SDK
React UiServer
LangGraph Vue SDK
LangGraph Svelte SDK
LangGraph Angular SDK
LangGraph SDK
UiClientAuthReactLoggingReact UiUtilsServer
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/angularUseStreamOptions
Interfaceā—Since v0.1

UseStreamOptions

Copy
interface UseStreamOptions

Properties

property
apiKey: string | null

The API key to use.

property
apiUrl: string

The URL of the API to use.

property
assistantId: string

The ID of the assistant to use.

property
callerOptions: AsyncCallerParams

Custom call options, such as custom fetch implementation.

property
client: Client<DefaultValues, DefaultValues, unknown>

Client used to send requests.

property
defaultHeaders: Record<string, HeaderValue>

Default headers to send with requests.

property
fetchStateHistory: boolean | __type

Whether to fetch the history of the thread. If true, the history will be fetched from the server. Defaults to 10 entries. If false, only the last state will be fetched from the server.

property
initialValues: StateType | null

Initial values to display immediately when loading a thread. Useful for displaying cached thread data while official history loads. These values will be replaced when official thread data is fetched.

Note: UI components from initialValues will render immediately if they're predefined in LoadExternalComponent's components prop, providing instant cached UI display without server fetches.

property
messagesKey: string

Specify the key within the state that contains messages. Defaults to "messages".

property
onCheckpointEvent: (data: __type, options: __type) => void

Callback that is called when a checkpoints event is received.

property
onCreated: (run: RunCallbackMeta) => void

Callback that is called when a new stream is created.

property
onCustomEvent: (data: GetCustomEventType<Bag>, options: __type) => void

Callback that is called when a custom event is received.

property
onError: (error: unknown, run: RunCallbackMeta | undefined) => void

Callback that is called when an error occurs.

property
onFinish: (state: ThreadState<StateType>, run: RunCallbackMeta | undefined) => void

Callback that is called when the stream is finished.

property
onLangChainEvent: (data: __type) => void

Callback that is called when a LangChain event is received.

property
onMetadataEvent: (data: __type) => void

Callback that is called when a metadata event is received.

property
onStop: (options: __type) => void

Callback that is called when the stream is stopped by the user. Provides a mutate function to update the stream state immediately without requiring a server roundtrip.

Copy
onStop: ({ mutate }) => {
  mutate((prev) => ({
    ...prev,
    ui: prev.ui?.map(component =>
      component.props.isLoading
        ? { ...component, props: { ...component.props, stopped: true, isLoading: false }}
        : component
    )
  }));
}
property
onTaskEvent: (data: __type | __type | __type, options: __type) => void

Callback that is called when a tasks event is received.

property
onThreadId: (threadId: string) => void

Callback that is called when the thread ID is updated (ie when a new thread is created).

property
onToolEvent: (data: ToolStreamEventData, options: __type) => void

Callback that is called when a tool lifecycle event is received.

property
onUpdateEvent: (data: __type, options: __type) => void

Callback that is called when an update event is received.

property
reconnectOnMount: boolean | () => RunMetadataStorage

Will reconnect the stream on mount

property
thread: UseStreamThread<StateType>

Manage the thread state externally.

property
threadId: string | null

The ID of the thread to fetch history and current values from.

property
throttle: number | boolean

Throttle the stream. If a number is provided, the stream will be throttled to the given number of milliseconds. If true, updates are batched in a single macrotask. If false, updates are not throttled or batched.

View source on GitHub