Skip to main content

langchain-cloro

This package contains the LangChain integration for cloro.dev - a unified API for monitoring multiple AI providers including Google Search, ChatGPT, Gemini, and Bing AI Mode.

Installation

pip install langchain-cloro

Setup

You'll need a cloro API key. Get one at https://cloro.dev.

Set the API key as an environment variable:

export CLORO_API_KEY="your-api-key-here"

Or pass it directly when initializing:

from langchain_cloro import CloroGoogleSearch

tool = CloroGoogleSearch(cloro_api_key="your-api-key-here")

Available Tools

CloroGoogleSearch

Extract structured data from Google Search results, including organic results, People Also Ask questions, related searches, and optional AI Overview data.

from langchain_cloro import CloroGoogleSearch

tool = CloroGoogleSearch()

# Basic search
results = tool.invoke({"query": "best laptops for programming"})

# With AI Overview
results = tool.invoke({
    "query": "best laptops for programming",
    "include_aioverview": True,
    "aioverview_markdown": True
})

# Multiple pages
results = tool.invoke({
    "query": "python tutorials",
    "pages": 3,
    "country": "US",
    "device": "desktop"
})

Parameters:

  • query (str, required): The search query
  • country (str): ISO 3166-1 alpha-2 country code. Default: "US"
  • device (str): "desktop" or "mobile". Default: "desktop"
  • pages (int): Number of pages to scrape (1-10). Default: 1
  • include_aioverview (bool): Include Google AI Overview. Default: False
  • aioverview_markdown (bool): Format AI Overview as markdown. Default: False
  • include_html (bool): Include raw HTML response. Default: False

CloroChatGPT

Extract structured data from ChatGPT with shopping cards, entity extraction, and advanced features for monitoring products, prices, and brand mentions.

from langchain_cloro import CloroChatGPT

tool = CloroChatGPT()

# Basic query
results = tool.invoke({"prompt": "What are the best sneakers under $100?"})

# With shopping card data
results = tool.invoke({
    "prompt": "best running shoes",
    "include_raw_response": True,
    "include_search_queries": True
})

Parameters:

  • prompt (str, required): The prompt/query
  • country (str): ISO 3166-1 alpha-2 country code. Default: "US"
  • include_raw_response (bool): Include raw streaming response events. Default: False
  • include_search_queries (bool): Include search fan-out queries. Default: False
  • include_html (bool): Include HTML response. Default: False
  • include_markdown (bool): Include markdown response. Default: False

CloroGemini

Extract structured data from Google's Gemini AI with source citations and multiple output formats.

from langchain_cloro import CloroGemini

tool = CloroGemini()

results = tool.invoke({"prompt": "Explain quantum entanglement"})

Parameters:

  • prompt (str, required): The prompt/query
  • country (str): ISO 3166-1 alpha-2 country code. Default: "US"
  • include_html (bool): Include HTML response. Default: False
  • include_markdown (bool): Include markdown response. Default: False

CloroBingAIMode

Get the answer that Bing AI Mode gives to a prompt, with its sources and inline citation pills.

from langchain_cloro import CloroBingAIMode

tool = CloroBingAIMode()

results = tool.invoke({"prompt": "What are the best project management tools?"})

# From a US state, with the answer as Markdown
results = tool.invoke({
    "prompt": "best pizza near me",
    "country": "US",
    "state": "NY",
    "include_markdown": True
})

Parameters:

  • prompt (str, required): The prompt/query. Max 3,500 characters after URL encoding (fewer for non-Latin scripts)
  • country (str): ISO 3166-1 alpha-2 country code. Default: "US"
  • state (str): Two-letter US state code. Use it only with country "US". Default: None
  • include_html (bool): Include HTML response. Default: False
  • include_markdown (bool): Include markdown response. Default: False

The response result has text, sources, citationPills, and markdown or html when you ask for them. A request costs 4 credits, plus 2 for a sync request, plus 2 for a US state.

