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-sdkstreamCustomAdapterOptions
Interface●Since v2.0

CustomAdapterOptions

Custom-adapter branch: caller brings their own AgentServerAdapter. Discriminated against AgentServerOptions by transport being an adapter instance.

Copy
interface CustomAdapterOptions

Bases

UseStreamCommonOptions<StateType, ThreadIdType>

Properties

property
apiKey: undefined

API key for authentication.

  • If a string is provided, that key will be used
  • If undefined (default), the key will be auto-loaded from environment variables (LANGGRAPH_API_KEY, LANGSMITH_API_KEY, or LANGCHAIN_API_KEY)
  • If null, no API key will be set (skips auto-loading)
property
apiUrl: undefined
property
assistantId: CustomAssistantIdType
property
callerOptions: undefined
property
client: undefined

LangGraph SDK client used to send requests and receive responses.

property
defaultHeaders: undefined
property
fetch: undefined

Optional fetch override, forwarded to the SSE transport. Useful for auth proxies, Next.js route handlers, or tests with injected mocks. Ignored when webSocketFactory is also supplied.

property
initialValues: StateType

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
onCreated: (meta: __type) => void

Callback that is called when a new stream is created.

property
onThreadId: (threadId: string) => void

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

property
onTool: OnToolCallback
property
threadId: ThreadIdType

Thread ID this transport is bound to.

property
tools: AnyHeadlessToolImplementation[]
property
transport: AgentServerAdapter

How this thread talks to the agent server. Accepts either a built-in transport string or a custom AgentServerAdapter:

  • "sse": HTTP commands + one SSE event stream per subscription.
  • "websocket": single bidirectional WebSocket.
  • an AgentServerAdapter: custom transport that replaces the built-in factories entirely. fetch / webSocketFactory are ignored in this mode.

Defaults to the client-level streamProtocol ("v2-websocket" → "websocket", otherwise "sse").

property
webSocketFactory: undefined

Optional WebSocket factory. Supplying it flips the adapter into WebSocket mode — SSE is bypassed entirely.

Inherited fromUseStreamCommonOptions

Properties

PinitialValues: StateType | null
—

Initial values to display immediately when loading a thread.

PmessagesKey: string
—

Specify the key within the state that contains messages.

PonCreated: (run: RunCallbackMeta)
—

Callback that is called when a new stream is created.

PonThreadId: (threadId: string)
—

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

PonTool: OnToolCallbackPthreadId: string
—

Thread ID this transport is bound to.

Ptools: "tools"
View source on GitHub