JS/TS
langchain/langgraph-sdk • Docs
langchain/langgraph-sdk¶
Modules¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / client
client¶
Index¶
Classes¶
Interfaces¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / client / AssistantsClient
Class: AssistantsClient¶
Extends¶
Constructors¶
new AssistantsClient()¶
new AssistantsClient(
config
?):AssistantsClient
Parameters¶
• config?: ClientConfig
Returns¶
Inherited from¶
Defined in¶
Properties¶
apiUrl¶
protected
apiUrl:string
Inherited from¶
Defined in¶
asyncCaller¶
protected
asyncCaller:AsyncCaller
Inherited from¶
Defined in¶
defaultHeaders¶
protected
defaultHeaders:Record
\<string
,undefined
|null
|string
>
Inherited from¶
Defined in¶
timeoutMs¶
protected
timeoutMs:number
Inherited from¶
Defined in¶
Methods¶
create()¶
create(
payload
):Promise
\<Assistant
>
Create a new assistant.
Parameters¶
• payload
Payload for creating an assistant.
• payload.config?: Config
• payload.graphId: string
• payload.metadata?: Metadata
Returns¶
Promise
\<Assistant
>
The created assistant.
Defined in¶
delete()¶
delete(
assistantId
):Promise
\<void
>
Delete an assistant.
Parameters¶
• assistantId: string
ID of the assistant.
Returns¶
Promise
\<void
>
Defined in¶
fetch()¶
protected
fetch\<T
>(path
,options
?):Promise
\<T
>
Type Parameters¶
• T
Parameters¶
• path: string
• options?: RequestInit
& object
Returns¶
Promise
\<T
>
Inherited from¶
Defined in¶
get()¶
get(
assistantId
):Promise
\<Assistant
>
Get an assistant by ID.
Parameters¶
• assistantId: string
The ID of the assistant.
Returns¶
Promise
\<Assistant
>
Assistant
Defined in¶
getGraph()¶
getGraph(
assistantId
):Promise
\<AssistantGraph
>
Get the JSON representation of the graph assigned to a runnable
Parameters¶
• assistantId: string
The ID of the assistant.
Returns¶
Promise
\<AssistantGraph
>
Serialized graph
Defined in¶
getSchemas()¶
getSchemas(
assistantId
):Promise
\<GraphSchema
>
Get the state and config schema of the graph assigned to a runnable
Parameters¶
• assistantId: string
The ID of the assistant.
Returns¶
Promise
\<GraphSchema
>
Graph schema
Defined in¶
prepareFetchOptions()¶
protected
prepareFetchOptions(path
,options
?): [URL
,RequestInit
]
Parameters¶
• path: string
• options?: RequestInit
& object
Returns¶
[URL
, RequestInit
]
Inherited from¶
BaseClient
.prepareFetchOptions
Defined in¶
search()¶
search(
query
?):Promise
\<Assistant
[]>
List assistants.
Parameters¶
• query?
Query options.
• query.limit?: number
• query.metadata?: Metadata
• query.offset?: number
Returns¶
Promise
\<Assistant
[]>
List of assistants.
Defined in¶
update()¶
update(
assistantId
,payload
):Promise
\<Assistant
>
Update an assistant.
Parameters¶
• assistantId: string
ID of the assistant.
• payload
Payload for updating the assistant.
• payload.config?: Config
• payload.graphId: string
• payload.metadata?: Metadata
Returns¶
Promise
\<Assistant
>
The updated assistant.
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / client / BaseClient
Class: BaseClient¶
Extended by¶
Constructors¶
new BaseClient()¶
new BaseClient(
config
?):BaseClient
Parameters¶
• config?: ClientConfig
Returns¶
Defined in¶
Properties¶
apiUrl¶
protected
apiUrl:string
Defined in¶
asyncCaller¶
protected
asyncCaller:AsyncCaller
Defined in¶
defaultHeaders¶
protected
defaultHeaders:Record
\<string
,undefined
|null
|string
>
Defined in¶
timeoutMs¶
protected
timeoutMs:number
Defined in¶
Methods¶
fetch()¶
protected
fetch\<T
>(path
,options
?):Promise
\<T
>
Type Parameters¶
• T
Parameters¶
• path: string
• options?: RequestInit
& object
Returns¶
Promise
\<T
>
Defined in¶
prepareFetchOptions()¶
protected
prepareFetchOptions(path
,options
?): [URL
,RequestInit
]
Parameters¶
• path: string
• options?: RequestInit
& object
Returns¶
[URL
, RequestInit
]
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / client / Client
Class: Client¶
Constructors¶
new Client()¶
new Client(
config
?):Client
Parameters¶
• config?: ClientConfig
Returns¶
Defined in¶
Properties¶
assistants¶
assistants:
AssistantsClient
The client for interacting with assistants.
Defined in¶
runs¶
runs:
RunsClient
The client for interacting with runs.
Defined in¶
threads¶
threads:
ThreadsClient
The client for interacting with threads.
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / client / RunsClient
Class: RunsClient¶
Extends¶
Constructors¶
new RunsClient()¶
new RunsClient(
config
?):RunsClient
Parameters¶
• config?: ClientConfig
Returns¶
Inherited from¶
Defined in¶
Properties¶
apiUrl¶
protected
apiUrl:string
Inherited from¶
Defined in¶
asyncCaller¶
protected
asyncCaller:AsyncCaller
Inherited from¶
Defined in¶
defaultHeaders¶
protected
defaultHeaders:Record
\<string
,undefined
|null
|string
>
Inherited from¶
Defined in¶
timeoutMs¶
protected
timeoutMs:number
Inherited from¶
Defined in¶
Methods¶
cancel()¶
cancel(
threadId
,runId
,wait
):Promise
\<void
>
Cancel a run.
Parameters¶
• threadId: string
The ID of the thread.
• runId: string
The ID of the run.
• wait: boolean
= false
Whether to block when canceling
Returns¶
Promise
\<void
>
Defined in¶
create()¶
create(
threadId
,assistantId
,payload
?):Promise
\<Run
>
Create a run.
Parameters¶
• threadId: string
The ID of the thread.
• assistantId: string
Assistant ID to use for this run.
• payload?: RunsCreatePayload
Payload for creating a run.
Returns¶
Promise
\<Run
>
The created run.
Defined in¶
delete()¶
delete(
threadId
,runId
):Promise
\<void
>
Delete a run.
Parameters¶
• threadId: string
The ID of the thread.
• runId: string
The ID of the run.
Returns¶
Promise
\<void
>
Defined in¶
fetch()¶
protected
fetch\<T
>(path
,options
?):Promise
\<T
>
Type Parameters¶
• T
Parameters¶
• path: string
• options?: RequestInit
& object
Returns¶
Promise
\<T
>
Inherited from¶
Defined in¶
get()¶
get(
threadId
,runId
):Promise
\<Run
>
Get a run by ID.
Parameters¶
• threadId: string
The ID of the thread.
• runId: string
The ID of the run.
Returns¶
Promise
\<Run
>
The run.
Defined in¶
join()¶
join(
threadId
,runId
):Promise
\<void
>
Block until a run is done.
Parameters¶
• threadId: string
The ID of the thread.
• runId: string
The ID of the run.
Returns¶
Promise
\<void
>
Defined in¶
list()¶
list(
threadId
,options
?):Promise
\<Run
[]>
List all runs for a thread.
Parameters¶
• threadId: string
The ID of the thread.
• options?
Filtering and pagination options.
• options.limit?: number
Maximum number of runs to return. Defaults to 10
• options.offset?: number
Offset to start from. Defaults to 0.
Returns¶
Promise
\<Run
[]>
List of runs.
Defined in¶
prepareFetchOptions()¶
protected
prepareFetchOptions(path
,options
?): [URL
,RequestInit
]
Parameters¶
• path: string
• options?: RequestInit
& object
Returns¶
[URL
, RequestInit
]
Inherited from¶
BaseClient
.prepareFetchOptions
Defined in¶
stream()¶
Create a run and stream the results.
Param¶
The ID of the thread.
Param¶
Assistant ID to use for this run.
Param¶
Payload for creating a run.
stream(threadId, assistantId, payload)¶
stream(
threadId
,assistantId
,payload
?):AsyncGenerator
\<object
,any
,unknown
>
Create a run and stream the results.
Parameters¶
• threadId: null
• assistantId: string
• payload?: Omit
\<RunsStreamPayload
, "multitaskStrategy"
>
Returns¶
AsyncGenerator
\<object
, any
, unknown
>
# data¶
data:
any
# event¶
event:
StreamEvent
Defined in¶
stream(threadId, assistantId, payload)¶
stream(
threadId
,assistantId
,payload
?):AsyncGenerator
\<object
,any
,unknown
>
Create a run and stream the results.
Parameters¶
• threadId: string
• assistantId: string
• payload?: RunsStreamPayload
Returns¶
AsyncGenerator
\<object
, any
, unknown
>
# data¶
data:
any
# event¶
event:
StreamEvent
Defined in¶
wait()¶
Create a run and wait for it to complete.
Param¶
The ID of the thread.
Param¶
Assistant ID to use for this run.
Param¶
Payload for creating a run.
wait(threadId, assistantId, payload)¶
wait(
threadId
,assistantId
,payload
?):Promise
\<DefaultValues
>
Create a run and wait for it to complete.
Parameters¶
• threadId: null
• assistantId: string
• payload?: Omit
\<RunsStreamPayload
, "multitaskStrategy"
>
Returns¶
Promise
\<DefaultValues
>
Defined in¶
wait(threadId, assistantId, payload)¶
wait(
threadId
,assistantId
,payload
?):Promise
\<DefaultValues
>
Create a run and wait for it to complete.
Parameters¶
• threadId: string
• assistantId: string
• payload?: RunsStreamPayload
Returns¶
Promise
\<DefaultValues
>
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / client / ThreadsClient
Class: ThreadsClient¶
Extends¶
Constructors¶
new ThreadsClient()¶
new ThreadsClient(
config
?):ThreadsClient
Parameters¶
• config?: ClientConfig
Returns¶
Inherited from¶
Defined in¶
Properties¶
apiUrl¶
protected
apiUrl:string
Inherited from¶
Defined in¶
asyncCaller¶
protected
asyncCaller:AsyncCaller
Inherited from¶
Defined in¶
defaultHeaders¶
protected
defaultHeaders:Record
\<string
,undefined
|null
|string
>
Inherited from¶
Defined in¶
timeoutMs¶
protected
timeoutMs:number
Inherited from¶
Defined in¶
Methods¶
create()¶
create(
payload
?):Promise
\<Thread
>
Create a new thread.
Parameters¶
• payload?
Payload for creating a thread.
• payload.metadata?: Metadata
Metadata for the thread.
Returns¶
Promise
\<Thread
>
The created thread.
Defined in¶
delete()¶
delete(
threadId
):Promise
\<void
>
Delete a thread.
Parameters¶
• threadId: string
ID of the thread.
Returns¶
Promise
\<void
>
Defined in¶
fetch()¶
protected
fetch\<T
>(path
,options
?):Promise
\<T
>
Type Parameters¶
• T
Parameters¶
• path: string
• options?: RequestInit
& object
Returns¶
Promise
\<T
>
Inherited from¶
Defined in¶
get()¶
get(
threadId
):Promise
\<Thread
>
Get a thread by ID.
Parameters¶
• threadId: string
ID of the thread.
Returns¶
Promise
\<Thread
>
The thread.
Defined in¶
getHistory()¶
getHistory\<
ValuesType
>(threadId
,options
?):Promise
\<ThreadState
\<ValuesType
>[]>
Get all past states for a thread.
Type Parameters¶
• ValuesType = DefaultValues
Parameters¶
• threadId: string
ID of the thread.
• options?
Additional options.
• options.before?: Config
• options.limit?: number
• options.metadata?: Metadata
Returns¶
Promise
\<ThreadState
\<ValuesType
>[]>
List of thread states.
Defined in¶
getState()¶
getState\<
ValuesType
>(threadId
,checkpointId
?):Promise
\<ThreadState
\<ValuesType
>>
Get state for a thread.
Type Parameters¶
• ValuesType = DefaultValues
Parameters¶
• threadId: string
ID of the thread.
• checkpointId?: string
Returns¶
Promise
\<ThreadState
\<ValuesType
>>
Thread state.
Defined in¶
patchState()¶
patchState(
threadIdOrConfig
,metadata
):Promise
\<void
>
Patch the metadata of a thread.
Parameters¶
• threadIdOrConfig: string
| Config
Thread ID or config to patch the state of.
• metadata: Metadata
Metadata to patch the state with.
Returns¶
Promise
\<void
>
Defined in¶
prepareFetchOptions()¶
protected
prepareFetchOptions(path
,options
?): [URL
,RequestInit
]
Parameters¶
• path: string
• options?: RequestInit
& object
Returns¶
[URL
, RequestInit
]
Inherited from¶
BaseClient
.prepareFetchOptions
Defined in¶
search()¶
search(
query
?):Promise
\<Thread
[]>
List threads
Parameters¶
• query?
Query options
• query.limit?: number
Maximum number of threads to return. Defaults to 10
• query.metadata?: Metadata
Metadata to filter threads by.
• query.offset?: number
Offset to start from.
Returns¶
Promise
\<Thread
[]>
List of threads
Defined in¶
update()¶
update(
threadId
,payload
?):Promise
\<Thread
>
Update a thread.
Parameters¶
• threadId: string
ID of the thread.
• payload?
Payload for updating the thread.
• payload.metadata?: Metadata
Metadata for the thread.
Returns¶
Promise
\<Thread
>
The updated thread.
Defined in¶
updateState()¶
updateState\<
ValuesType
>(threadId
,options
):Promise
\<void
>
Add state to a thread.
Type Parameters¶
• ValuesType = DefaultValues
Parameters¶
• threadId: string
The ID of the thread.
• options
• options.asNode?: string
• options.checkpointId?: string
• options.values: ValuesType
Returns¶
Promise
\<void
>
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / client / ClientConfig
Interface: ClientConfig¶
Properties¶
apiUrl?¶
optional
apiUrl:string
Defined in¶
callerOptions?¶
optional
callerOptions:AsyncCallerParams
Defined in¶
defaultHeaders?¶
optional
defaultHeaders:Record
\<string
,undefined
|null
|string
>
Defined in¶
timeoutMs?¶
optional
timeoutMs:number
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / schema
schema¶
Index¶
Interfaces¶
Type Aliases¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / schema / Assistant
Interface: Assistant¶
Properties¶
assistant_id¶
assistant_id:
string
Defined in¶
config¶
config:
Config
Defined in¶
created_at¶
created_at:
string
Defined in¶
graph_id¶
graph_id:
string
Defined in¶
metadata¶
metadata:
Metadata
Defined in¶
updated_at¶
updated_at:
string
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / schema / Config
Interface: Config¶
Properties¶
configurable¶
configurable:
object
Runtime values for attributes previously made configurable on this Runnable.
Index Signature¶
[key
: string
]: unknown
thread_id?¶
optional
thread_id:string
ID of the thread
thread_ts?¶
optional
thread_ts:string
Timestamp of the state checkpoint
Defined in¶
recursion_limit?¶
optional
recursion_limit:number
Maximum number of times a call can recurse. If not provided, defaults to 25.
Defined in¶
tags?¶
optional
tags:string
[]
Tags for this call and any sub-calls (eg. a Chain calling an LLM). You can use these to filter calls.
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / schema / GraphSchema
Interface: GraphSchema¶
Properties¶
config_schema¶
config_schema:
JSONSchema7
The schema for the graph config
Defined in¶
graph_id¶
graph_id:
string
The ID of the graph.
Defined in¶
state_schema¶
state_schema:
JSONSchema7
The schema for the graph state
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / schema / Run
Interface: Run¶
Properties¶
assistant_id¶
assistant_id:
string
Defined in¶
created_at¶
created_at:
string
Defined in¶
metadata¶
metadata:
Metadata
Defined in¶
run_id¶
run_id:
string
Defined in¶
status¶
status:
"pending"
|"running"
|"error"
|"success"
|"timeout"
|"interrupted"
Defined in¶
thread_id¶
thread_id:
string
Defined in¶
updated_at¶
updated_at:
string
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / schema / Thread
Interface: Thread¶
Properties¶
created_at¶
created_at:
string
Defined in¶
metadata¶
metadata:
Metadata
Defined in¶
thread_id¶
thread_id:
string
Defined in¶
updated_at¶
updated_at:
string
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / schema / ThreadState
Interface: ThreadState\<ValuesType>¶
Type Parameters¶
• ValuesType = DefaultValues
Properties¶
checkpoint_id¶
checkpoint_id:
string
Defined in¶
created_at¶
created_at:
Optional
\<string
>
Defined in¶
metadata¶
metadata:
Metadata
Defined in¶
next¶
next:
string
[]
Defined in¶
parent_checkpoint_id¶
parent_checkpoint_id:
Optional
\<string
>
Defined in¶
values¶
values:
ValuesType
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / schema / AssistantGraph
Type Alias: AssistantGraph¶
AssistantGraph:
Record
\<string
,Record
\<string
,unknown
>[]>
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / schema / DefaultValues
Type Alias: DefaultValues¶
DefaultValues:
Record
\<string
,unknown
>[] |Record
\<string
,unknown
>
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / schema / Metadata
Type Alias: Metadata¶
Metadata:
Optional
\<Record
\<string
,unknown
>>
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / types
types¶
Index¶
Interfaces¶
Type Aliases¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / types / RunsCreatePayload
Interface: RunsCreatePayload¶
Extends¶
RunsInvokePayload
Properties¶
config?¶
optional
config:Config
Additional configuration for the run.
Inherited from¶
RunsInvokePayload.config
Defined in¶
input?¶
optional
input:null
|Record
\<string
,unknown
>
Input to the run. Pass null
to resume from the current state of the thread.
Inherited from¶
RunsInvokePayload.input
Defined in¶
interruptAfter?¶
optional
interruptAfter:string
[]
Interrupt execution after leaving these nodes.
Inherited from¶
RunsInvokePayload.interruptAfter
Defined in¶
interruptBefore?¶
optional
interruptBefore:string
[]
Interrupt execution before entering these nodes.
Inherited from¶
RunsInvokePayload.interruptBefore
Defined in¶
metadata?¶
optional
metadata:Metadata
Metadata for the run.
Inherited from¶
RunsInvokePayload.metadata
Defined in¶
multitaskStrategy?¶
optional
multitaskStrategy:MultitaskStrategy
Strategy to handle concurrent runs on the same thread. Only relevant if there is a pending/inflight run on the same thread. One of: - "reject": Reject the new run. - "interrupt": Interrupt the current run, keeping steps completed until now, and start a new one. - "rollback": Cancel and delete the existing run, rolling back the thread to the state before it had started, then start the new run. - "enqueue": Queue up the new run to start after the current run finishes.
Inherited from¶
RunsInvokePayload.multitaskStrategy
Defined in¶
signal?¶
optional
signal:AbortSignal
Abort controller signal to cancel the run.
Inherited from¶
RunsInvokePayload.signal
Defined in¶
webhook?¶
optional
webhook:string
Webhook to call when the run is complete.
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / types / RunsStreamPayload
Interface: RunsStreamPayload¶
Extends¶
RunsInvokePayload
Properties¶
config?¶
optional
config:Config
Additional configuration for the run.
Inherited from¶
RunsInvokePayload.config
Defined in¶
feedbackKeys?¶
optional
feedbackKeys:string
[]
Pass one or more feedbackKeys if you want to request short-lived signed URLs for submitting feedback to LangSmith with this key for this run.
Defined in¶
input?¶
optional
input:null
|Record
\<string
,unknown
>
Input to the run. Pass null
to resume from the current state of the thread.
Inherited from¶
RunsInvokePayload.input
Defined in¶
interruptAfter?¶
optional
interruptAfter:string
[]
Interrupt execution after leaving these nodes.
Inherited from¶
RunsInvokePayload.interruptAfter
Defined in¶
interruptBefore?¶
optional
interruptBefore:string
[]
Interrupt execution before entering these nodes.
Inherited from¶
RunsInvokePayload.interruptBefore
Defined in¶
metadata?¶
optional
metadata:Metadata
Metadata for the run.
Inherited from¶
RunsInvokePayload.metadata
Defined in¶
multitaskStrategy?¶
optional
multitaskStrategy:MultitaskStrategy
Strategy to handle concurrent runs on the same thread. Only relevant if there is a pending/inflight run on the same thread. One of: - "reject": Reject the new run. - "interrupt": Interrupt the current run, keeping steps completed until now, and start a new one. - "rollback": Cancel and delete the existing run, rolling back the thread to the state before it had started, then start the new run. - "enqueue": Queue up the new run to start after the current run finishes.
Inherited from¶
RunsInvokePayload.multitaskStrategy
Defined in¶
signal?¶
optional
signal:AbortSignal
Abort controller signal to cancel the run.
Inherited from¶
RunsInvokePayload.signal
Defined in¶
streamMode?¶
optional
streamMode:StreamMode
|StreamMode
[]
One of "values"
, "messages"
, "updates"
or "events"
.
- "values"
: Stream the thread state any time it changes.
- "messages"
: Stream chat messages from thread state and calls to chat models,
token-by-token where possible.
- "updates"
: Stream the state updates returned by each node.
- "events"
: Stream all events produced by the run. You can also access these
afterwards using the client.runs.listEvents()
method.
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / types / MultitaskStrategy
Type Alias: MultitaskStrategy¶
MultitaskStrategy:
"reject"
|"interrupt"
|"rollback"
|"enqueue"
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / types / RunsWaitPayload
Type Alias: RunsWaitPayload¶
RunsWaitPayload:
RunsStreamPayload
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / types / StreamEvent
Type Alias: StreamEvent¶
StreamEvent:
"events"
|"metadata"
|"debug"
|"updates"
|"values"
|"messages/partial"
|"messages/metadata"
|"messages/complete"
|string
&object
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / types / StreamMode
Type Alias: StreamMode¶
StreamMode:
"values"
|"messages"
|"updates"
|"events"
|"debug"