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

# Fact-check a claim with cited web sources

> Check a claim against the pages that discuss it: search, then fetch each page with a prompt that returns a verdict and the quoted sentence, per URL.

Check one claim against the pages that discuss it, and get back a verdict and a quoted sentence for each URL. Your code searches for the claim, then fetches each top result with a `prompt`. An LLM reads the page and returns only whether the page supports, contradicts or doesn't mention the claim, with the sentence that decides it.

## 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/fact-check-with-citations.md and add a fact-check function to this project with the official Keenable SDK for the project's language. It takes one claim, searches with max_results=3, fetches each result with the verdict prompt and max_chars=600, and returns a list of (url, verdict, quote). Read KEENABLE_API_KEY from the environment if it is set. Run it on one claim from this project's data and show me the result.
```

## What you build

| Step | Call | Setting | What you get |
| - | - | - | - |
| Find sources | Search | `max_results: 3`, `snippet_max_length: 300` | The 3 pages that rank highest for the claim |
| Check each source | Fetch | `prompt`: the claim and the question, `max_chars: 600` | A one-word verdict and the quoted sentence, not the whole page |
| Report | Your code | | One verdict per URL, so a reader can open the source |

## When it runs

On demand, once per claim. A common place is after your model drafts an answer: split the draft into claims and check the ones that carry a number, a date or a name. Each claim costs 1 search and up to 3 fetches.

## Code

This sample checks one claim against the top 3 pages and prints each URL with its verdict. It runs with no API key:

```typescript TypeScript theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
// Needs keenable 0.2.0 or later on npm.
import { Keenable } from "keenable";

async function main() {
  const client = new Keenable(); // keyless: no API key needed to try it
  const claim = "The James Webb Space Telescope launched in December 2021.";
  const check =
    `Claim: ${claim}\n` +
    "Does this page support, contradict or not mention the claim? " +
    "Answer with one word, then quote the one sentence from the page that decides it.";

  // 1. Find pages that discuss the claim
  const results = await client.search(claim, { maxResults: 3, snippetMaxLength: 300 });

  // 2. Ask each page about the claim, and keep the URL with the answer
  for (const result of results.results) {
    const page = await client.fetch(result.url, { prompt: check, maxChars: 600 });
    console.log(`${page.url}\n${page.content}\n`); // page.url is the address after redirects
  }
}

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
claim = "The James Webb Space Telescope launched in December 2021."
check = (
    f"Claim: {claim}\n"
    "Does this page support, contradict or not mention the claim? "
    "Answer with one word, then quote the one sentence from the page that decides it."
)

# 1. Find pages that discuss the claim
results = client.search(claim, max_results=3, snippet_max_length=300)

# 2. Ask each page about the claim, and keep the URL with the answer
for result in results:
    page = client.fetch(result.url, prompt=check, max_chars=600)
    print(f"{page.url}\n{page.content}\n")  # page.url is the address after redirects
```

```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() {
	ctx := context.Background()
	client, err := keenable.New(nil) // keyless: no API key needed to try it
	if err != nil {
		log.Fatal(err)
	}
	defer client.Close()

	claim := "The James Webb Space Telescope launched in December 2021."
	check := "Claim: " + claim + "\n" +
		"Does this page support, contradict or not mention the claim? " +
		"Answer with one word, then quote the one sentence from the page that decides it."

	// 1. Find pages that discuss the claim
	snippetCap := 300
	results, err := client.Search(ctx, claim, &keenable.SearchOptions{MaxResults: 3, SnippetMaxLength: &snippetCap})
	if err != nil {
		log.Fatal(err)
	}

	// 2. Ask each page about the claim, and keep the URL with the answer
	for _, result := range results.Results {
		page, err := client.FetchWithOptions(ctx, result.URL, &keenable.FetchOptions{Prompt: check, MaxChars: 600})
		if err != nil {
			log.Printf("%s: %v", result.URL, err)
			continue
		}
		fmt.Printf("%s\n%s\n\n", page.URL, page.Content) // page.URL is the address after redirects
	}
}
```

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

#[tokio::main]
async fn main() -> Result<(), keenable::Error> {
    let client = Client::new()?; // keyless: no API key needed to try it
    let claim = "The James Webb Space Telescope launched in December 2021.";
    let check = format!(
        "Claim: {claim}\n\
         Does this page support, contradict or not mention the claim? \
         Answer with one word, then quote the one sentence from the page that decides it."
    );

    // 1. Find pages that discuss the claim
    let results = client
        .search_with(
            claim,
            &SearchOptions {
                max_results: Some(3),
                snippet_max_length: Some(300),
                ..Default::default()
            },
        )
        .await?;

    // 2. Ask each page about the claim, and keep the URL with the answer
    for result in &results {
        let opts = FetchOptions {
            prompt: Some(check.clone()),
            max_chars: Some(600),
            ..Default::default()
        };
        match client.fetch_with(&result.url, &opts).await {
            Ok(page) => println!("{}\n{}\n", page.url, page.content), // the address after redirects
            Err(err) => eprintln!("{}: {}", result.url, err),
        }
    }
    Ok(())
}
```

