JSPM

  • Created
  • Published
  • Downloads 1432415
  • Score
    100M100P100Q209499F
  • License MIT

Client library for interacting with the LangGraph API

Package Exports

  • @langchain/langgraph-sdk
  • @langchain/langgraph-sdk/auth
  • @langchain/langgraph-sdk/client
  • @langchain/langgraph-sdk/logging
  • @langchain/langgraph-sdk/package.json
  • @langchain/langgraph-sdk/react
  • @langchain/langgraph-sdk/react-ui
  • @langchain/langgraph-sdk/react-ui/server

Readme

LangGraph JS/TS SDK

This repository contains the JS/TS SDK for interacting with the LangGraph REST API.

Quick Start

To get started with the JS/TS SDK, install the package

pnpm add @langchain/langgraph-sdk

You will need a running LangGraph API server. If you're running a server locally using langgraph-cli, SDK will automatically point at http://localhost:8123, otherwise you would need to specify the server URL when creating a client.

import { Client } from "@langchain/langgraph-sdk";

const client = new Client();

// List all assistants
const assistants = await client.assistants.search({
  metadata: null,
  offset: 0,
  limit: 10,
});

// We auto-create an assistant for each graph you register in config.
const agent = assistants[0];

// Start a new thread
const thread = await client.threads.create();

// Start a streaming run
const messages = [{ role: "human", content: "what's the weather in la" }];

const streamResponse = client.runs.stream(
  thread["thread_id"],
  agent["assistant_id"],
  {
    input: { messages },
  }
);

for await (const chunk of streamResponse) {
  console.log(chunk);
}

Documentation

To generate documentation, run the following commands:

  1. Generate docs.

     pnpm typedoc
  2. Consolidate doc files into one markdown file.

     npx concat-md --decrease-title-levels --ignore=js_ts_sdk_ref.md --start-title-level-at 2 docs > docs/js_ts_sdk_ref.md
  3. Copy js_ts_sdk_ref.md to MkDocs directory.

     cp docs/js_ts_sdk_ref.md ../../docs/docs/cloud/reference/sdk/js_ts_sdk_ref.md

Reference Documentation

The reference documentation is available here.

More usage examples can be found here.

Change Log

The change log for new versions can be found here.