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

# Research Examples

> Examples for filtering, continuations, and saved runs

## Stream the Final Report

Set `stream: true` and concatenate `synthesis_delta` values for live report text. The final assembled report is also
included in `final_result`.

```python theme={null}
import json
import os
import httpx

payload = {"query": "What changed in battery recycling this year?", "mode": "deep", "stream": True}

with httpx.stream(
    "POST",
    "https://agent.tinyfish.ai/v1/automation/run-research",
    headers={"X-API-Key": os.environ["TINYFISH_API_KEY"]},
    json=payload,
    timeout=2700,
) as response:
    response.raise_for_status()
    for line in response.iter_lines():
        if not line.startswith("data: "):
            continue
        event = json.loads(line[6:])
        if event["event"] == "synthesis_delta":
            print(event["delta"], end="", flush=True)
        elif event["event"] == "done":
            break
```

## Restrict Research to Trusted Domains

Use `include` to prioritize domains while retaining other results. Use `exclusive` to restrict results to the allowlist.
Blocked domains are always removed. Each list accepts at most 150 entries.

```json theme={null}
{
  "query": "Compare current public-health recommendations",
  "domain_filter": {
    "mode": "exclusive",
    "domains": ["who.int", "cdc.gov"],
    "block": []
  }
}
```

## Continue Research

Use the `session_id` emitted by a standard run to continue its conversation.

```json theme={null}
{
  "query": "Which conclusion has the strongest primary-source support?",
  "mode": "standard",
  "session_id": "019..."
}
```

Use `prior_run_id` instead to seed a new run with a completed report and its evidence.

```json theme={null}
{
  "query": "Update this report with developments from the last week",
  "mode": "deep",
  "prior_run_id": "019..."
}
```

## Retrieve Saved Runs

```bash theme={null}
curl "https://agent.tinyfish.ai/v1/research-run?status=COMPLETED&limit=20" \
  -H "X-API-Key: $TINYFISH_API_KEY"
```

```bash theme={null}
curl "https://agent.tinyfish.ai/v1/research-run/$RESEARCH_RUN_ID" \
  -H "X-API-Key: $TINYFISH_API_KEY"
```

## Cancel a Running Run

```bash theme={null}
curl -X POST \
  "https://agent.tinyfish.ai/v1/research-run/$RESEARCH_RUN_ID/cancel" \
  -H "X-API-Key: $TINYFISH_API_KEY"
```

```json theme={null}
{
  "research_run_id": "019...",
  "status": "CANCELLED",
  "cancelled": true
}
```
