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

# Keenable SDK with Cerebras inference

> Ground Cerebras Inference models in live web results with the Keenable SDK: one search for cited answers, or tool calling with TOOLS, in Python and Node.

*Keenable SDK with Cerebras*

Ground answers from [Cerebras Inference](https://inference-docs.cerebras.ai) models in current web pages with the Keenable SDK. Each search result already carries the page text, so a cited answer takes one search and one chat completion. For agents that decide when to search, the SDK ships OpenAI-compatible tool definitions that go straight into a Cerebras request.

→ [Cerebras examples in the Keenable SDK repository](https://github.com/keenableai/keenable-sdk/tree/main/examples/cerebras)

## Install

Install the Keenable SDK and the Cerebras SDK, then set your Cerebras key:

```bash Python theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
pip install keenable cerebras_cloud_sdk
export CEREBRAS_API_KEY="your-cerebras-key"
```

```bash Node.js theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
npm install keenable @cerebras/cerebras_cloud_sdk
export CEREBRAS_API_KEY="your-cerebras-key"
```

The Keenable SDK runs without a key. To use your organization's limits, also export `KEENABLE_API_KEY`: the SDK reads it from the environment. See [API keys](https://docs.keenable.ai/api-keys.md).

## Answer from search results

Search once, render the results as a numbered context block with `to_context()`, and ask the model to cite by number:

```python Python theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
from cerebras.cloud.sdk import Cerebras
from keenable import Keenable

question = "What did Cerebras announce most recently, and when?"

keenable = Keenable()
cerebras = Cerebras()

results = keenable.search(question, published_after="2026-01-01")

completion = cerebras.chat.completions.create(
    model="gpt-oss-120b",
    messages=[
        {"role": "system", "content": "Answer using only the sources provided. Cite them by number, like [1]."},
        {"role": "user", "content": f"{results.to_context()}\n\nQuestion: {question}"},
    ],
)

print(completion.choices[0].message.content)
for index, result in enumerate(results.cited(), start=1):
    print(f"[{index}] {result.title} - {result.url}")
```

```javascript Node.js theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
import Cerebras from '@cerebras/cerebras_cloud_sdk';
import { Keenable } from 'keenable';

const question = 'What did Cerebras announce most recently, and when?';

const keenable = new Keenable();
const cerebras = new Cerebras();

const results = await keenable.search(question, { publishedAfter: '2026-01-01' });

const completion = await cerebras.chat.completions.create({
  model: 'gpt-oss-120b',
  messages: [
    { role: 'system', content: 'Answer using only the sources provided. Cite them by number, like [1].' },
    { role: 'user', content: `${results.toContext()}\n\nQuestion: ${question}` },
  ],
});

console.log(completion.choices[0].message.content);
results.cited().forEach((result, index) => {
  console.log(`[${index + 1}] ${result.title} - ${result.url}`);
});
```

The answer cites sources as `[1]`, `[2]` and so on. `cited()` lists the results that made it into the context, in the same numbering, so the source list matches the citations. A result that did not fit the context's character budget is not listed.

## Let the model search

`TOOLS` holds definitions for `keenable_search` and `keenable_fetch`. `run_tool_call` runs the tool the model picked and returns text to hand back:

```python theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
from cerebras.cloud.sdk import Cerebras
from keenable import TOOLS, Keenable, KeenableError, run_tool_call

keenable = Keenable()
cerebras = Cerebras()

messages = [
    {"role": "system", "content": "Use the web tools when the answer depends on recent information, and cite the URLs you used."},
    {"role": "user", "content": "What did Cerebras announce most recently, and when?"},
]

while True:
    completion = cerebras.chat.completions.create(model="gpt-oss-120b", messages=messages, tools=TOOLS)
    message = completion.choices[0].message
    if not getattr(message, "tool_calls", None):
        print(message.content)
        break

    messages.append(message.model_dump())
    for call in message.tool_calls:
        try:
            output = run_tool_call(keenable, call.function.name, call.function.arguments)
        except KeenableError as exc:
            output = f"Tool call failed: {exc}"
        messages.append({"role": "tool", "tool_call_id": call.id, "content": output})
```

The loop ends when the model answers without calling a tool. A failed call goes back to the model as the tool result, so it can try another source. The Node SDK exports the same `TOOLS` and a `runToolCall` function. See the [Node example](https://github.com/keenableai/keenable-sdk/blob/main/examples/cerebras/tool_calling.mjs).

## SDK pieces used

| Python | Node.js | What it does |
| - | - | - |
| `keenable.search(q, published_after=...)` | `keenable.search(q, { publishedAfter })` | Web search. Each result includes page text in `snippet`. |
| `results.to_context()` | `results.toContext()` | Renders results as a numbered block for a prompt. |
| `results.cited()` | `results.cited()` | The results that fit in the context, in citation order. |
| `TOOLS` | `TOOLS` | Tool definitions for `keenable_search` and `keenable_fetch`. |
| `run_tool_call(client, name, args)` | `runToolCall(client, name, args)` | Runs one tool call and returns its text output. |

See the [Python](https://github.com/keenableai/keenable-sdk/tree/main/python) and [TypeScript](https://github.com/keenableai/keenable-sdk/tree/main/typescript) SDK READMEs for every search filter.

> [!NOTE]
>
> Without `KEENABLE_API_KEY`, searches run on the shared public tier at [lower rate limits](https://docs.keenable.ai/rate-limits.md). Set the key to use your organization's limits and remove the hourly cap.

## Related pages

> [card] [OmniRoute](https://docs.keenable.ai/integrations/omniroute.md)
>
> Route web search and page fetch through Keenable in the OmniRoute AI gateway with provider keenable-search. No key needed, in OmniRoute 3.8.54 and later.

> [card] [OpenRouter](https://docs.keenable.ai/integrations/openrouter.md)
>
> Web search and page fetch for any OpenRouter model, as tools it calls itself: from Python, the AI SDK, or the Agent SDK over MCP. No Keenable key needed.

> [card] [Baseten](https://docs.keenable.ai/integrations/baseten.md)
>
> Keenable web search and page fetch as server-side tools on Baseten Model APIs, called by the model inside the inference loop.

> [card] [Tool calling](https://docs.keenable.ai/tool-calling.md)
>
> Give an LLM web search and page fetch as tools. Pass the SDK's TOOLS to any OpenAI-compatible chat completions client and run each call with run\_tool\_call.


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