@cloro-dev/cloro

中文文档
0.4.0发布于 2026/11/08MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 1万

Official TypeScript/Node SDK for the cloro API: one API for Google Search and every AI answer engine (ChatGPT, Gemini, AI Overview, AI Mode, Bing AI Mode).

原始使用文档
文档目录9 节
  1. Installation
  2. Quickstart
  3. Engines
  4. Async task queue
  5. Configuration
  6. Error handling
  7. Reference data
  8. Links
  9. License

cloro TypeScript / Node SDK

The official JS SDK for cloro, for TypeScript and Node. cloro is a SERP API with one API for Google Search and every AI answer engine (ChatGPT, Gemini, AI Overview, AI Mode, Bing AI Mode). Real-time, structured JSON.

cloro also has an official Python SDK, cloro on PyPI, and a hosted MCP server for Claude, Cursor and ChatGPT, so an AI agent can call the same endpoints as tools.

Use the SDK, or just curl it: same clean response either way. The SDK adds typed methods, sensible retries, and a polling helper for the async task queue so you don't hand-roll it. Ships with TypeScript types and both ESM and CommonJS builds.

Installation

npm install @cloro-dev/cloro

Requires Node 18+ (uses the built-in fetch). Works with TypeScript, ESM, and CommonJS.

Quickstart

import { Cloro } from "@cloro-dev/cloro";

const client = new Cloro({ apiKey: "sk_live_..." }); // or set CLORO_API_KEY

const res = await client.monitor.chatgpt({
  prompt: "What do you know about Acme Corp?",
  country: "US",
  include: { markdown: true },
});

console.log(res.result.text);
for (const source of res.result.sources) {
  console.log(source.position, source.url, source.label);
}

The API key is read from the CLORO_API_KEY environment variable when you don't pass apiKey. Get a key (and 500 free credits) at dashboard.cloro.dev.

CommonJS
const { Cloro } = require("@cloro-dev/cloro");

const client = new Cloro({ apiKey: "sk_live_..." });
client.monitor.chatgpt({ prompt: "...", country: "US" }).then((res) => {
  console.log(res.result.text);
});

Engines

Every engine is a method on client.monitor. AI engines take a prompt; Google Search and Google News take a query.

await client.monitor.chatgpt({ prompt: "...", country: "US" });
await client.monitor.gemini({ prompt: "...", country: "US" });
await client.monitor.aimode({ prompt: "...", country: "US" }); // Google AI Mode
await client.monitor.bingAimode({ prompt: "...", country: "US" }); // Bing AI Mode

await client.monitor.google({ query: "best crm", country: "US", pages: 1 });
await client.monitor.googleNews({ query: "acme corp", country: "US" });

Pass include: { ... } to request extra formats — markdown, html, searchQueries, shopping, and more, depending on the engine.

Bing AI Mode accepts only include: { markdown, html }. The html value is a URL to the page that Bing shows. You can also set state to a two-letter US state code (only with country: "US"). The result has text, sources, and citationPills.

const bing = await client.monitor.bingAimode({
  prompt: "best crm for startups",
  country: "US",
  state: "CA",
  include: { markdown: true },
});
for (const pill of bing.result.citationPills) {
  console.log(pill.position, pill.domain, pill.url);
}

Async task queue

For high-volume or long-running work, enqueue tasks and poll them to completion. run() does create-then-wait in one call:

const result = await client.asyncTasks.run({
  taskType: "CHATGPT",
  payload: { prompt: "What is cloro?", country: "US" },
});
console.log(result.response); // present once COMPLETED
console.log(result.credits); // credits reserved / charged

Prefer to manage the lifecycle yourself:

const task = await client.asyncTasks.create({
  taskType: "GOOGLE",
  payload: { query: "serp api", country: "US" },
  priority: 5,
});
const snapshot = await client.asyncTasks.retrieve(task); // non-blocking
const done = await client.asyncTasks.wait(task, { timeout: 120_000, pollInterval: 2000 });

Batch up to 500 tasks in a single request (results preserve input order):

const results = await client.asyncTasks.createBatch([
  { taskType: "CHATGPT", payload: { prompt: "q1", country: "US" } },
  { taskType: "GEMINI", payload: { prompt: "q2", country: "GB" } },
]);
for (const item of results) {
  if (item.success) await client.asyncTasks.wait(item.task.id);
  else console.log("failed:", item.error.message);
}

Queue-wide status:

await client.asyncTasks.status(); // queued / processing counts, concurrency usage

Valid taskType values: CHATGPT, GEMINI, AIMODE, BING_AIMODE, GOOGLE, GOOGLE_NEWS.

Configuration

const client = new Cloro({
  apiKey: "sk_live_...",
  baseUrl: "https://api.cloro.dev", // override if needed
  timeout: 300_000, // per-request milliseconds (the default)
  maxRetries: 2, // timeouts, connection errors, 429/5xx
});

Error handling

All errors subclass CloroError. HTTP failures map to status-specific types:

import { Cloro, AuthenticationError, RateLimitError, CloroError } from "@cloro-dev/cloro";

try {
  await client.monitor.chatgpt({ prompt: "...", country: "US" });
} catch (err) {
  if (err instanceof AuthenticationError) {
    // 401 — bad or missing API key
  } else if (err instanceof RateLimitError) {
    // 429 — the client already retried; back off further if it persists
  } else if (err instanceof CloroError) {
    // everything else
  } else {
    throw err;
  }
}

BadRequestError (400), PermissionDeniedError (403), NotFoundError (404), ConflictError (409), and InternalServerError (5xx) are also available, along with TaskFailedError / TaskTimeoutError from the poller and APITimeoutError / APIConnectionError from the transport.

Reference data

await client.countries(); // supported countries
await client.countries("chatgpt");
await client.countries("bing_aimode"); // countries for Bing AI Mode
await client.states(); // US states for location targeting (Google, Bing AI Mode)

License

MIT

版本与发布记录

@cloro-dev/cloro 共发布 6 个版本,首次发布于 2026/07/14;过去 12 个月发布了 6 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.4.0latest2026/11/082 天前
0.3.02026/11/063 天前
0.2.02026/10/1525 天前
0.1.22026/10/071 个月前
0.1.12026/07/143 个月前
0.1.02026/07/143 个月前

关于 @cloro-dev/cloro 的常见问题

@cloro-dev/cloro 是什么?

Official TypeScript/Node SDK for the cloro API: one API for Google Search and every AI answer engine (ChatGPT, Gemini, AI Overview, AI Mode, Bing AI Mode).

如何安装 @cloro-dev/cloro?

在项目目录运行 npm install @cloro-dev/cloro,或使用 pnpm add / yarn add / bun add。

@cloro-dev/cloro 支持 TypeScript 吗?

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

@cloro-dev/cloro 支持 ESM 还是 CommonJS?

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

@cloro-dev/cloro 需要什么版本的 Node.js?

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

@cloro-dev/cloro 可以商用吗?

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

@cloro-dev/cloro 的下载量有多少?

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

@cloro-dev/cloro 还在维护吗?

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