文档
EN/中

指南
  • 快速入门
接入方式
  • Agent Skills
  • CLI
  • MCP
  • SDK
API 参考
  • 搜索
  • 内容
  • 研究
概念
  • 身份验证
  • 错误处理
  • 限流
下载 OpenAPI

SDK

TypeScript 和 Python 的类型化客户端,都从 AREX_API_KEY 读取密钥。

Markdown

TypeScript

research.run 创建 Run 并等待答案;research.create、get、wait、cancel 和 delete 可分步操作。错误均为 ArexError 的子类。

Shell
npm install @arex-research/ts-sdk
TypeScript
import { Arex } from "@arex-research/ts-sdk";

const arex = new Arex(); // reads AREX_API_KEY

const { results } = await arex.search("how are AI agents evaluated", { limit: 5 });
for (const { url } of results) {
  const page = await arex.contents(url, { maxCharacters: 4000 });
}
const run = await arex.research.run("Compare agent evaluation benchmarks", { mode: "fast" });
console.log(run.result.answer);

Python

需要 Python 3.10 及以上。AsyncArex 提供相同的异步调用。

Shell
pip install arex-python-sdk
Python
from arex import Arex

with Arex() as arex:  # reads AREX_API_KEY
    search = arex.search("how are AI agents evaluated", limit=5)
    for item in search.results:
        page = arex.contents(item.url, max_characters=4000)
    run = arex.research.run("Compare agent evaluation benchmarks", mode="fast")
    assert run.result is not None  # always set once run() returns
    print(run.result.answer)

作为 Agent 工具

在 Pi SDK 或 LangGraph 中把 SDK 调用封装成工具。

import { Arex } from "@arex-research/ts-sdk";

const arex = new Arex(); // reads AREX_API_KEY

export const arexTools = [
  {
    name: "arex_search",
    description: "Search the web for ranked URLs and snippets.",
    parameters: {
      type: "object",
      properties: { query: { type: "string" }, limit: { type: "number" } },
      required: ["query"],
    },
    execute: async ({ query, limit = 5 }: { query: string; limit?: number }) =>
      arex.search(query, { limit }),
  },
  {
    name: "arex_contents",
    description: "Read clean markdown text from a public URL.",
    parameters: {
      type: "object",
      properties: { url: { type: "string" } },
      required: ["url"],
    },
    execute: async ({ url }: { url: string }) =>
      arex.contents(url, { maxCharacters: 8000 }),
  },
  {
    name: "arex_research",
    description: "Answer a question with cited web sources in one call.",
    parameters: {
      type: "object",
      properties: { query: { type: "string" } },
      required: ["query"],
    },
    execute: async ({ query }: { query: string }) =>
      arex.research.run(query, { mode: "fast" }),
  },
];
npm · @arex-research/ts-sdkPyPI · arex-python-sdkGitHubTypeScript ChangelogPython Changelog
上一页MCP下一页搜索