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

# RAG with fresh web results: retrieve, cite and answer

> Retrieve pages published in the last 30 days, render them as numbered sources and prompt your model to answer with citations. Runs with no API key.

Answer questions about things that happened after your model's training cutoff. Your code searches only pages published in the last 30 days, turns the top results into a numbered source block, and asks your model to answer from those sources and cite them as `[n]`.

## Recipe prompt

Paste this into your coding agent to have it build the recipe in your project:

```text Recipe prompt theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
Read https://docs.keenable.ai/recipes/rag-with-fresh-web-results.md and add this recipe to my project with the official Keenable SDK for the project's language. Keep published_after at 30d and the 4,000-character context budget, send the prompt to the model this project already uses, and print the cited sources under the answer. Read KEENABLE_API_KEY from the environment if it is set. Run it once with a question about this week's news and show me the answer and its sources.
```

## What you build

| Step | What it does | Setting |
| - | - | - |
| Retrieve | Searches the web for the question, keeping only recent pages | `published_after: "30d"`, `max_results: 5` |
| Augment | Renders the results as `[n] Title (url)` blocks that fit a budget | `to_context(max_chars=4000)` |
| Generate | Your model answers from the block and cites `[n]` | Any chat model |
| Cite | Lists the URLs in the same order as the numbers | `cited(max_chars=4000)` |

## When it runs

Once per question, on demand. Use it when the answer depends on something recent, such as a release, a price or an announcement. For a question about stable facts, drop `published_after` so older reference pages can rank.

## Code

This sample searches for pages published in the last 30 days, builds the prompt and prints it with the source list. It runs with no API key:

```typescript TypeScript theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
import { Keenable } from "keenable";

async function main() {
  const client = new Keenable(); // keyless: no API key needed to try it
  const question = "What changed in the latest stable Rust release?";

  // Retrieve: only pages published in the last 30 days
  const results = await client.search(question, {
    publishedAfter: "30d",
    maxResults: 5,
    snippetMaxLength: 800,
  });

  // Augment: a numbered source block that fits a 4,000-character budget
  const context = results.toContext({ maxChars: 4000 });
  const prompt =
    "Answer the question using only the sources below, and cite each claim as [n]. " +
    "If the sources don't answer it, say so.\n\n" +
    `Sources:\n${context}\n\nQuestion: ${question}`;
  console.log(prompt); // Generate: send this prompt to your model

  console.log("\nSources:");
  results.cited({ maxChars: 4000 }).forEach((result, i) => {
    console.log(`[${i + 1}] ${(result.publishedAt ?? "no date").slice(0, 10)} ${result.url}`);
  });
}

main();
```

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

client = Keenable()  # keyless: no API key needed to try it
question = "What changed in the latest stable Rust release?"

# Retrieve: only pages published in the last 30 days
results = client.search(question, published_after="30d", max_results=5, snippet_max_length=800)

# Augment: a numbered source block that fits a 4,000-character budget
context = results.to_context(max_chars=4000)
prompt = (
    "Answer the question using only the sources below, and cite each claim as [n]. "
    "If the sources don't answer it, say so.\n\n"
    f"Sources:\n{context}\n\nQuestion: {question}"
)
print(prompt)  # Generate: send this prompt to your model

print("\nSources:")
for number, result in enumerate(results.cited(max_chars=4000), start=1):
    print(f"[{number}] {(result.published_at or 'no date')[:10]} {result.url}")
```

```go Go theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
package main

import (
	"context"
	"fmt"
	"log"

	"github.com/keenableai/keenable-sdk/go"
)

func main() {
	client, err := keenable.New(nil) // keyless: no API key needed to try it
	if err != nil {
		log.Fatal(err)
	}
	defer client.Close()

	question := "What changed in the latest stable Rust release?"

	// Retrieve: only pages published in the last 30 days
	snippetCap := 800
	results, err := client.Search(context.Background(), question, &keenable.SearchOptions{
		PublishedAfter:   "30d",
		MaxResults:       5,
		SnippetMaxLength: &snippetCap,
	})
	if err != nil {
		log.Fatal(err)
	}

	// Augment: a numbered source block that fits a 4,000-character budget
	opts := &keenable.ContextOptions{MaxChars: 4000}
	prompt := "Answer the question using only the sources below, and cite each claim as [n]. " +
		"If the sources don't answer it, say so.\n\n" +
		"Sources:\n" + results.ToContext(opts) + "\n\nQuestion: " + question
	fmt.Println(prompt) // Generate: send this prompt to your model

	fmt.Println("\nSources:")
	for i, result := range results.Cited(opts) {
		date := "no date"
		if result.PublishedAt != nil {
			date = (*result.PublishedAt)[:10]
		}
		fmt.Printf("[%d] %s %s\n", i+1, date, result.URL)
	}
}
```

```rust Rust theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
use keenable::{Client, ContextOptions, SearchOptions};

