Skip to content

JS/TS

@langchain/langgraph-sdkDocs


@langchain/langgraph-sdk

Classes

@langchain/langgraph-sdkDocs


@langchain/langgraph-sdk / AssistantsClient

Class: AssistantsClient

Extends

  • BaseClient

Constructors

new AssistantsClient()

new AssistantsClient(config?): AssistantsClient

Parameters

config?: ClientConfig

Returns

AssistantsClient

Inherited from

BaseClient.constructor

Defined in

client.mts:42

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

client.mts:238


delete()

delete(assistantId): Promise\<void>

Delete an assistant.

Parameters

assistantId: string

ID of the assistant.

Returns

Promise\<void>

Defined in

client.mts:286


get()

get(assistantId): Promise\<Assistant>

Get an assistant by ID.

Parameters

assistantId: string

The ID of the assistant.

Returns

Promise\<Assistant>

Assistant

Defined in

client.mts:211


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

client.mts:220


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

client.mts:229


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

client.mts:297


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

client.mts:263

@langchain/langgraph-sdkDocs


@langchain/langgraph-sdk / Client

Class: Client

Constructors

new Client()

new Client(config?): Client

Parameters

config?: ClientConfig

Returns

Client

Defined in

client.mts:901

Properties

assistants

assistants: AssistantsClient

The client for interacting with assistants.

Defined in

client.mts:884


crons

crons: CronsClient

The client for interacting with cron runs.

Defined in

client.mts:899


runs

runs: RunsClient

The client for interacting with runs.

Defined in

client.mts:894


threads

threads: ThreadsClient

The client for interacting with threads.

Defined in

client.mts:889

@langchain/langgraph-sdkDocs


@langchain/langgraph-sdk / CronsClient

Class: CronsClient

Extends

  • BaseClient

Constructors

new CronsClient()

new CronsClient(config?): CronsClient

Parameters

config?: ClientConfig

Returns

CronsClient

Inherited from

BaseClient.constructor

Defined in

client.mts:42

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

client.mts:150


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

client.mts:122


delete()

delete(cronId): Promise\<void>

Parameters

cronId: string

Cron ID of Cron job to delete.

Returns

Promise\<void>

Defined in

client.mts:175


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

client.mts:186

@langchain/langgraph-sdkDocs


@langchain/langgraph-sdk / RunsClient

Class: RunsClient

Extends

  • BaseClient

Constructors

new RunsClient()

new RunsClient(config?): RunsClient

Parameters

config?: ClientConfig

Returns

RunsClient

Inherited from

BaseClient.constructor

Defined in

client.mts:42

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

client.mts:777


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

client.mts:634


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

client.mts:663


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

client.mts:873


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

client.mts:765


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

client.mts:797


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

client.mts:811


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

client.mts:734


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

client.mts:524

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

client.mts:533


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

client.mts:680

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

client.mts:686

@langchain/langgraph-sdkDocs


@langchain/langgraph-sdk / ThreadsClient

Class: ThreadsClient

Extends

  • BaseClient

Constructors

new ThreadsClient()

new ThreadsClient(config?): ThreadsClient

Parameters

config?: ClientConfig

Returns

ThreadsClient

Inherited from

BaseClient.constructor

Defined in

client.mts:42

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

client.mts:355


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

client.mts:332


delete()

delete(threadId): Promise\<void>

Delete a thread.

Parameters

threadId: string

ID of the thread.

Returns

Promise\<void>

Defined in

client.mts:388


get()

get(threadId): Promise\<Thread>

Get a thread by ID.

Parameters

threadId: string

ID of the thread.

Returns

Promise\<Thread>

The thread.

Defined in

client.mts:322


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

client.mts:501


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

client.mts:431


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

client.mts:471


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

client.mts:400


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

client.mts:368


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">>

Defined in

client.mts:448

Comments