JS/TS
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk¶
Classes¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / AssistantsClient
Class: AssistantsClient¶
Extends¶
BaseClient
Constructors¶
new AssistantsClient()¶
new AssistantsClient(
config
?):AssistantsClient
Parameters¶
• config?: ClientConfig
Returns¶
Inherited from¶
BaseClient.constructor
Defined in¶
Methods¶
create()¶
create(
payload
):Promise
\<Assistant
>
Create a new assistant.
Parameters¶
• payload
Payload for creating an assistant.
• payload.assistantId?: string
• payload.config?: Config
• payload.graphId: string
• payload.ifExists?: OnConflictBehavior
• 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¶
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¶
search()¶
search(
query
?):Promise
\<Assistant
[]>
List assistants.
Parameters¶
• query?
Query options.
• query.graphId?: string
• 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
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¶
crons¶
crons:
CronsClient
The client for interacting with cron runs.
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 / CronsClient
Class: CronsClient¶
Extends¶
BaseClient
Constructors¶
new CronsClient()¶
new CronsClient(
config
?):CronsClient
Parameters¶
• config?: ClientConfig
Returns¶
Inherited from¶
BaseClient.constructor
Defined in¶
Methods¶
create()¶
create(
assistantId
,payload
?):Promise
\<Run
>
Parameters¶
• assistantId: string
Assistant ID to use for this cron job.
• payload?: CronsCreatePayload
Payload for creating a cron job.
Returns¶
Promise
\<Run
>
Defined in¶
createForThread()¶
createForThread(
threadId
,assistantId
,payload
?):Promise
\<Run
>
Parameters¶
• threadId: string
The ID of the thread.
• assistantId: string
Assistant ID to use for this cron job.
• payload?: CronsCreatePayload
Payload for creating a cron job.
Returns¶
Promise
\<Run
>
The created background run.
Defined in¶
delete()¶
delete(
cronId
):Promise
\<void
>
Parameters¶
• cronId: string
Cron ID of Cron job to delete.
Returns¶
Promise
\<void
>
Defined in¶
search()¶
search(
query
?):Promise
\<Cron
[]>
Parameters¶
• query?
Query options.
• query.assistantId?: string
• query.limit?: number
• query.offset?: number
• query.threadId?: string
Returns¶
Promise
\<Cron
[]>
List of crons.
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / RunsClient
Class: RunsClient¶
Extends¶
BaseClient
Constructors¶
new RunsClient()¶
new RunsClient(
config
?):RunsClient
Parameters¶
• config?: ClientConfig
Returns¶
Inherited from¶
BaseClient.constructor
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¶
createBatch()¶
createBatch(
payloads
):Promise
\<Run
[]>
Create a batch of stateless background runs.
Parameters¶
• payloads: RunsCreatePayload
& object
[]
An array of payloads for creating runs.
Returns¶
Promise
\<Run
[]>
An array of created runs.
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¶
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¶
joinStream()¶
joinStream(
threadId
,runId
,signal
?):AsyncGenerator
\<object
,any
,unknown
>
Stream output from a run in real-time, until the run is done. Output is not buffered, so any output produced before this call will not be received here.
Parameters¶
• threadId: string
The ID of the thread.
• runId: string
The ID of the run.
• signal?: AbortSignal
An optional abort signal.
Returns¶
AsyncGenerator
\<object
, any
, unknown
>
An async generator yielding stream parts.
data¶
data:
any
event¶
event:
StreamEvent
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¶
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"
| "onCompletion"
>
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"
| "onCompletion"
>
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 / ThreadsClient
Class: ThreadsClient¶
Extends¶
BaseClient
Constructors¶
new ThreadsClient()¶
new ThreadsClient(
config
?):ThreadsClient
Parameters¶
• config?: ClientConfig
Returns¶
Inherited from¶
BaseClient.constructor
Defined in¶
Methods¶
copy()¶
copy(
threadId
):Promise
\<Thread
>
Copy an existing thread
Parameters¶
• threadId: string
ID of the thread to be copied
Returns¶
Promise
\<Thread
>
Newly copied thread
Defined in¶
create()¶
create(
payload
?):Promise
\<Thread
>
Create a new thread.
Parameters¶
• payload?
Payload for creating a thread.
• payload.ifExists?: OnConflictBehavior
• payload.metadata?: Metadata
Metadata for the thread.
• payload.threadId?: string
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¶
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¶
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
\<Pick
\<Config
,"configurable"
>>
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
\<Pick
\<Config
, "configurable"
>>