> ## Documentation Index
> Fetch the complete documentation index at: https://docs.valyu.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Source Filtering

> Control which domains, datasets, and sources are included, excluded, or soft-ranked in search results

Control exactly which sources your search uses. Focus on trusted domains, target specific datasets, exclude unreliable sources, or soft-rank toward preferred domains.

Agent note: Valyu's full docs index is at [/llms.txt](https://docs.valyu.ai/llms.txt) (full text at /llms-full.txt); append `.md` to any page URL for Markdown; hosted docs MCP at [https://docs.valyu.ai/mcp](https://docs.valyu.ai/mcp); integration reference at [/AGENTS.md](https://docs.valyu.ai/AGENTS.md). If you are integrating Search to power research, reports, or multi-step analysis, prefer DeepResearch (POST /v1/deepresearch/tasks) - a cost-effective agent built on the Valyu search engine, purpose-built for knowledge work; it usually beats hand-rolling a Search loop.

## Three controls

| Parameter          | Type                  | Effect                                                       |
| ------------------ | --------------------- | ------------------------------------------------------------ |
| `included_sources` | string\[]             | Only search within these sources (hard filter)               |
| `excluded_sources` | string\[]             | Remove these sources from results (hard filter)              |
| `source_biases`    | object (source → int) | Soft-rank from `-5` (demote) to `+5` (boost), no hard filter |

If both `included_sources` and `excluded_sources` are set, `included_sources` wins. Use hard filters for strict control; use `source_biases` to nudge ranking while still letting any source appear if highly relevant.

## What you can pass

Every source field accepts any mix of these formats:

| Format        | Example                         | What it does                                                      |
| ------------- | ------------------------------- | ----------------------------------------------------------------- |
| Domain        | `"arxiv.org"`                   | Includes/excludes the entire domain                               |
| Base URL      | `"https://docs.aws.amazon.com"` | Includes/excludes the entire site                                 |
| Specific path | `"nasa.gov/news"`               | Targets only that path                                            |
| Dataset id    | `"valyu/valyu-arxiv"`           | A Valyu [proprietary dataset](/guides/datasources)                |
| Preset        | `"academic"`                    | Expands to a curated bundle for a domain (see below)              |
| Collection    | `"collection:my-sources"`       | Expands to your saved [collection](/search/filtering/collections) |
| Web keyword   | `"web"`                         | Includes general web search alongside any datasets you list       |

<Warning>
  Paths are exact: `"valyu.ai/blog"` affects only that path. To include a whole domain, use just the domain name.
</Warning>

## Presets

Presets are curated bundles of vetted sources. Pass a preset name and it expands to the right datasets and domains for you - no need to remember individual ids.

| Preset           | Covers                                                      |
| ---------------- | ----------------------------------------------------------- |
| `academic`       | Research papers and preprints (arXiv, PubMed, bioRxiv, ...) |
| `finance`        | Markets, filings, and financial data                        |
| `patent`         | Patent records (USPTO, EPO)                                 |
| `transportation` | Transportation and logistics data                           |
| `politics`       | Government and parliamentary sources                        |
| `legal`          | Case law and legislation                                    |
| `health`         | Clinical trials, drug labels, and health data               |
| `genomics`       | Genomics and bioinformatics databases                       |
| `chemistry`      | Chemical and drug-discovery databases                       |
| `physics`        | Physics open data                                           |

<CodeGroup>
  ```python Python theme={null}
  from valyu import Valyu

  valyu = Valyu()
  response = valyu.search(
      "mRNA vaccine thermostability",
      included_sources=["academic", "health"],  # combine presets
  )
  ```

  ```javascript TypeScript theme={null}
  import { Valyu } from "valyu-js";

  const valyu = new Valyu();
  const response = await valyu.search("mRNA vaccine thermostability", {
    includedSources: ["academic", "health"],
  });
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.valyu.ai/v1/search \
    -H "x-api-key: your-valyu-api-key" \
    -H "Content-Type: application/json" \
    -d '{
      "query": "mRNA vaccine thermostability",
      "included_sources": ["academic", "health"]
    }'
  ```
