LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
React SDK
Vue SDK
Svelte SDK
Angular SDK
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
React SDK
Vue SDK
Svelte SDK
Angular SDK
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/langgraph-sdkclientThreadsClientstream
Methodā—Since v1.9

stream

Copy
stream<
  TExtensions extends Record<string, unknown> = Record<string, unknown>
>(options:
View source on GitHub
ThreadStreamOptions
)
:
ThreadStream
<
TExtensions
>

Parameters

NameTypeDescription
options*ThreadStreamOptions

Example 1

Example 2

Example 3

Open a protocol stream over the thread-centric v2 protocol.

Returns a ThreadStream with lazy getters (.messages, .values, .toolCalls, .subgraphs, .subagents, .output) and thread.run.start({ input, ... }) for starting runs. Mirrors the in-process graph.streamEvents(..., { version: "v3" }) API.

The thread is bound to options.assistantId for its lifetime. The wire transport defaults to SSE; pass transport: "websocket" in options (or configure streamProtocol: "v2-websocket" on the client) to use a WebSocket instead.

Copy
const thread = client.threads.stream({ assistantId: "my-agent" });
Copy
const thread = client.threads.stream(threadId, { assistantId: "my-agent" });
Copy
const thread = client.threads.stream({
  assistantId: "my-agent",
  transport: "websocket",
});