> ## Documentation Index
> Fetch the complete documentation index at: https://cloro.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Use only the endpoint paths in https://cloro.dev/docs/skill.md. Do not derive a path from a docs page URL.
> For many requests, use the async API (POST /v1/async/task or POST /v1/async/task/batch). It has no sync surcharge.
> To call cloro as tools, use the MCP server at https://mcp.cloro.dev/mcp.
> Plan prices are at https://cloro.dev/pricing/. Credits for each request are at https://cloro.dev/docs/guides/providers.md.

# TypeScript SDK

> Install the official cloro TypeScript/Node SDK, configure your API key, and call nine engines, including ChatGPT and Google Search, from one typed client.

The [`@cloro-dev/cloro`](https://www.npmjs.com/package/@cloro-dev/cloro) npm package is the official TypeScript/Node SDK for the cloro API, the API for AI answers. It is one typed client for nine engines (ChatGPT, Google Search, Google News, Google AI Overview, Google AI Mode, Gemini, Bing Search, Bing AI Mode and Meta AI). Each call is a single authenticated request that returns structured JSON with sources. It ships ESM and CommonJS builds with bundled type declarations; the source lives in the [cloro-node repository](https://github.com/cloro-dev/cloro-node).

## Prerequisites

* Node 18 or newer (uses the built-in `fetch`)
* A cloro API key from the [dashboard](https://dashboard.cloro.dev) (see [Authentication](https://cloro.dev/docs/guides/authentication.md))

## Install the package

```bash theme={null}
npm install @cloro-dev/cloro
```

## Configure your API key

The client reads `CLORO_API_KEY` from the environment automatically:

```bash theme={null}
export CLORO_API_KEY="YOUR_API_KEY"
```

Or pass it to the constructor:

```ts theme={null}
import { Cloro } from "@cloro-dev/cloro";

const client = new Cloro({ apiKey: "YOUR_API_KEY" });
```

## Quickstart

```ts theme={null}
import { Cloro } from "@cloro-dev/cloro";

const client = new Cloro(); // reads 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);
}
```

Every call resolves with the `{ success, result }` envelope. Pass `include: {...}` to request extra formats (`markdown`, `html`, `searchQueries`, `shopping`, and more, depending on the engine).

## Every engine, one client

AI engines take a `prompt`; Google Search, Google News and Bing Search take a `query`. Each method is a thin wrapper over one endpoint.

| Method | Endpoint |
| - | - |
| `client.monitor.google({ query, country })` | [`POST /v1/monitor/google`](https://cloro.dev/docs/api-reference/endpoint/monitor-google) |
| `client.monitor.chatgpt({ prompt, country })` | [`POST /v1/monitor/chatgpt`](https://cloro.dev/docs/api-reference/endpoint/monitor-chatgpt) |
| `client.monitor.gemini({ prompt, country })` | [`POST /v1/monitor/gemini`](https://cloro.dev/docs/api-reference/endpoint/monitor-gemini) |
| `client.monitor.aimode({ prompt, country })` | [`POST /v1/monitor/aimode`](https://cloro.dev/docs/api-reference/endpoint/monitor-aimode) |
| `client.monitor.bingAimode({ prompt, country })` | [`POST /v1/monitor/bing/aimode`](https://cloro.dev/docs/api-reference/endpoint/monitor-bing-aimode) |
| `client.monitor.metaAi({ prompt, country })` | [`POST /v1/monitor/meta-ai`](https://cloro.dev/docs/api-reference/endpoint/monitor-meta-ai) |
| `client.monitor.bing({ query, country })` | [`POST /v1/monitor/bing`](https://cloro.dev/docs/api-reference/endpoint/monitor-bing) |
| `client.monitor.googleNews({ query, country })` | [`POST /v1/monitor/google/news`](https://cloro.dev/docs/api-reference/endpoint/monitor-google-news) |

`client.monitor.google` also accepts `location`, `uule`, `device`, and `pages` (1–10). `client.monitor.bing` also accepts `pages` (1–10) and `first`. The client exposes `client.countries()` and `client.states()` for the [supported countries](https://cloro.dev/docs/api-reference/endpoint/countries.md) and states.

## Async task queue

For large batches, don't loop synchronous calls — enqueue tasks and poll them. `createBatch` submits up to 500 tasks in one request; `wait` polls a task to completion with interval backoff. See [Async requests](https://cloro.dev/docs/guides/making-requests/async.md).

```ts theme={null}
import { Cloro } from "@cloro-dev/cloro";

const client = new Cloro();

const KEYWORDS = ["best running shoes", "trail running shoes", "waterproof running shoes"];

// Enqueue up to 500 tasks in a single call.
const results = await client.asyncTasks.createBatch(
  KEYWORDS.map((kw) => ({ taskType: "GOOGLE", payload: { query: kw, country: "US" } })),
);

for (const item of results) {
  if (item.success) {
    const done = await client.asyncTasks.wait(item.task.id);
    const organic = done.response.organicResults;
    if (organic?.length) {
      console.log(item.task.id, "→", organic[0].link);
    } else {
      console.log(item.task.id, "→ no results");
    }
  } else {
    console.log("failed:", item.error.message);
  }
}
```

For a single task, `client.asyncTasks.run({ taskType, payload })` creates it and resolves once it completes. Valid `taskType` values: `CHATGPT`, `GEMINI`, `AIMODE`, `BING_AIMODE`, `GOOGLE`, `GOOGLE_NEWS`, `BING`, `META_AI`.

## Reliability and configuration

The client retries timeouts, connection errors, and `429`/`5xx` responses with exponential backoff. Its default timeout is 300 seconds, the minimum the docs advise for a sync request. To set it yourself: `new Cloro({ maxRetries: 2, timeout: 300000 })` (timeout in milliseconds; see [Retries and cancellation](https://cloro.dev/docs/guides/error-handling.md#retries-and-cancellation)). Cap your own concurrency to your plan's limit (see [Concurrency](https://cloro.dev/docs/guides/concurrency.md)), read the key from `CLORO_API_KEY` rather than hardcoding it, and access response fields with optional chaining (`?.`) since shapes vary by query (a Google result with no AI Overview omits `aioverview`).

## Error handling

Every error subclasses `CloroError`, so one `instanceof CloroError` check catches everything. HTTP failures map to status-specific types:

```ts theme={null}
import { Cloro, AuthenticationError, RateLimitError, CloroError } from "@cloro-dev/cloro";

const client = new Cloro();

try {
  const res = 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;
  }
}
```

| Exception | Meaning |
| - | - |
| `AuthenticationError` | `401` — missing or invalid API key |
| `BadRequestError` | `400` — malformed request or failed validation |
| `PermissionDeniedError` | `403` — insufficient credits |
| `NotFoundError` | `404` — resource does not exist |
| `ConflictError` | `409` — an async task with that `idempotencyKey` already exists |
| `RateLimitError` | `429` — rate, concurrency, or queue limit exceeded |
| `InternalServerError` | `5xx` — the API failed to process the request |
| `APITimeoutError` | request timed out before a response |
| `TaskFailedError` / `TaskTimeoutError` | async task failed, or did not finish within the poll timeout |

## Next steps

* [JavaScript & Node API guide](https://cloro.dev/integrations/javascript/) — the landing-page walkthrough with recipes, pricing, and production patterns
* [Python SDK](https://cloro.dev/docs/integrations/python.md) — the same client surface in Python
* [Google SERP API](https://cloro.dev/serp-api/) — the SERP endpoint this SDK wraps
* [Making requests](https://cloro.dev/docs/guides/making-requests/sync.md) — the raw sync and [async](https://cloro.dev/docs/guides/making-requests/async.md) HTTP contracts
* [Providers](https://cloro.dev/docs/guides/providers.md) and [Billing & credits](https://cloro.dev/docs/guides/billing.md) — per-engine credit costs
* [API reference](https://cloro.dev/docs/api-reference/endpoint/monitor-google.md) — full request and response schemas
* [cloro-node on GitHub](https://github.com/cloro-dev/cloro-node) and [on npm](https://www.npmjs.com/package/@cloro-dev/cloro)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.