#[tokio::main]
async fn main() -> Result<(), keenable::Error> {
    let client = Client::new()?; // keyless: no API key needed to try it
    let question = "What changed in the latest stable Rust release?";

    // Retrieve: only pages published in the last 30 days
    let results = client
        .search_with(
            question,
            &SearchOptions {
                published_after: Some("30d".into()),
                max_results: Some(5),
                snippet_max_length: Some(800),
                ..Default::default()
            },
        )
        .await?;

    // Augment: a numbered source block that fits a 4,000-character budget
    let opts = ContextOptions {
        max_chars: 4000,
        ..Default::default()
    };
    let prompt = format!(
        "Answer the question using only the sources below, and cite each claim as [n]. \
         If the sources don't answer it, say so.\n\n\
         Sources:\n{}\n\nQuestion: {}",
        results.to_context_with(&opts),
        question
    );
    println!("{}", prompt); // Generate: send this prompt to your model

    println!("\nSources:");
    for (i, result) in results.cited_with(&opts).iter().enumerate() {
        let date = result
            .published_at
            .as_deref()
            .and_then(|d| d.get(..10))
            .unwrap_or("no date");
        println!("[{}] {} {}", i + 1, date, result.url);
    }
    Ok(())
}
```

```bash curl theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
# Retrieve pages published in the last 30 days, numbered for citation
curl -s -X POST https://api.keenable.ai/v1/search/public \
  -H "Content-Type: application/json" \
  -H "X-Keenable-Title: My App" \
  -d '{
    "query": "What changed in the latest stable Rust release?",
    "published_after": "30d",
    "max_results": 5,
    "snippet_max_length": 800
  }' | jq -r '.results | to_entries[] | "[\(.key + 1)] \(.value.title) (\(.value.url)) - published \(.value.published_at // "no date")\n\(.value.snippet)\n"'
```

Send the printed prompt to your model. `to_context()` and `cited()` take the same options, so `[2]` in the answer always maps to the second URL in the source list. The curl tab numbers the raw results with `jq`, because HTTP returns JSON with no rendered block.

## Example output

You see the prompt, then one line per source with its publish date:

```text Example output · results vary theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
Answer the question using only the sources below, and cite each claim as [n]. If the sources don't answer it, say so.

Sources:
[1] Rust Language: "Rust 1.100.0 has been released…" (https://social.rust-lang.org/@rust/117605013073050966) - published 2026-11-12T19:01:27Z
Rust 1.100.0 has been released! …

…

Question: What changed in the latest stable Rust release?

Sources:
[1] 2026-11-12 https://social.rust-lang.org/@rust/117605013073050966
[2] 2026-11-12 https://version.rs/v/1.100.0
[3] 2026-11-16 https://heise.de/en/news/Rust-1-100-stabilizes-Never-Type-after-10-years-Cargo-holds-new-releases-11526687.html
[4] 2026-11-15 https://dev.to/aheadkit/rust-1100-is-out-i-installed-it-this-morning-and-tried-the-three-things-that-actually-matter-ff6
[5] 2026-11-18 https://byteiota.com/rust-1-100-never-type
```

## Production notes

| Situation | What happens | What to do |
| - | - | - |
| No API key | 1,000 requests per hour and 10 per second per IP address, shared with other traffic from that address | Set `KEENABLE_API_KEY`. Your organization gets 10 requests per second and no hourly cap. See [Rate limits](https://docs.keenable.ai/rate-limits.md). |
| `429` | You went over a rate limit. The response carries `Retry-After`. | Wait that many seconds, then retry. See [429 Rate limit exceeded](https://docs.keenable.ai/errors.md#429). |
| `402` with an API key | Your organization used its allowance and prepaid balance. The code is `insufficient_credits`. | Stop and top up in the console. Retrying returns `402` again. See [402 Out of funds](https://docs.keenable.ai/errors.md#402). |
| No results | Nothing in the window matched the query. | Widen `published_after`, for example to `90d`, or drop it. |
| Pages without a publish date | A date filter drops them. | Leave the filter off when undated pages, such as docs, should count. |

`published_after` takes a date, an ISO 8601 timestamp or a relative offset such as `7d`. Don't use `query_time` for recency: it sets an upper bound and leaves newer pages out. See [Search parameters](https://docs.keenable.ai/products/search.md#key-parameters).

## Next steps

* [Fact-check with citations](https://docs.keenable.ai/recipes/fact-check-with-citations.md): check each claim in an answer against the pages that discuss it.
* [Research loop](https://docs.keenable.ai/recipes/research-loop.md): split a broad question into several searches before you answer.
* [Tool calling](https://docs.keenable.ai/tool-calling.md#ground-an-answer-without-tool-calling): let the model decide when to search instead.
* [Recipes](https://docs.keenable.ai/recipes.md): every recipe on one page.


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