@blaxel/langgraph

中文文档
0.3.36发布于 2026/11/10MITTypeScriptESM + CJS近 30 天下载 4412

Blaxel SDK for TypeScript

原始使用文档
文档目录11 节
  1. Example
  2. Installation
  3. Authentication
  4. Usage
  5. Model use
  6. MCP tool use
  7. Telemetry
  8. Requirements
  9. Documentation
  10. Contributing
  11. License

Blaxel TypeScript SDK

Blaxel is a perpetual sandbox platform that achieves near instant latency by keeping infinite secure sandboxes on automatic standby, while co-hosting your agent logic to cut network overhead.

This package contains helper functions for Blaxel's TypeScript SDK, to let you retrieve model clients and MCP tool definitions in the format required by LangChain/LangGraph.

Example

import { blTools, blModel } from "@blaxel/langgraph";

const stream = await createReactAgent({
  llm: await blModel("sandbox-openai"),
  prompt: prompt,
  tools: [
    ...(await blTools(["blaxel-search", "webcrawl"])),
    tool(
      async (input: any) => {
        console.debug("TOOLCALLING: local weather", input);
        return `The weather in ${input.city} is sunny`;
      },
      {
        name: "weather",
        description: "Get the weather in a specific city",
        schema: z.object({
          city: z.string(),
        }),
      }
    ),
  ],
}).stream({
  messages: [new HumanMessage(process.argv[2])],
});

Installation

# npm
npm install @blaxel/langgraph

# yarn
yarn add @blaxel/langgraph

# bun
bun add @blaxel/langgraph

Authentication

The SDK authenticates with your Blaxel workspace using these sources (in priority order):

  1. Blaxel CLI, when logged in
  2. Environment variables in .env file (BL_WORKSPACE, BL_API_KEY)
  3. System environment variables
  4. Blaxel configuration file (~/.blaxel/config.yaml)

When developing locally, the recommended method is to just log in to your workspace with the Blaxel CLI:

bl login YOUR-WORKSPACE

This allows you to run Blaxel SDK functions that will automatically connect to your workspace without additional setup. When you deploy on Blaxel, this connection persists automatically.

When running Blaxel SDK from a remote server that is not Blaxel-hosted, we recommend using environment variables as described in the third option above.

Usage

Model use

Blaxel acts as a unified gateway for model APIs, centralizing access credentials, tracing and telemetry. You can integrate with any model API provider, or deploy your own custom model. When a model is deployed on Blaxel, a global API endpoint is also created to call it.

This package includes a helper function that creates a reference to a model deployed on Blaxel and returns a framework-specific model client that routes API calls through Blaxel's unified gateway.

// With LangChain
import { blModel } from "@blaxel/langgraph";
const model = await blModel("gpt-5-mini");

MCP tool use

Blaxel lets you deploy and host Model Context Protocol (MCP) servers, accessible at a global endpoint over streamable HTTP.

This package includes a helper function that retrieves and returns tool definitions from a Blaxel-hosted MCP server in the format required by specific frameworks.

Here is an example of retrieving tool definitions from a Blaxel sandbox's MCP server in the format required by LangGraph:

import { SandboxInstance } from "@blaxel/core";
import { blTools } from "@blaxel/langgraph";

// Create a new sandbox (base-image is Alpine + Node.js 22 + git; no Python — use "blaxel/py-app:latest" for Python)
const sandbox = await SandboxInstance.createIfNotExists({
  name: "my-sandbox",
  image: "blaxel/base-image:latest",
  memory: 4096,
  region: "us-pdx-1",
  ttl: "24h"
});

// Get sandbox tools
const tools = await blTools(['sandbox/my-sandbox'])

Telemetry

Instrumentation happens automatically when workloads run on Blaxel.

Enable automatic telemetry by importing the @blaxel/telemetry package:

import "@blaxel/telemetry";

Requirements

  • Node.js v18 or later

Documentation

Contributing

Contributions are welcome! Please feel free to submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

版本与发布记录

@blaxel/langgraph 共发布 684 个版本,首次发布于 2025/05/04;过去 12 个月发布了 338 个版本。

版本发布日期距今
0.3.36latest2026/11/10今天
0.3.36-preview.349preview2026/11/10今天
0.3.36-preview.3472026/11/072 天前
0.3.36-preview.3482026/11/072 天前
0.3.36-preview.3462026/11/072 天前
0.3.35-preview.3442026/11/063 天前

其他发布通道:dev → 0.3.18-dev.283,preview → 0.3.36-preview.349。

关于 @blaxel/langgraph 的常见问题

@blaxel/langgraph 是什么?

Blaxel SDK for TypeScript

如何安装 @blaxel/langgraph?

在项目目录运行 npm install @blaxel/langgraph,或使用 pnpm add / yarn add / bun add。

@blaxel/langgraph 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@blaxel/langgraph 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@blaxel/langgraph 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@blaxel/langgraph 可以商用吗?

@blaxel/langgraph 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@blaxel/langgraph 的下载量有多少?

根据 npm 官方下载统计,@blaxel/langgraph 在 2026/10/09 – 2026/11/07 这 30 天内被下载 4,412 次,日均约 147 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@blaxel/langgraph 还在维护吗?

最新版本 0.3.36 发布于 2026/11/10(今天);至今共发布 684 个版本,其中过去 12 个月发布了 338 个;首次发布于 2025/05/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。