# Search

> Query Brave, Tavily, Exa, SearXNG, DuckDuckGo, SerpAPI and Serper web search from SQL through one interface

This page includes setup, release pins, credentials, hosting and verification evidence. [JSON alternative](https://query.farm/products/orchard/api/v1/connectors/search.json) contains the same setup facts for structured readers; choose one format.

## Runtime and release

Use DuckDB or Haybarn **2.0.1** with **VGI protocol 3.4**.
Catalog alias: `search`. Release: [v0.5.0](https://github.com/Query-farm/vgi-search/releases/tag/v0.5.0). Metadata generated: 2026-12-01T18:22:16+00:00.

## Choose where it runs

- On your machine: use an installation method below. No Query Farm account is required for local execution.
- Self-host: follow [the connector deployment instructions](https://github.com/Query-farm/vgi-search) and [connection guide](https://query.farm/vgi/connect-to-a-worker/). Use your real endpoint and its authentication settings.
- Query Farm hosted: [create a deployment](https://auth.queryfarm.cloud/console/new?worker=search). Hosting has a $10 monthly minimum per organization; usage and license fees may apply. Copy the deployment-specific ATTACH from the console.

## Service credentials and prerequisites

Supply your own service credentials or required connection options before querying protected data.

Secret parameter required flags describe the upstream declaration; they do not override the service-level mode above. Keep secrets in environment variables or the deployment secret store. SQL values in angle brackets are placeholders, not automatic environment lookups. Native DuckDB and Haybarn 2.0.1 do not provide a SQL getenv() function, even when worker-supplied snippets mention it. Read environment variables in your application and pass credential values through client parameter bindings (for example, Python con.execute("CREATE SECRET stripe (TYPE stripe, api_key ?)", [os.environ["STRIPE_API_KEY"]]) after attaching the connector. Omit unused optional parameters and keep real values out of saved SQL and logs.

After installing VGI and attaching the connector, create the required secrets using your own values. Replace placeholders and omit unused optional parameters from the templates below.

### brave

Optional Brave Search API key for web_search(provider := brave) / web_answer. Falls back to the BRAVE_API_KEY environment variable.
[Credential instructions](https://brave.com/search/api/)

```json
[
  {
    "name": "api_key",
    "type": "VARCHAR",
    "required": false,
    "redact": true,
    "description": "Brave Search API key, issued from your account at https://brave.com/search/api/"
  }
]
```

```sql
CREATE SECRET brave (
    TYPE brave,
    api_key '<BRAVE_API_KEY>'  -- secret
);
```

### tavily

Optional Tavily Search API key for web_search(provider := tavily) / web_answer. Falls back to the TAVILY_API_KEY environment variable.
[Credential instructions](https://app.tavily.com/)

```json
[
  {
    "name": "api_key",
    "type": "VARCHAR",
    "required": false,
    "redact": true,
    "description": "Tavily Search API key, issued from your account at https://app.tavily.com/"
  }
]
```

```sql
CREATE SECRET tavily (
    TYPE tavily,
    api_key '<TAVILY_API_KEY>'  -- secret
);
```

### exa

Optional Exa Search API key for web_search(provider := exa) / web_answer. Falls back to the EXA_API_KEY environment variable.
[Credential instructions](https://dashboard.exa.ai/api-keys)

```json
[
  {
    "name": "api_key",
    "type": "VARCHAR",
    "required": false,
    "redact": true,
    "description": "Exa Search API key, issued from your account at https://dashboard.exa.ai/api-keys"
  }
]
```

```sql
CREATE SECRET exa (
    TYPE exa,
    api_key '<EXA_API_KEY>'  -- secret
);
```

### serpapi

Optional SerpApi (opt-in; requires VGI_SEARCH_ENABLE_SERP=1) key for web_search(provider := serpapi) / web_answer. Falls back to the SERPAPI_API_KEY environment variable.
[Credential instructions](https://serpapi.com/manage-api-key)

```json
[
  {
    "name": "api_key",
    "type": "VARCHAR",
    "required": false,
    "redact": true,
    "description": "SerpApi (opt-in; requires VGI_SEARCH_ENABLE_SERP=1) key, issued from your account at https://serpapi.com/manage-api-key"
  }
]
```

```sql
CREATE SECRET serpapi (
    TYPE serpapi,
    api_key '<SERPAPI_API_KEY>'  -- secret
);
```

### serper

Optional Serper.dev (opt-in; requires VGI_SEARCH_ENABLE_SERP=1) key for web_search(provider := serper) / web_answer. Falls back to the SERPER_API_KEY environment variable.
[Credential instructions](https://serper.dev/api-key)

```json
[
  {
    "name": "api_key",
    "type": "VARCHAR",
    "required": false,
    "redact": true,
    "description": "Serper.dev (opt-in; requires VGI_SEARCH_ENABLE_SERP=1) key, issued from your account at https://serper.dev/api-key"
  }
]
```

```sql
CREATE SECRET serper (
    TYPE serper,
    api_key '<SERPER_API_KEY>'  -- secret
);
```

## Install the extension

In stock DuckDB:

```sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
```

In Haybarn:

```sql
INSTALL vgi FROM community;
LOAD vgi;
```

## Attach the connector

The local recipes below pin the catalog release for repeatability. A public demo endpoint follows its deployed release.

### uvx

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

```sql
ATTACH 'search' AS search (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/vgi-search@v0.5.0 vgi-search-worker'
);
```

### Docker

Attach the signed image

Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.

```sql
ATTACH 'search' AS search (
  TYPE vgi,
  LOCATION 'oci://ghcr.io/query-farm/vgi-search:0.5.0'
);
```

## Search the web from SQL

Service credentials required for this example: not declared by this example; check the connector requirements above.

```sql
SELECT title, url, rank FROM search.main.web_search('python programming language', provider := 'ddg', count := 5) ORDER BY rank
```

- [search.main.web_search — table_function](https://query.farm/products/orchard/connectors/search/objects/table_function.bWFpbg.d2ViX3NlYXJjaA.md): exact declaration for this example.

Execution evidence: **captured_result**.

```json
{
  "status": "captured_result",
  "capturedAt": "2026-12-01T06:21:29+00:00",
  "engineVersion": "2.0.1",
  "protocolVersion": "3.4.0",
  "releaseTag": "v0.5.0",
  "sample": {
    "columns": [
      "title",
      "url",
      "rank"
    ],
    "types": [
      "VARCHAR",
      "VARCHAR",
      "INTEGER"
    ],
    "rows": [
      [
        "Python (programming language)",
        "https://en.wikipedia.org/wiki/Python_(programming_language)",
        1
      ],
      [
        "Python (programming language) Category",
        "https://duckduckgo.com/c/Python_(programming_language)",
        2
      ],
      [
        "CPython",
        "https://duckduckgo.com/CPython",
        3
      ],
      [
        "Cython",
        "https://duckduckgo.com/Cython",
        4
      ],
      [
        "Jupyter",
        "https://duckduckgo.com/Project_Jupyter",
        5
      ]
    ],
    "more": false
  }
}
```

## Connector reference

### Unified Web Search in SQL

Query the live web directly from DuckDB SQL through one pluggable provider surface that unifies **Brave Search**, **Tavily**, **Exa**, **SearXNG**, and **DuckDuckGo** behind a single result schema -- built for RAG, retrieval, and agent grounding.

This extension turns web search into a first-class SQL data source. Instead of wiring a different HTTP client and JSON shape for every search API, you call one table function and get back the same unified rows -- `title`, `url`, `snippet`, `rank`, `source`, `published`, `score`, and an `extra` JSON column for provider-specific fields -- no matter which provider served the query. It is designed for developers building retrieval-augmented generation (RAG) pipelines, search-driven analytics, and AI agents that need fresh, citable web results inside the database, with the ability to swap or A/B providers without rewriting a single query.

Under the hood the worker is a thin, dependency-light connector: every provider is reached over plain HTTP with the [httpx](https://www.python-httpx.org/) client ([source](https://github.com/encode/httpx)) -- no heavyweight provider SDKs are bundled. Each backend is a small adapter that maps the upstream JSON into the shared result shape, with a per-call timeout plus bounded retry/backoff on rate-limit and server errors so a flaky provider never crashes the engine. Because it is an egress connector, results and quotas come from your own upstream subscription: API keys are supplied through the VGI secret provider (one secret type per keyed provider) and are **never** passed inline in SQL, while DuckDuckGo works key-free.

The function surface is intentionally small. The table function `web_search(query, provider := ..., count := ..., page := ...)` runs one search against the chosen provider and streams the ranked, unified rows with 0-based page pagination. The scalar `web_answer(query, provider)` returns a single synthesized one-line answer (via Tavily or the free DuckDuckGo Instant Answer API) or NULL when none is available. The table function `search_providers()` lists every provider and whether each currently has a key or base URL configured. Runnable, catalog-qualified queries for each function live in that object's examples.

### Providers & documentation

- **Brave Search** -- [API docs](https://brave.com/search/api/), [developer dashboard](https://api-dashboard.search.brave.com/app/documentation/web-search/get-started)
- **Tavily** -- [site](https://tavily.com/), [docs](https://docs.tavily.com/)
- **Exa** -- [site](https://exa.ai/), [docs](https://docs.exa.ai/)
- **SearXNG** (self-hosted, base_url required) -- [source](https://github.com/searxng/searxng), [docs](https://docs.searxng.org/)
- **DuckDuckGo** (free, key-free) -- [duckduckgo.com](https://duckduckgo.com/)

Opt-in SerpApi/Serper SERP backends are also available when explicitly enabled. Built and maintained by [Query.Farm](https://query.farm).

## Find the exact SQL object

[Browse 3 object declarations](https://query.farm/products/orchard/api/v1/connectors/search/objects.json) or [search within this connector](https://query.farm/products/orchard/api/v1/search.json?kind=object&connector=search&q=search).

Follow one format of each needed object for complete argument types, defaults, named flags, return columns and examples. Existing links above can replace another search. For questions about hosting, credentials or supported operations, stop once the documentation answers the question; SQL and unrelated object lookups are unnecessary.

## Verification and interpretation

- Missing, null, or undeclared metadata means unknown; do not invent defaults, credential scope, platform support or endpoint URLs.
- Search is keyword retrieval, not proof of a capability. Read the exact object declaration before generating SQL.
- A table and a table function can have the same name. Preserve parentheses and use the matching overload and schema.
- Service credentials, external data availability and deployment authentication are separate requirements.
- Catalog verification records the harvest environment. It is not proof that every query or current live API call succeeds. Only an example with captured_result has a saved result for that exact SQL.

```json
{
  "generatedAt": "2026-12-01T18:22:16+00:00",
  "repository": "https://github.com/Query-farm/vgi-search",
  "harvest": {
    "status": "ok",
    "method": "subprocess",
    "error": null,
    "vgi_version": "9773130dde"
  },
  "catalogVerification": {
    "verified": true,
    "status": "passed",
    "total": 3,
    "passed": 3,
    "failed": 0,
    "needs_credentials": 0,
    "location": "uvx --from git+https://github.com/Query-farm/vgi-search@v0.5.0 vgi-search-worker",
    "transport": "subprocess",
    "environment": {
      "vgi_extension_version": "9773130dde",
      "haybarn_version": "2.0.1rc3",
      "engine_version": "v2.0.1",
      "python": "3.12.4",
      "platform": "darwin_arm64",
      "protocol_version": "3.4.0"
    },
    "checked_at": "2026-12-01T06:17:46+00:00"
  },
  "interpretation": "Catalog verification records the harvest environment. It is not proof that every query or current live API call succeeds. Only an example with captured_result has a saved result for that exact SQL."
}
```