```bash curl theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
# 1. Find pages that discuss the claim
curl -s -X POST https://api.keenable.ai/v1/search/public \
  -H "Content-Type: application/json" \
  -H "X-Keenable-Title: My App" \
  -d '{
    "query": "The James Webb Space Telescope launched in December 2021.",
    "max_results": 3,
    "snippet_max_length": 300
  }' | jq -r '.results[].url' | while read -r url; do

  # 2. Ask each page about the claim, and keep the URL with the answer
  curl -s -G https://api.keenable.ai/v1/fetch/public \
    -H "X-Keenable-Title: My App" \
    --data-urlencode "url=$url" \
    --data-urlencode "prompt=Claim: The James Webb Space Telescope launched in December 2021. Does this page support, contradict or not mention the claim? Answer with one word, then quote the one sentence from the page that decides it." \
    --data-urlencode "max_chars=600" | jq -r '"\(.url)\n\(.content)\n"'
done
```

The TypeScript sample needs `keenable` 0.2.0 or later on npm, for the `prompt` option on `fetch`. The Go and Rust samples skip a page that fails to fetch and keep going. The curl tab runs the search, then checks each page the same way.

## Example output

You see each URL, then the verdict and the sentence from that page:

```text Example output · results vary theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
https://science.nasa.gov/mission/webb/launch
Support
"Webb was launched on on December 25, 2021 on board an Ariane 5 rocket from Ariane Space Spaceport in French Guiana."

https://science.nasa.gov/asset/webb/james-webb-space-telescope-launch-highlights
Support
NASA’s James Webb Space Telescope launched at 7:20 a.m. EST on December 25, 2021 on an Ariane 5 rocket from Europe’s Spaceport in French Guiana, South America.

https://science.nasa.gov/mission/webb/about-overview
Support
Webb was launched on Dec 25, 2021 on from French Guiana on an Arianne 5 rocket.
```

The quotes keep the pages' own typos. An LLM writes the verdict, so treat it as a pointer to the quote, and show the quote and URL to the reader.

## Production notes

| Situation | What happens | What to do |
| - | - | - |
| No API key | 1,000 requests per hour and 10 per second per IP address. Searches and fetches count against the same limit. | Set `KEENABLE_API_KEY` for 10 requests per second per organization 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. Check claims one at a time, or keep parallel fetches under your limit. |
| `402` with an API key | `insufficient_credits`: your organization used its allowance and prepaid balance. | Stop and top up. Retrying returns `402` again. See [402 Out of funds](https://docs.keenable.ai/errors.md#402). |
| A page can't be fetched | The fetch returns an error such as `502` with `target_unreachable`, which is retryable. | Skip the page or retry it after a few seconds. See [target\_unreachable](https://docs.keenable.ai/errors.md#target-unreachable). |
| All pages say "not mention" | The search found pages about the topic, not the claim. | Rewrite the query as the page you want to find. See [Describe the page you want](https://docs.keenable.ai/best-practices.md#describe-the-page-you-want). |
| Pages disagree | Sources can be out of date. | Prefer the primary source, and show every verdict rather than a vote. |

A fetch with a `prompt` sends the page to an LLM. If the page is longer than 500,000 characters, the LLM reads only the first 500,000. See [Fetch parameters](https://docs.keenable.ai/products/fetch.md#key-parameters).

## Next steps

* [RAG with fresh web results](https://docs.keenable.ai/recipes/rag-with-fresh-web-results.md): draft the answer you then check.
* [Docs lookup for coding agents](https://docs.keenable.ai/guides/docs-lookup-for-coding-agents.md): the same search-then-prompt pattern on documentation sites.
* [Fetch](https://docs.keenable.ai/products/fetch.md): `prompt`, `max_chars` and `live`.
* [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.