翻篇收录说明
翻篇网页快照

Keenable SDKs for Python, TypeScript, Go and Rust - Keenable

https://docs.keenable.ai/sdks

最近抓取:2026-12-03 23:19:42(北京时间)

最近内容变化:2026-12-03 23:19:42(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

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.

正文摘录

The official SDKs give your code web search, page fetch and Monitors in Python, TypeScript, Go and Rust. Search results come back ready to paste into a prompt. Each language has its own page with install, authentication, search, fetch, Monitors, webhook verification and error classes: TypeScript, Python, Go and Rust. What you get search returns ranked pages with their text extracted. fetch takes a list of up to 20 URLs and returns each page as markdown, in the same order. to_context() renders results as numbered [n] Title (url) sources a model can cite. TOOLS holds OpenAI-format definitions for keenable_search and keenable_fetch. A helper runs whichever tool the model calls. See Tool calling, with complete loops for Anthropic, OpenAI, Gemini, Mistral and Ollama or vLLM. In Python, AsyncKeenable has the same methods as the sync client. See Async. The Rust client is async and runs on Tokio. Search and fetch work with no account and no key. Monitors needs an API key. A key also raises your rate limit, and lets one fetch read 20 URLs instead of 10. Install Install the package for your language: TypeScriptPythonGoRustnpm install keenable The SDKs need Python 3.9, Node 18, Go 1.22 or Rust 1.85, or newer. The TypeScript SDK has no runtime dependencies. Keenable has no official SDK for other languages, such as Java, Ruby, PHP or C#. From those languages, call the HTTP API. See the API reference. On macOS and many Linux distributions, system Python refuses a global pip install. If it does, install the package into a virtual environment: run python3 -m venv .venv, then source .venv/bin/activate. In an empty folder, run go mod init example.com/demo before go get. The Rust samples also need an async runtime: cargo add tokio --features macros,rt-multi-thread. Versions These pages describe the SDKs as they are in the SDK repository. A package registry can hold an older release, and the install commands above take the latest one there. This table shows both versions for each language, and the command that prints the version you have: LanguagePackageLatest releaseSDK repositoryCheck your versionTypeScriptnpm0.5.00.5.0npm ls keenablePythonPyPI0.5.00.5.0pip show keenableGopkg.go.dev0.5.00.5.0go list -m github.com/keenableai/keenable-sdk/goRustcrates.io0.5.00.5.0cargo tree -p keenable --depth 0 Release versions checked on 2026-11-27. On an older release, a method marked “Needs SDK” doesn’t exist, so the call fails. An option marked that way behaves differently in each language. Python raises a TypeError on the unknown keyword argument. In TypeScript it’s a type error, but the npm package ignores an option it doesn’t know, so plain JavaScript, or code TypeScript doesn’t check, runs the call without it and raises no error. A search then comes back without the filter, and a fetch without the option. Until a newer release is out, call the API over HTTP for it. To check a webhook signature without the SDK, follow Verify a webhook. Run a keyless search This program runs one search without a key and prints the top 3 results as a citable block: TypeScriptPythonGoRustcurlimport { Keenable } from "keenable"; async function main() { const client = new Keenable(); // keyless: no API key needed to try it const results = await client.search("fastest inference providers 2026", { maxResults: 3 }); console.log(results.toContext()); } main(); Save it in the directory where you installed the SDK and run it. In a new TypeScript project, npx tsx index.ts works as is: npx downloads tsx the first time, so you don’t install it. To run the file with plain node, name it index.mjs or add "type": "module" to package.json, because the program uses a top-level import. LanguageSave asRunTypeScriptindex.tsnpx tsx index.tsPythonmain.pypython main.pyGomain.gogo run .Rustsrc/main.rscargo runcurlPaste the command into a terminal. You see one [n] Title (url) header per result, followed by the page text: Example output · results vary[1] Hugging Face Inference Providers · Supported Models (https://huggingface.co/inference) … [2] Fastest LLM Inference Provider 2026: TTFT, tok/s, p99 (https://openbenchmarks.com/inference/fastest-inference-provider) - published 2026-09-03T00:00:00Z Baseten recorded the lowest end-to-end p99 latency at 3.23 seconds on this run, with a median of 331 ms… [3] Best LLM Inference Providers Compared for 2026 - SiliconFlow (https://siliconflow.com/articles/the-best-inference-provider-for-llms) … Each result has title, url and snippet, the page text extracted for the query, which is the field to put in a prompt. It also has published_at (publishedAt in TypeScript, PublishedAt in Go) and acquired_at, each an ISO 8601 UTC timestamp when the API has one. Results come back ranked, most relevant first. description is always empty and is deprecated, so read snippet. To raise your limit, create an API key and set KEENABLE_API_KEY. The code stays the same. Search with an API key, several at once This program creates one client with your API key, runs 4 searches with at most 2 in flight, and prints each query’s result count and top URL. It stops before any request when KEENABLE_API_KEY isn’t set: TypeScriptPythonGoRustcurlimport { Keenable } from "keenable"; const QUERIES = [ "official Postgres documentation on logical replication slots", "release notes for the latest PostgreSQL major version", "guide to monitoring Postgres replication lag", "Postgres documentation on the max_slot_wal_keep_size setting", ]; const IN_FLIGHT = 2; // at most 2 calls in flight at once async function main() { const apiKey = process.env.KEENABLE_API_KEY; if (!apiKey) throw new Error("Set KEENABLE_API_KEY"); // One client for every call: it reuses its connections. const client = new Keenable({ apiKey }); const lines: string[] = new Array(QUERIES.length); let next = 0; async function worker() { while (next < QUERIES.length) { const i = next++; const results = await client.search(QUERIES[i], { maxResults: 3 }); lines[i] = `${results.length} results, top: ${results.results[0]?.url ?? "-"}`; } } await Promise.all(Array.from({ length: IN_FLIGHT }, worker)); QUERIES.forEach((query, i) => console.log(`${query.slice(0, 40).padEnd(40)} ${lines[i]}`)); } main(); You see one line per query, in the order of the list, whichever search finished first. The curl tab prints each line as its search finishes, so the order can change. A search that fails prints curl’s error on stderr instead of its line, the other searches still run, and the command exits non-zero. Two habits keep a parallel run fast and inside your rate limit: Create one client and share it. Every call on a client reuses its connections. In Go, call Close when you’re done. In Python, async with closes the client. In Rust, a clone() of the client shares its connection pool, so clone it into each task. Cap the calls in flight. No SDK limits how many calls run at once, and starting hundreds at once with asyncio.gather or Promise.all turns most of them into 429s. Each SDK retries a 429 after Retry-After, up to 2 times by default. LanguageCap calls in flight withPythonAsyncKeenable and an asyncio.SemaphoreTypeScriptA fixed number of worker loops under one Promise.allGoA buffered channel as a semaphore, with a sync.WaitGroupRustA tokio::task::JoinSet that waits for one search to finish before it starts another With an API key, searches and fetches share your organization’s limit of 10 requests per second by default. A cap of calls in flight isn’t a cap per second: fast calls can still pass it, and the SDK’s retries then slow the run down. High-volume research covers sizing the cap, the 429 you still get after the retries, and grouping a run with a session ID. What the SDKs don’t cover Time Machine (/v1/time-machine/search, /fetch and /versions) has no method in any SDK. Call it over HTTP, as its page shows with curl. The SDKs’ query_time search filter is a normal search, not a Time Machine call. Configuration Every SDK reads two environment variables: VariableDefaultPurposeKEENABLE_API_KEYunsetYour API key. Unset means keyless.KEENABLE_API_URLhttps://api.keenable.aiThe API base URL. You can also pass settings to the constructor: SettingPythonTypeScriptGo (keenable.Options)Rust (keenable::Options)API keyapi_keyapiKeyAPIKey (pointer)api_keyBase URLbase_urlbaseUrlBaseURL (pointer)base_urlTimeouttimeout, in seconds (default 30)timeoutMs (default 30000)Timeout (default 30s)timeout, a Duration (default 30s)Client sourceclient_sourceclientSourceClientSourceclient_sourceYour own HTTP client, for a proxy or custom transportclient (an httpx.Client)fetchHTTPClient (an *http.Client)http_client (a reqwest::ClientBuilder) The SDK sends the client source as the X-Keenable-Title header. It defaults to Keenable SDK. If you build an integration on top of an SDK, set it to your product’s name, so Keenable attributes the traffic to your product. Methods What it doesPythonTypeScriptGoRustSearch the websearch(query, **filters)search(query, options)Search(ctx, query, *SearchOptions)search(query), search_with(query, &SearchOptions)Fetch up to 20 pagesfetch(urls, **options)fetch(urls, options)Fetch(ctx, urls), FetchWithOptions(ctx, urls, *FetchOptions)fetch(urls), fetch_with(urls, &FetchOptions)Render a citable blockto_context()toContext()ToContext(nil)to_context()List the results a block citescited()cited()Cited(nil)cited()Tool definitionsTOOLSTOOLSToolstools()Run a tool callrun_tool_call (arun_tool_call for async)runToolCallRunToolCallrun_tool_callCheck who an API key belongs toidentity()identity()Identity(ctx, *RequestOptions)identity(), identity_with(&RequestOptions) Search takes the Search parameters, named in each language’s style: published_after in Python and Rust, publishedAfter in TypeScript, PublishedAfter in Go. In Rust they are fields on SearchOptions. The same pattern holds for every parameter: ParameterPython and RustTypeScriptGoWhat it doesExclude domainsexclude_domainsexcludeDomainsExcludeDomainsLeaves out these hosts.Objectiveobjectiveobject