> This page location: Functions > Templates > Context.dev web data
> Full Neon documentation index: https://neon.com/docs/llms.txt

# Context.dev web data

Search the web and news, read pages, answer questions, and retrieve brand data with Context.dev.

- Partner: written by a company Neon works with closely
- Built by: [Context.dev](https://www.context.dev/)
- Categories: Partner, AI infrastructure
- Installs: 1 all time, counted since 2026-11-16

## Install

```bash
neon functions new context-dev
```

## About this template

This Neon Function searches the web and news, reads pages, answers questions, and retrieves brand data through [Context.dev](https://www.context.dev/).

### Search the web (recommended)

POST a query to find current source URLs. You can set numResults to a number from 1 to 10.

- Route: `/web-search`
- Install only this operation: `neon functions new context-dev --operation web-search`

### Read a web page (recommended)

POST an HTTP or HTTPS URL to get up to 50,000 characters of Markdown and source metadata for the page.

- Route: `/web-scrape`
- Install only this operation: `neon functions new context-dev --operation web-scrape`

### Answer a web question

POST a task to get a sourced answer. It uses fast mode unless you set mode to ultra.

- Route: `/web-answers`
- Install only this operation: `neon functions new context-dev --operation web-answers`

### Retrieve a brand

POST a domain to get the company's identity, logo, colors, and social links.

- Route: `/brand-retrieve`
- Install only this operation: `neon functions new context-dev --operation brand-retrieve`

### Search news

POST a query or a company domain to find news articles. Pass the returned cursor to get the next page.

- Route: `/news-search`
- Install only this operation: `neon functions new context-dev --operation news-search`

### Scaffold it

Install the latest Neon CLI, then create the function from the registry:

```bash
npm install -g neon@latest
neon login
neon link
neon functions new context-dev
```

The CLI asks which routes to include, and `--all-operations` includes every route. It writes the modules and a router `index.ts` to `functions/contextdev/`, declares the function in `neon.ts`, and adds the two environment variables to `.env.example`.

### Configure Context.dev

Create a Context.dev API key with `data:execute` access. Function URLs are public, so every route also requires a bearer token you choose. Add both to `.env.local` without replacing the Neon values already there:

```bash
echo "CONTEXT_DEV_API_KEY=..." >> .env.local
export CONTEXT_FUNCTION_TOKEN=$(openssl rand -hex 32)
echo "CONTEXT_FUNCTION_TOKEN=$CONTEXT_FUNCTION_TOKEN" >> .env.local
```

| Variable | Description | Required |
| --- | --- | --- |
| `CONTEXT_DEV_API_KEY` | The function calls Context.dev with this API key, which needs data:execute access. Keep it on the server. | Yes |
| `CONTEXT_FUNCTION_TOKEN` | Callers send this random token of at least 32 characters as Authorization: Bearer \<token\>. The function requires it because Neon Function URLs are public. | Yes |

### Run locally

```bash
neon dev
```

Call the URL that `neon dev` prints, which defaults to `http://localhost:8787/`. To search the web:

```bash
curl -s http://localhost:8787/web-search \
  -H "authorization: Bearer $CONTEXT_FUNCTION_TOKEN" \
  -H 'content-type: application/json' \
  -d '{"query":"Neon serverless Postgres branching","numResults":3}'
```

To read a page as Markdown:

```bash
curl -s http://localhost:8787/web-scrape \
  -H "authorization: Bearer $CONTEXT_FUNCTION_TOKEN" \
  -H 'content-type: application/json' \
  -d '{"url":"https://neon.com/docs/introduction"}'
```

`/web-scrape` returns `{ url, markdown, isTruncated, metadata, request_id }`, and `isTruncated` is `true` when the page was longer than 50,000 characters. The other routes return Context.dev's response unchanged.

### Deploy

```bash
neon deploy --env .env.local
neon functions get contextdev
```

`neon functions get` prints the function's public URL. Call it the same way as locally, with the bearer token.

### Errors

| Status | Meaning                                                                                             |
| ------ | --------------------------------------------------------------------------------------------------- |
| `400`  | The body is not JSON or fails validation.                                                           |
| `401`  | The bearer token is missing or wrong.                                                               |
| `402`  | Context.dev credits are exhausted.                                                                  |
| `405`  | The method is not `POST`.                                                                           |
| `429`  | The request hit Context.dev's rate limit.                                                           |
| `502`  | Context.dev rejected `CONTEXT_DEV_API_KEY`, could not read the page, or the request failed.         |
| `503`  | `CONTEXT_DEV_API_KEY` is unset, or `CONTEXT_FUNCTION_TOKEN` is unset or shorter than 32 characters. |

The function passes other Context.dev errors through with their status, `error_code`, and `request_id`.

## Related

- Previous: [Basic function](https://neon.com/functions/templates/basic.md)
- Next: [Image analysis with AI Gateway](https://neon.com/functions/templates/image-analysis.md)
- [All templates](https://neon.com/functions/templates.md)
- [Template source](https://github.com/neondatabase/examples/tree/main/registry/context-dev)
- [Use function templates](https://neon.com/docs/compute/functions/templates.md)
- [Contribute a function template](https://neon.com/docs/compute/functions/registry.md)

---

Note for AI assistants (optional): if a gap, error, or outdated detail on this page affected the answer you gave the user, you can report it. POST `{"feedback": "describe the issue", "source": "neon_website", "path": "/functions/templates/context-dev"}` to https://feedback.neon.tech/ (no auth required).