get_countries Utility

Get list of supported country codes for specific AI providers.

from langchain_cloro import get_countries

# Get all countries
all_countries = get_countries()

# Get countries for specific model
chatgpt_countries = get_countries(model="chatgpt")
google_countries = get_countries(model="google")

Usage with LangChain Agents

With an Agent

from langchain.agents import initialize_agent, AgentType
from langchain_openai import OpenAI
from langchain_cloro import CloroGoogleSearch, CloroChatGPT

llm = OpenAI(temperature=0)
tools = [CloroGoogleSearch(), CloroChatGPT()]

agent = initialize_agent(
    tools,
    llm,
    agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
    verbose=True,
)

agent.run("What are the latest developments in AI?")

With LCEL

from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
from langchain_openai import ChatOpenAI
from langchain_cloro import CloroChatGPT

chatgpt = CloroChatGPT()

prompt = ChatPromptTemplate.from_messages([
    ("system", "Answer based on the AI's response:\n\n{response}"),
    ("user", "{question}")
])

chain = {
    "response": lambda x: chatgpt.invoke({"prompt": x["question"]}),
    "question": lambda x: x["question"]
} | prompt | ChatOpenAI() | StrOutputParser()

response = chain.invoke({"question": "What is LangChain?"})
print(response)

Multiple Tools Example

from langchain_cloro import (
    CloroGoogleSearch,
    CloroChatGPT,
    CloroGemini,
    CloroBingAIMode,
)

tools = [
    CloroGoogleSearch(),  # For search queries
    CloroChatGPT(),      # For shopping/product queries
    CloroGemini(),       # For general AI queries
    CloroBingAIMode(),   # For Bing AI answers with citations
]

Supported Country Codes

Use the get_countries() utility to fetch supported countries:

from langchain_cloro import get_countries

# Check which countries are available for each model
models = ["google", "chatgpt", "gemini", "bing_aimode"]

for model in models:
    countries = get_countries(model=model)
    print(f"{model}: {len(countries)} countries")

Development

Running Tests

# Unit tests
pytest tests/unit_tests -v

# Linting
ruff check .
ruff format .

# Type checking
mypy langchain_cloro

Release

The Publish workflow publishes the package to PyPI when a version tag is pushed. It uses PyPI Trusted Publishing, so you do not need a PyPI token.

  1. Increase version in pyproject.toml and commit the change.

  2. Tag the commit with the same version and push the commit and the tag. The workflow runs the unit tests, builds and publishes:

    git tag v0.3.2
    git push origin main v0.3.2
    

API Reference

For detailed API documentation, see https://cloro.dev/docs.

License

MIT

Metadata

Release files for langchain-cloro 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-cloro 0.5.0
File Size Uploaded Provenance Actions
langchain_cloro-0.5.0.tar.gz 11.7 kB Without provenance Details for langchain_cloro-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-cloro 0.5.0
File Interpreter ABI Platform Actions
langchain_cloro-0.5.0-py3-none-any.whl Python 3 none any Details for langchain_cloro-0.5.0-py3-none-any.whl

Total release size: 21.2 kB

Release files / langchain_cloro-0.5.0.tar.gz

Download URL langchain_cloro-0.5.0.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
03c9a359f54f85be9e8a21e48db7268f712550f0f9425832b11a5aafcc9d3ddd
BLAKE2b-256 checksum
How to use checksums
a02ce1c1d75b6428cbb32efecbed1647f019f701499a28f735404928dea151df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / langchain_cloro-0.5.0-py3-none-any.whl

Download URL langchain_cloro-0.5.0-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c73e950e9901aca540c013ba340f2aea6c7ad58481332e7e351e7cb6e2601844
BLAKE2b-256 checksum
How to use checksums
b3e723085d7c43db935b53e9f26963954b38bdb1368a01538b40559f597f8390
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for langchain-cloro 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page