SDK (JS/TS)
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk¶
Classes¶
Functions¶
@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
• payload.name?: string
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
,options
?):Promise
\<AssistantGraph
>
Get the JSON representation of the graph assigned to a runnable
Parameters¶
• assistantId: string
The ID of the assistant.
• options?
• options.xray?: number
| boolean
Whether to include subgraphs in the serialized graph representation. If an integer value is provided, only subgraphs with a depth less than or equal to the value will be included.
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¶
getSubgraphs()¶
getSubgraphs(
assistantId
,options
?):Promise
\<Subgraphs
>
Get the schemas of an assistant by ID.
Parameters¶
• assistantId: string
The ID of the assistant to get the schema of.
• options?
Additional options for getting subgraphs, such as namespace or recursion extraction.
• options.namespace?: string
• options.recurse?: boolean
Returns¶
Promise
\<Subgraphs
>
The subgraphs of the assistant.
Defined in¶
getVersions()¶
getVersions(
assistantId
,payload
?):Promise
\<AssistantVersion
[]>
List all versions of an assistant.
Parameters¶
• assistantId: string
ID of the assistant.
• payload?
• payload.limit?: number
• payload.metadata?: Metadata
• payload.offset?: number
Returns¶
Promise
\<AssistantVersion
[]>
List of assistant versions.
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¶
setLatest()¶
setLatest(
assistantId
,version
):Promise
\<Assistant
>
Change the version of an assistant.
Parameters¶
• assistantId: string
ID of the assistant.
• version: number
The version to change to.
Returns¶
Promise
\<Assistant
>
The updated assistant.
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
• payload.name?: string
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¶
store¶
store:
StoreClient
The client for interacting with the KV store.
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
,action
):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
• action: CancelAction
= "interrupt"
Action to take when cancelling the run. Possible values are interrupt
or rollback
. Default is interrupt
.
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
,options
?):Promise
\<void
>
Block until a run is done.
Parameters¶
• threadId: string
The ID of the thread.
• runId: string
The ID of the run.
• options?
• options.signal?: AbortSignal
Returns¶
Promise
\<void
>
Defined in¶
joinStream()¶
joinStream(
threadId
,runId
,options
?):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.
• options?: AbortSignal
| object
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.
• options.status?: RunStatus
Status of the run to filter by.
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
\<RunsWaitPayload
, "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?: RunsWaitPayload
Returns¶
Promise
\<DefaultValues
>
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / StoreClient
Class: StoreClient¶
Extends¶
BaseClient
Constructors¶
new StoreClient()¶
new StoreClient(
config
?):StoreClient
Parameters¶
• config?: ClientConfig
Returns¶
Inherited from¶
BaseClient.constructor
Defined in¶
Methods¶
deleteItem()¶
deleteItem(
namespace
,key
):Promise
\<void
>
Delete an item.
Parameters¶
• namespace: string
[]
A list of strings representing the namespace path.
• key: string
The unique identifier for the item.
Returns¶
Promise
\<void
>
Promise
Defined in¶
getItem()¶
getItem(
namespace
,key
):Promise
\<null
|Item
>
Retrieve a single item.
Parameters¶
• namespace: string
[]
A list of strings representing the namespace path.
• key: string
The unique identifier for the item.
Returns¶
Promise
\<null
| Item
>
Promise
Defined in¶
listNamespaces()¶
listNamespaces(
options
?):Promise
\<ListNamespaceResponse
>
List namespaces with optional match conditions.
Parameters¶
• options?
• options.limit?: number
Maximum number of namespaces to return (default is 100).
• options.maxDepth?: number
Optional integer specifying the maximum depth of namespaces to return.
• options.offset?: number
Number of namespaces to skip before returning results (default is 0).
• options.prefix?: string
[]
Optional list of strings representing the prefix to filter namespaces.
• options.suffix?: string
[]
Optional list of strings representing the suffix to filter namespaces.
Returns¶
Promise
\<ListNamespaceResponse
>
Promise
Defined in¶
putItem()¶
putItem(
namespace
,key
,value
):Promise
\<void
>
Store or update an item.
Parameters¶
• namespace: string
[]
A list of strings representing the namespace path.
• key: string
The unique identifier for the item within the namespace.
• value: Record
\<string
, any
>
A dictionary containing the item's data.
Returns¶
Promise
\<void
>
Promise
Defined in¶
searchItems()¶
searchItems(
namespacePrefix
,options
?):Promise
\<SearchItemsResponse
>
Search for items within a namespace prefix.
Parameters¶
• namespacePrefix: string
[]
List of strings representing the namespace prefix.
• options?
• options.filter?: Record
\<string
, any
>
Optional dictionary of key-value pairs to filter results.
• options.limit?: number
Maximum number of items to return (default is 10).
• options.offset?: number
Number of items to skip before returning results (default is 0).
• options.query?: string
Optional search query.
Returns¶
Promise
\<SearchItemsResponse
>
Promise
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
\<DefaultValues
>>
Copy an existing thread
Parameters¶
• threadId: string
ID of the thread to be copied
Returns¶
Promise
\<Thread
\<DefaultValues
>>
Newly copied thread
Defined in¶
create()¶
create(
payload
?):Promise
\<Thread
\<DefaultValues
>>
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
\<DefaultValues
>>
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
\<DefaultValues
>>
Get a thread by ID.
Parameters¶
• threadId: string
ID of the thread.
Returns¶
Promise
\<Thread
\<DefaultValues
>>
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.checkpoint?: Partial
\<Omit
\<Checkpoint
, "thread_id"
>>
• options.limit?: number
• options.metadata?: Metadata
Returns¶
Promise
\<ThreadState
\<ValuesType
>[]>
List of thread states.
Defined in¶
getState()¶
getState\<
ValuesType
>(threadId
,checkpoint
?,options
?):Promise
\<ThreadState
\<ValuesType
>>
Get state for a thread.
Type Parameters¶
• ValuesType = DefaultValues
Parameters¶
• threadId: string
ID of the thread.
• checkpoint?: string
| Checkpoint
• options?
• options.subgraphs?: boolean
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
\<DefaultValues
>[]>
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.
• query.status?: ThreadStatus
Thread status to filter on. Must be one of 'idle', 'busy', 'interrupted' or 'error'.
Returns¶
Promise
\<Thread
\<DefaultValues
>[]>
List of threads
Defined in¶
update()¶
update(
threadId
,payload
?):Promise
\<Thread
\<DefaultValues
>>
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
\<DefaultValues
>>
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.checkpoint?: Checkpoint
• options.checkpointId?: string
• options.values: ValuesType
Returns¶
Promise
\<Pick
\<Config
, "configurable"
>>
Defined in¶
@langchain/langgraph-sdk • Docs
@langchain/langgraph-sdk / getApiKey
Function: getApiKey()¶
getApiKey(
apiKey
?):string
|undefined
Get the API key from the environment. Precedence: 1. explicit argument 2. LANGGRAPH_API_KEY 3. LANGSMITH_API_KEY 4. LANGCHAIN_API_KEY
Parameters¶
• apiKey?: string
Optional API key provided as an argument
Returns¶
string
| undefined
The API key if found, otherwise undefined