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

> ## Agent Instructions
> Every page is listed in https://docs.keenable.ai/llms.txt. To pick a product for a job, read https://docs.keenable.ai/choose.md
> Setup steps for agents, covering the SDKs, the MCP server and the CLI: https://docs.keenable.ai/skill.md
> Keenable search and fetch work without an API key. To add them to code, use the official SDK for the project's language: https://docs.keenable.ai/sdks.md
> Without a key, call POST https://api.keenable.ai/v1/search/public or GET https://api.keenable.ai/v1/fetch/public with an X-Keenable-Title header that names your app.
> With a key, send it in the X-API-Key header and read it from the KEENABLE_API_KEY environment variable. Never ask a user to paste a key into chat. Every access method: https://docs.keenable.ai/auth.md
> To get an API key without the console, use device login: https://docs.keenable.ai/authentication.md#device-login
> MCP server: https://api.keenable.ai/mcp (no key, or X-API-Key; keyless Codex uses https://api.keenable.ai/mcp-public), or https://api.keenable.ai/mcp-oauth for OAuth sign-in. These docs are an MCP server at https://docs.keenable.ai/mcp and the OpenAPI spec is at https://docs.keenable.ai/api-reference/openapi.json
> Keenable searches and fetches public web pages. If a question needs no web information, skip the call.
> On 402 with an API key (code insufficient_credits), stop and ask a human to add credits; don't retry. On 429, wait the number of seconds in Retry-After, then retry. Before you ship, follow https://docs.keenable.ai/production.md
> Every error, with its cause and fix, is in https://docs.keenable.ai/errors.md and moving from another search API is covered in https://docs.keenable.ai/migrate.md
> Before you compare Keenable with another search API, read https://docs.keenable.ai/guides/evaluate-search-apis.md

# AG2 web search toolkit

> Give AG2 agents web search and page fetch with KeenableSearchToolkit, built into AG2 1.2.2 and later, with no API key required.

*Toolkit in AG2*

`KeenableSearchToolkit` gives AG2 agents two tools: `keenable_search` for web search and `keenable_fetch` for reading a page as markdown. It ships in [AG2](https://github.com/ag2ai/ag2) itself and talks to the Keenable REST API over `httpx`, which AG2 already depends on, so there is no extra package. It runs without an API key.

→ [KeenableSearchToolkit in the AG2 repository](https://github.com/ag2ai/ag2/blob/main/ag2/extensions/tools/search/keenable.py) · [AG2's Keenable Search page](https://docs.ag2.ai/docs/user-guide/extensions/tools/search/keenable/)

## Install

`KeenableSearchToolkit` ships in AG2 1.2.2 and later. Install AG2 with the extra for your model provider. The example uses OpenAI:

```bash theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
pip install -U "ag2[openai]>=1.2.2"
```

Current AG2 releases need Python 3.11 or later. Set `OPENAI_API_KEY` for the model, or pass another provider's config to `Agent(config=...)`.

## Give it to an agent

Add `KeenableSearchToolkit()` to the agent's tools. It registers both `keenable_search` and `keenable_fetch`:

```python theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
import asyncio

from ag2 import Agent
from ag2.config import OpenAICompletionsConfig
from ag2.extensions.tools.search import KeenableSearchToolkit

agent = Agent(
    "researcher",
    prompt="Answer with the URLs of the pages you used.",
    config=OpenAICompletionsConfig(model="gpt-4o-mini"),
    tools=[KeenableSearchToolkit()],
)


async def main() -> None:
    reply = await agent.ask("What changed in the latest Python release?")
    print(reply.body)


asyncio.run(main())
```

The reply cites the pages the agent found. Each `keenable_search` result has `title`, `url`, `snippet` and `acquired_at`, the time Keenable last indexed the page. `keenable_fetch` returns the page's `url`, `title`, `content` as markdown, `author` and `published_at`. The last two are empty when unknown.

## Give it search only

Each tool is a factory method on the toolkit. Pass only `toolkit.search()` to keep the agent to one site and a set number of results:

```python theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
toolkit = KeenableSearchToolkit()

agent = Agent(
    "researcher",
    config=OpenAICompletionsConfig(model="gpt-4o-mini"),
    tools=[toolkit.search(site="docs.python.org", max_results=10)],
)
```

`toolkit.fetch()` returns the fetch tool on its own. Both methods also take `name` and `description` to rename the registered tool.

## Options

| Parameter | Default | What it does |
| - | - | - |
| `api_key` | `None` | Keenable API key, sent as `X-API-Key`. If unset, the toolkit reads `KEENABLE_API_KEY` at call time. If neither is set, it calls the keyless `/v1/search/public` and `/v1/fetch/public` endpoints. |
| `max_results` | API default, `10` | Number of search results, from 1 to 50. |
| `site` | `None` | Domain to restrict search results to, such as `"docs.python.org"`. |
| `published_after` | `None` | Only pages published on or after this date, as `YYYY-MM-DD`. |
| `snippet_max_length` | `1000` | Approximate characters of page text per result. Use `keenable_fetch` to read a whole page. |
| `base_url` | `"https://api.keenable.ai"` | API root, for routing through your own gateway. |
| `timeout` | `60.0` | Request timeout in seconds. |
| `proxy` | `None` | Proxy URL for the outgoing connection. |
| `verify` | `True` | Verify the server's TLS certificate. |

If Keenable returns an error, the tool raises `httpx.HTTPStatusError` with Keenable's error message. On `429`, the message includes the `Retry-After` value. See [Errors](https://docs.keenable.ai/errors.md).

> [!NOTE]
>
> Without a key, calls run on the shared public tier at [lower rate limits](https://docs.keenable.ai/rate-limits.md). Set `KEENABLE_API_KEY`, or pass `KeenableSearchToolkit(api_key=...)`, to use your organization's limits and remove the hourly cap. See [API keys](https://docs.keenable.ai/api-keys.md).

## Related pages

> [card] [Composio](https://docs.keenable.ai/integrations/composio.md)
>
> Keenable as a Composio toolkit: your agent searches the web and reads pages through Composio, next to the other apps it uses there.

> [card] [Agno](https://docs.keenable.ai/integrations/agno.md)
>
> Give Agno agents web search and page reading with KeenableTools, a toolkit built into Agno, with no API key required.

> [card] [CrewAI](https://docs.keenable.ai/integrations/crewai.md)
>
> Give CrewAI agents Keenable web search with the official SDK. Keyless by default.

> [card] [Overview](https://docs.keenable.ai/sdks.md)
>
> Install the official Keenable SDK for Python, TypeScript, Go or Rust with one command, search with no key, then add fetch, tool calling and Monitors.


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