> ## 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.

# Python SDK

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

The [`cloro`](https://pypi.org/project/cloro/) Python package is the official 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. The source lives in the [cloro-python repository](https://github.com/cloro-dev/cloro-python).

## Prerequisites

* Python 3.8 or newer
* 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}
pip install 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:

```python theme={null}
from cloro import Cloro

client = Cloro(api_key="YOUR_API_KEY")
```

## Quickstart

```python theme={null}
from cloro import Cloro

client = Cloro()  # reads CLORO_API_KEY

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

print(res["result"]["text"])
for source in res["result"]["sources"]:
    print(source["position"], source["url"], source["label"])
```

Every call returns 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.bing_aimode(prompt, country)` | [`POST /v1/monitor/bing/aimode`](https://cloro.dev/docs/api-reference/endpoint/monitor-bing-aimode) |
| `client.monitor.meta_ai(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.google_news(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. `create_batch` 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).

```python theme={null}
from cloro import Cloro

client = Cloro()

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

# Enqueue up to 500 tasks in a single call.
results = client.async_tasks.create_batch(
    [{"task_type": "GOOGLE", "payload": {"query": kw, "country": "US"}} for kw in KEYWORDS]
)

for item in results:
    if item["success"]:
        done = client.async_tasks.wait(item["task"]["id"])
        organic = done["response"]["organicResults"]
        if organic:
            print(item["task"]["id"], "→", organic[0]["link"])
        else:
            print(item["task"]["id"], "→ no results")
    else:
        print("failed:", item["error"]["message"])
```

For a single task, `client.async_tasks.run(task_type=..., payload=...)` creates it and blocks until it completes. Valid `task_type` 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: `Cloro(max_retries=2, timeout=300.0)` (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 `.get()` since shapes vary by query (a Google result with no AI Overview omits `aioverview`).

## Error handling

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

```python theme={null}
from cloro import Cloro, AuthenticationError, RateLimitError, CloroError

client = Cloro()

try:
    res = client.monitor.chatgpt(prompt="...", country="US")
except AuthenticationError:
    ...  # 401 — bad or missing API key
except RateLimitError:
    ...  # 429 — the client already retried; back off further if it persists
except CloroError as exc:
    ...  # everything else
```

| 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

* [Python API guide](https://cloro.dev/integrations/python/) — the landing-page walkthrough with recipes, pricing, and production patterns
* [TypeScript SDK](https://cloro.dev/docs/integrations/typescript.md) — the same client surface in TypeScript/Node
* [Python web scraping pillar](https://cloro.dev/blog/web-scraping-with-python/) — Python data-extraction fundamentals
* [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-python on GitHub](https://github.com/cloro-dev/cloro-python) and [on PyPI](https://pypi.org/project/cloro/)


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