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

# Extract part of a web page with a fetch prompt

> How to pass a prompt to fetch so content holds only the facts you asked for, write prompts that return parseable output, and handle the 2,000-character limit.

Get only the facts you need from a page, in the shape your code expects. Add `prompt` to a fetch: a model reads the page, and `content` holds its answer instead of the page's markdown.

## Parameters

| Parameter | In | Type | Default | Limits | What it does |
| - | - | - | - | - | - |
| `url` | Query, `/v1/fetch` | string | Required | None | The page to read, as an absolute `http` or `https` URL. URL-encode it when it has its own query string. |
| `prompt` | Query, `/v1/fetch` | string | None | At most 2,000 characters | An instruction for extracting part of the page, at most 2000 characters. When set, a model reads the page and `content` holds only its answer instead of the whole page. |
| `max_chars` | Query, `/v1/fetch` | integer | `50000` | At least 1 | Maximum number of characters of `content`, counted in Unicode code points. Longer content is cut so that `content`, including a trailing `...`, is never longer than this, and `truncated` is `true`. |

## Extract a table from a page

This sample fetches the PostgreSQL versioning policy page and asks for each supported version with its release dates, one line each. 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 page = await client.fetch("https://www.postgresql.org/support/versioning/", {
    prompt:
      "List every supported major version with its first release date and " +
      "final release date, one line each as: version | first release | final release",
    maxChars: 1000,
  });
  console.log(page.content);
}

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
page = client.fetch(
    "https://www.postgresql.org/support/versioning/",
    prompt=(
        "List every supported major version with its first release date and "
        "final release date, one line each as: version | first release | final release"
    ),
    max_chars=1000,
)
print(page.content)
```

```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()

	page, err := client.FetchWithOptions(context.Background(), "https://www.postgresql.org/support/versioning/",
		&keenable.FetchOptions{
			Prompt: "List every supported major version with its first release date and " +
				"final release date, one line each as: version | first release | final release",
			MaxChars: 1000,
		})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(page.Content)
}
```

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

#[tokio::main]
async fn main() -> Result<(), keenable::Error> {
    let client = Client::new()?; // keyless: no API key needed to try it
    let page = client
        .fetch_with(
            "https://www.postgresql.org/support/versioning/",
            &FetchOptions {
                prompt: Some(
                    "List every supported major version with its first release date and \
                     final release date, one line each as: version | first release | final release"
                        .into(),
                ),
                max_chars: Some(1000),
                ..Default::default()
            },
        )
        .await?;
    println!("{}", page.content);
    Ok(())
}
```

```bash curl theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
curl -G https://api.keenable.ai/v1/fetch/public \
  -H "X-Keenable-Title: My App" \
  --data-urlencode "url=https://www.postgresql.org/support/versioning/" \
  --data-urlencode "prompt=List every supported major version with its first release date and final release date, one line each as: version | first release | final release" \
  --data-urlencode "max_chars=1000"
```

You see one line per supported version, in the format the prompt asked for. This run was made on 19 November 2026:

```text Example output · results vary theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
18 | September 25, 2025 | November 14, 2030
17 | September 26, 2024 | November 8, 2029
16 | September 14, 2023 | November 9, 2028
15 | October 13, 2022 | November 11, 2027
14 | September 30, 2021 | November 12, 2026
```

The response keeps the page's `url` and `title`, so you can cite the source. `total_chars` is the length of the answer, not of the page:

```json Response · results vary theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
{
  "url": "https://www.postgresql.org/support/versioning/",
  "title": "PostgreSQL: Versioning Policy",
  "content": "18 | September 25, 2025 | November 14, 2030\n17 | September 26, 2024 | November 8, 2029\n16 | September 14, 2023 | November 9, 2028\n15 | October 13, 2022 | November 11, 2027\n14 | September 30, 2021 | November 12, 2026",
  "description": "",
  "truncated": false,
  "total_chars": 215
}
```

## Write the prompt

Write the prompt as an instruction about this one page. Name the facts you want and the format to return them in, so your code can parse the answer without another model call.

| Goal | Prompt |
| - | - |
| One fact | `Which version is the current LTS? Answer with the version number only.` |
| A list | `List the modules this page says were removed from the standard library, as a comma-separated list.` |
| A table | `List every supported major version with its first release date and final release date, one line each as: version \| first release \| final release` |
| A short answer | `What happens to the other tasks when one task in a TaskGroup raises? Answer in two sentences.` |
| A check with a fallback | `Which components are not operational right now? Reply with the component names and their status, or All systems operational.` |

`content` is the model's answer, so check it before you act on it. If the page doesn't hold the answer, the model says so in `content`, and the response is still `200`. Give it a fixed reply for that case, as the last row does, so your code can test for it.

## Prompt or whole page

| Use `prompt` when | Fetch without `prompt` when |
| - | - |
| You need a few facts from a long page | You need exact wording, such as a quotation or a config block |
| You want the answer in a fixed format | You want to keep the page's headings, links and code blocks |
| Your agent's context is short | You will ask several different questions about the same page |

A prompt doesn't change what the call costs. A fetch is billed as `fetch`, or as `fetch.live` when it was read from the source, with or without a prompt. See [Pricing](https://docs.keenable.ai/pricing.md#what-each-call-costs).

## Common mistakes

| Wrong | Right | Why |
| - | - | - |
| A prompt over 2,000 characters | Keep the instruction short and about this page | The API returns `400` with `"prompt": must be 2000 characters or less`. |
| `Summarize this page` when you need two numbers | Name the two numbers and the format | A summary can leave out the facts your code needs. |
| Trust `content` without a check | Ask for a fixed reply when the page lacks the answer, then test for it | The model answers from the page. If the page doesn't hold the fact, `content` says so instead. |
| A prompt on a very long page that fails | Fetch without `prompt`, or use a more specific URL | If the page is too long to run a prompt over, the API returns `400` with `The page is too long to run a prompt over`. See [Read long pages](https://docs.keenable.ai/guides/long-pages.md). |
| An unencoded prompt in a query string | URL-encode it, for example with `curl --data-urlencode` | Spaces, `&` and `?` in a raw prompt break the query string. |

## In the SDKs, CLI and MCP

`fetch` takes `prompt` in every SDK: a keyword argument in Python, `fetch(url, { prompt })` in TypeScript (from `keenable` 0.2.0), `FetchOptions.Prompt` in Go and `FetchOptions.prompt` in Rust. See [SDK methods](https://docs.keenable.ai/sdks.md#methods). The CLI takes `--prompt` (see [CLI](https://docs.keenable.ai/cli.md)). Over MCP, `fetch_page_content` takes `prompt` (see [MCP server](https://docs.keenable.ai/mcp-server.md#available-tools)).

## API reference

* [Fetch request](https://docs.keenable.ai/api-reference/fetch.md#request): `prompt`, `max_chars` and `live` in full.
* [Search, then fetch](https://docs.keenable.ai/guides/search-then-fetch.md): decide when a fetch is worth it.
* [Fetch the current version of a page](https://docs.keenable.ai/guides/live-fetch.md): combine `prompt` with `live=true`.


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