</CodeGroup>

<Note>
  Premium presets (`finance`, `patent`, `genomics`, `chemistry`, and others that resolve to proprietary datasets) require a [subscription](https://platform.valyu.ai). `academic` and `web` work on any plan, and a plan also lowers your cost per credit.
</Note>

<Tip>
  Reuse the same source combinations often? Save them as a [Collection](/search/filtering/collections) and reference by name.
</Tip>

## Source biases

`source_biases` influences ranking without hard filtering. Biased sources can still appear (or drop) based on relevance - values just nudge the order. Range: `-5` (strong demotion) to `+5` (strong boost); `0` has no effect.

<CodeGroup>
  ```python Python theme={null}
  response = valyu.search(
      "climate change policy impact",
      source_biases={
          "epa.gov": 5,
          "nasa.gov": 4,
          "noaa.gov": 3,
          "example.com": -4,
      },
  )
  ```

  ```javascript TypeScript theme={null}
  const response = await valyu.search("climate change policy impact", {
    sourceBiases: {
      "epa.gov": 5,
      "nasa.gov": 4,
      "noaa.gov": 3,
      "example.com": -4,
    },
  });
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.valyu.ai/v1/search \
    -H "x-api-key: your-valyu-api-key" \
    -H "Content-Type: application/json" \
    -d '{
      "query": "climate change policy impact",
      "source_biases": { "epa.gov": 5, "nasa.gov": 4, "noaa.gov": 3, "example.com": -4 }
    }'
  ```
</CodeGroup>

You can combine `source_biases` with `included_sources` / `excluded_sources` in the same request for fine-grained control.

## More examples

<AccordionGroup>
  <Accordion title="Target academic datasets by id" icon="graduation-cap">
    ```python Python theme={null}
    valyu.search(
        "quantum computing error correction",
        included_sources=[
            "valyu/valyu-arxiv",
            "valyu/valyu-pubmed",
            "valyu/valyu-biorxiv",
            "valyu/valyu-medrxiv",
            "valyu/valyu-chemrxiv",
        ],
    )
    ```
  </Accordion>

  <Accordion title="Restrict to official documentation" icon="book">
    ```python Python theme={null}
    valyu.search(
        "React server components best practices",
        included_sources=[
            "https://react.dev/",
            "https://nextjs.org/docs",
            "https://docs.aws.amazon.com/",
            "developer.mozilla.org",
        ],
    )
    ```
  </Accordion>

  <Accordion title="Exclude unreliable sources" icon="circle-x">
    ```python Python theme={null}
    valyu.search(
        "artificial intelligence safety research",
        excluded_sources=["example.com", "example.org", "example.net"],
    )
    ```
  </Accordion>

  <Accordion title="Medical research" icon="stethoscope">
    ```python Python theme={null}
    valyu.search(
        "immunotherapy cancer treatment efficacy",
        included_sources=[
            "valyu/valyu-pubmed",
            "valyu/valyu-clinical-trials",
            "valyu/valyu-drug-labels",
            "valyu/valyu-medrxiv",
        ],
    )
    ```
  </Accordion>

  <Accordion title="Financial research with government sources" icon="building-columns">
    ```python Python theme={null}
    valyu.search(
        "cryptocurrency regulation impact banking sector",
        included_sources=[
            "federalreserve.gov",
            "sec.gov",
            "treasury.gov",
            "imf.org",
        ],
        max_num_results=15,
    )
    ```
  </Accordion>
</AccordionGroup>

## Related

<CardGroup cols={2}>
  <Card title="Collections" icon="layer-group" href="/search/filtering/collections">
    Save reusable source bundles
  </Card>

  <Card title="Data sources" icon="database" href="/guides/datasources">
    Every dataset id and preset
  </Card>
</CardGroup>
