Skip to main content Switch to mobile version keenable 0.5.0 Official Python SDK for the Keenable web search API, built for AI agents
pip install keenable==0.5.0 Copy PIP instructions
Official Python SDK for Keenable, a web search API built for AI agents: ranked results that come back with the page text already extracted, plus a fetch endpoint that returns any URL as clean markdown.
Keyless by default. Every call works with no account and no key. An optional KEENABLE_API_KEY only lifts the hourly rate limit.
pip install keenable Search
from keenable import Keenable keenable = Keenable() # or Keenable("keen_...") / set KEENABLE_API_KEY results = keenable.search("how wafer scale chips avoid the memory bottleneck") for result in results: print(result.title, result.url) print(result.snippet) Results carry the page text in snippet. (description is deprecated: the API no longer fills it, so it is always None. Build prompts from snippet.)
Filters are optional and combine freely:
results = keenable.search( "post-training quantization results", site="arxiv.org", published_after="2026-01-01", snippet_max_length=500, ) Argument What it does site Restrict to one domain, e.g. "arxiv.org" exclude_domains Never return results from these hosts or their subdomains; see below published_after / published_before Filter by publication date (YYYY-MM-DD) acquired_after / acquired_before Filter by when Keenable indexed the page snippet_max_length Cap the page text returned per result max_results How many results to return, 1 to 50 (default 10) query_time Search the index as it stood at that moment (YYYY-MM-DD, ISO 8601, or "7d"); not a recency filter objective What the search is for, in two or three sentences (up to 1,000 characters); the ranker scores results for it together with the query (retrieval reads only the query), same price. Not sent when empty mode Search mode: "pro" does deeper retrieval; "realtime" gives the fastest response, for latency-sensitive agent loops. None, the default, sends no mode, so your organization's default search mode applies: "pro" unless Keenable set another disable_cards True returns ordinary web pages in place of Keenable's cards (results Keenable writes for prices, exchange rates or company facts, whose URLs expire after one day). Default False, which is not sent; any other value raises KeenableInvalidRequestError. Works in "pro" and "realtime" modes; with mode unset, the organization's default mode must be "pro" or "realtime", so set mode explicitly to be sure. In the next release after 0.1.3 moderation Filter unsafe results: "moderate" or "strict". None, the default, is no moderation and is not sent. Works in "pro" and "realtime" modes, and not when the query is a URL (the API answers 400). With mode unset, the organization's default mode must be "pro" or "realtime"; set mode explicitly to be sure. session_id Your own ID for grouping related requests, such as one agent run's searches and fetches. Sent as the X-Keenable-Session-Id header, never in the body. Printable ASCII; surrounding spaces are dropped, and None or "" is unset. The API keeps the first 128 characters. To send it on every call, put the header in default_headers Excluding domains
exclude_domains drops results from the listed sites.
results = keenable.search( "how to repot a monstera without damaging the roots", exclude_domains=["pinterest.com", "quora.com"], ) Each entry is a host, such as "pinterest.com". A host excludes itself and every subdomain, so "yahoo.com" also drops finance.yahoo.com. Up to 1,000 distinct hosts. Hosts such as github.io and blogspot.com are accepted.
The API cleans up unambiguous input for you: surrounding whitespace, case, an http:// or https:// scheme, a leading www., a port, a trailing / or dot, a query string or #fragment; international names become punycode. So "https://WWW.Pinterest.com/" is read as "pinterest.com". Anything else is rejected with HTTP 400, raised as KeenableAPIError: a path ("example.com/blog"), a suffix or wildcard (".com", "*.example.com"), an IP address, a user@host, or an invalid host. The param, value and reason attributes name the rejected entry, and fix says what to change:
try: keenable.search("q", exclude_domains=["example.com/blog"]) except KeenableAPIError as err: if err.error == "invalid_filter": print(err.param, err.value, err.reason) # exclude_domains example.com/blog paths are not supported; give only the host, such as example.com else: print(err.body) value and reason are set only for that rejection (a 400 whose body has "error": "invalid_filter") and None on every other error. value is usually the entry as sent; a size cap reports the list's size ("2500 entries" or "more than 1000 distinct hosts") or an over-long entry's first 64 characters followed by "...".
If every match is excluded, the response can be empty. The SDK sends the list as given and leaves validation to the API; run_tool_call does the same with a model's exclude_domains argument. site still works for a single domain, and the keenable_search tool offers the model site and exclude_domains.
Ground a model in one line
to_context() renders the result set as a numbered, citable block you can drop straight into a prompt:
context = keenable.search("cerebras inference benchmarks").to_context() prompt = f"Answer using only these sources, citing them by number.\n\n{context}\n\nQuestion: ..." It emits [1] Title (url) headers followed by the page text. Each result's text is cleaned (images dropped, relative links resolved, markdown tables flattened to cell · cell; rows) and cut at a word boundary to max_snippet_chars (2000 by default, None for no cap; a value below 1 also disables the cap), ending in "…". Results are then added whole until the character budget is reached (max_chars=12000 by default), so a later source is dropped rather than cut off. The first result is kept even when it alone is over the budget.
To print a source list that matches the citations in the answer, ask which results were actually rendered rather than listing them all:
results = keenable.search("cerebras inference benchmarks") for index, result in enumerate(results.cited(), start=1): print(f"[{index}] {result.title} - {result.url}") Read full pages
response = keenable.fetch(["https://cerebras.ai/chip", "https://cerebras.ai/blog"]) for page in response.results: if page.error: print(page.url, page.error.code) continue print(page.title) print(page.content) # markdown, boilerplate stripped print(page.to_context()) # same citable block shape as search results fetch() sends one POST /v1/fetch. results[i] is for urls[i]; a URL that failed has error set instead of raising. Optional arguments, sent only when set (the API checks their values):
billing = keenable.billing() for price in billing.prices: print(price.sku, price.unit_price.amount, price.unit_price.currency) if billing.account: # None without an API key print("available:", billing.account.balance.available.amount) billing() reads GET /v1/billing: read-only and free, with or without a key. Without one, prices are the public list prices and account is None. With one, prices are your organization's (with list_unit_price and source, "list" or "contract"), and account holds the available balance and billing_url, the console page for adding funds. Amounts are numbers in US dollars (Money.amount, a float such as 0.004, up to nine decimal places, negative for an account in debt). Money.amount_decimal is the same amount as an exact decimal string ("0.004"); add amounts with it, not with the float, when they must match a bill:
from decimal import Decimal total = sum(Decimal(p.unit_price.amount_decimal) for p in billing.prices) Key identity
me = keenable.identity() print(me.org_id, me.org_name, me.email) identity() reads GET /v1/auth/user: who the API key belongs to. org_id is the organization whose balance and rate limit the key uses, user_id the user who created the key; email, display_name and org_name are None when the API doesn't have them. It is read-only and free, and it needs an API key: without one it raises KeenableAuthError (code missing_api_key) without sending anything. A key the API does not accept raises KeenableAuthError too, so it is a cheap way to check a key.
The SDK ships OpenAI-compatible tool definitions, so any inference API that speaks that schema can call Keenable directly:
from keenable import Keenable, TOOLS, run_tool_call keenable = Keenable() response = client.chat.completions.create(model=..., messages=messages, tools=TOOLS) for call in response.choices[0].message.tool_calls or []: messages.append( { "role": "tool", "tool_call_id": call.id, "content": run_tool_call( keenable, call.function.name, call.function.arguments ), } ) TOOLS exposes keenable_search and keenable_fetch; run_tool_call executes whichever the model picked and returns text ready for the tool message. Both tools render the same numbered, citable block, so the model can cite a fetched page the way it cites a search result. arun_tool_call is the async counterpart, for use with AsyncKeenable.
The model may set site, exclude_domains, published_after, objective, disable_cards and moderation on search. The other filters stay on search() for you to set yourself.
On fetch the model sets urls (1 to 20) and may set max_chars (per page), prompt (applied to every page) and max_age_hours (0 reads every page live, -1 only the stored copy), as on the hosted MCP tool. A call without urls is an invalid request. Each page comes back as its own numbered block. A URL that failed while others were read becomes a [n]
AsyncKeenable mirrors the sync client:
import asyncio from keenable import AsyncKeenable async def main(): async with AsyncKeenable() as keenable: results = await keenable.search("wafer scale engine") print(results.to_context()) asyncio.run(main()) Monitors
A search monitor is a standing search: it watches the web for a topic and hands over every new result that matches, by webhook, in scheduled runs, or when you poll it. A page monitor (type="page") reads one page on a schedule and reports the changes worth telling. Monitors need an API key (KEENABLE_API_KEY); without one, every call raises KeenableAuthError with code == "missing_api_key" and sends nothing. An organization can have 100 active monitors.
pricing = keenable.monitors.create( type="page", page={ "url": "https://example.com/pricing", "watch_for": "plan prices and new plans", "sensitivity": "meaningful", # or "any": every change that is not cosmetic }, schedule={"type": "interval", "value": "6h"}, ) for run in keenable.monitors.runs(pricing.id): if run.changes and run.changes.notified: print(run.changes.summary, run.changes.items) for version in keenable.monitors.versions(pricing.id): print(version.version, version.fetched_at, version.diff and version.diff.added) Schedules: cron (runs at least 10 minutes apart, in timezone), interval ("10m" to "90d") or once. Without one, a search monitor runs only on trigger() and a page monitor every hour. The API checks the schedule and the output_schema: one that breaks a rule raises KeenableAPIError with status 400, code == "invalid_request" and a message that names the rule.
AsyncKeenable().monitors has the same methods, awaitable (list_all is an async iterator). Every call also takes timeout, max_retries and extra_headers. Reads and deletes are retried like a search; create() sends an Idempotency-Key (yours, or a new one per call), so its retries cannot make a second monitor; update(), trigger() and bulk() are retried only on a 429.
A Monitor has type ("search" or "page"), search (None for a page monitor), page (None for a search monitor), disabled_reason (code runs_failed, webhook_unreachable or data_policy (a page monitor whose organization turned on zero data retention), while it is disabled). A completed MonitorRun has, for a page monitor, changes (changed, notified, baseline, version, source, summary, items, diff). With an output_schema, output has structured, fresh and error.
Deliveries are signed as Standard Webhooks. Verify the raw body before trusting it:
from keenable import WebhookVerificationError, verify_webhook try: event = verify_webhook(raw_body, request.headers, secret) except WebhookVerificationError: ... # answer 400 if event.type == "monitor.result.found": print(event.data.result.url) elif event.type == "monitor.page.changed": # a page monitor's change worth telling print(event.data.run.changes.summary) verify_webhook checks the HMAC-SHA256 signature in constant time and refuses a timestamp more than 5 minutes from now (tolerance= changes it). Drop repeats by event.id, which stays the same across retries.
All errors subclass KeenableError:
The SDK already retries what can be retried (see Retries and timeouts), so an error that reaches you is final for this call. Every KeenableAPIError carries what the API says about the failure. Branch on code, not on the message. Each field is None when the API did not send it.
Retries and timeouts
Failed requests are retried twice by default. Connection errors, timeouts, 408, 429 and 5xx are retried, unless the API marks the error retryable: false (credits, bad parameters and blocked pages never are). The SDK waits the API's Retry-After when it sent one, else backs off exponentially from 0.5 s to 8 s with jitter. A Retry-After over 60 s, such as the keyless hourly cap, is not waited out: the error is raised at once so your code decides.
timeout (default 30 s) is the deadline for each attempt as a whole, from connecting to the end of the answer, headers included: a server that keeps sending a few bytes at a time still times out on schedule. A timed-out request raises KeenableTimeoutError, a subclass of KeenableConnectionError, and its connection is closed, so nothing keeps running after it. Pass an httpx.Timeout instead of a number to set httpx's per-phase timeouts (connect, read, write, pool) with no overall deadline.
The overall deadline needs the HTTP client the SDK creates. With your own client=httpx.Client(...), a numeric timeout keeps httpx's per-phase meaning: each connect and each read gets the timeout, and a server that keeps trickling bytes is not cut off. AsyncKeenable enforces the deadline either way.
keenable = Keenable(max_retries=4, timeout=10, default_headers={"X-Team": "search"}) keenable.search("wafer scale engine", max_retries=0) # no retries for this call keenable.fetch(["https://example.com"], timeout=60, extra_headers={"X-Trace": "abc"}) Every call takes timeout, max_retries and extra_headers, which override the client's settings for that call. Results carry request_id (quote it when reporting a problem). A search response's warnings lists what the request should change, such as a deprecated parameter it used; it is empty otherwise. Redirects are never followed, so the API key cannot leak to another host.
Both can also be passed to the constructor as api_key and base_url, alongside timeout, max_retries, default_headers, client (your own httpx.Client, e.g. for a proxy) and client_source. Building an integration on top of this SDK? Set client_source="Your Integration" so your traffic is attributed to you rather than to the bare SDK.
Released: Dec 1, 2026
Both files in this release have provenance metadata.
View provenance details
MIT View SPDX License List
agents grounding keenable llm rag search web-search
Development Status 4 - Beta
Intended Audience Developers
License OSI Approved :: MIT License
Programming Language Python :: 3
Topic Scientific/Engineering :: Artificial Intelligence
Release files for keenable 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
Built distribution (wheel)
Total release size: 212.3 kB
Release files / keenable-0.5.0.tar.gz
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Release files / keenable-0.5.0-py3-none-any.whl
Security for keenable 0.5.0
Both files in this release have been uploaded with provenance metadata.
With provenance keenable-0.5.0.tar.gz Dec 1, 2026
With provenance keenable-0.5.0-py3-none-any.whl Dec 1, 2026
Attestation for keenable-0.5.0.tar.gz
Attestation for keenable-0.5.0-py3-none-any.whl
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.
Release history Release notifications | RSS feed
Dec 1, 2026 2 release files Full provenance
Nov 23, 2026 2 release files Full provenance
Nov 19, 2026 2 release files Full provenance
Nov 13, 2026 2 release files Full provenance
Nov 2, 2026 2 release files Full provenance
Oct 29, 2026 2 release files Full provenance
Aug 15, 2026 2 release files Full provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation
Deployed from a8e35ed











