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

# Hybrid synthesize

> Run a multi-source synthesis pipeline that combines PDF analyses and company intelligence into a unified causal narrative.

The hybrid synthesize endpoint runs a multi-stage pipeline that ingests PDFs and company profiles, extracts causal entities and relationships, synthesises them into novel research ideas, and applies a novelty gate before returning a structured synthesis result. The pipeline streams progress as Server-Sent Events (SSE), so your client receives incremental updates as each stage completes.

<Info>
  Authentication is optional. If you include a valid `Authorization` header, results are associated with your account and persisted in your session history. Without a token, the synthesis runs anonymously and is not saved.
</Info>

***

## Run a synthesis

```
POST /api/hybrid-synthesize
```

* **Content-Type:** `multipart/form-data`
* **Response:** `text/event-stream` (SSE)
* **Max duration:** 300 seconds (5 minutes)

### Minimum inputs

You must supply **at least 2 total sources** across files and companies combined. For example: 1 PDF + 1 company, or 2 PDFs, or 2 companies.

### Form data parameters

<ParamField body="files" type="File[]">
  PDF files to include in the synthesis. Maximum 6 files. Each file must be a valid PDF. Files are parsed, scientifically analysed, and their causal entities are extracted before synthesis.
</ParamField>

<ParamField body="companies" type="string">
  JSON-encoded array of company names to include as intelligence sources. Maximum 5 companies. The pipeline retrieves recent research and product context for each company and incorporates it alongside your PDFs.

  Example: `'["DeepMind", "Anthropic", "Meta AI"]'`
</ParamField>

<ParamField body="researchFocus" type="string">
  A guiding question or theme that orients the synthesis. The pipeline uses this focus to rank ideas and structure the output.

  Example: `"causal mechanisms of neuroplasticity under chronic stress"`
</ParamField>

<ParamField body="enableParallelRefinement" type="string" default="true">
  Whether to run the refinement stage with parallel threads. Set to `"true"` or `"false"`.
</ParamField>

<ParamField body="parallelConcurrency" type="number" default="3">
  Number of concurrent refinement threads when `enableParallelRefinement` is `"true"`. Higher values produce richer output but increase latency.
</ParamField>

### SSE events

The response is a stream of SSE events. Each event has an `event` name and a JSON `data` payload. Parse them incrementally as they arrive.

#### Timeline

Stages execute in this order: `ingestion` → `pdf_parsing` → `entity_harvest` → `synthesis` → `novelty_gate` → `recovery_plan` → `completed`

Each stage emits `timeline_stage_started`, then `timeline_stage_completed` (or `timeline_stage_skipped` if the stage is not applicable given your inputs).

#### Event reference

<AccordionGroup>
  <Accordion title="ingestion_start">
    Emitted once when the pipeline begins processing your inputs.

    ```json theme={null}
    {
      "files": 2
    }
    ```

    * `files` — number of PDF files received.
  </Accordion>

  <Accordion title="pdf_processed">
    Emitted once per PDF file after it has been successfully parsed.

    ```json theme={null}
    {
      "filename": "mcewen_2012_stress_hippocampus.pdf"
    }
    ```
  </Accordion>

  <Accordion title="scientific_analysis_complete">
    Emitted after all PDF scientific analyses finish.

    ```json theme={null}
    {
      "pdfCount": 2,
      "completed": 2,
      "failed": 0
    }
    ```
  </Accordion>

  <Accordion title="timeline_stage_started">
    Emitted when a pipeline stage begins.

    ```json theme={null}
    {
      "stage": "entity_harvest",
      "state": "started",
      "timestamp": "2026-04-05T12:01:05Z",
      "meta": {}
    }
    ```
  </Accordion>

  <Accordion title="timeline_stage_completed">
    Emitted when a pipeline stage finishes successfully.

    ```json theme={null}
    {
      "stage": "entity_harvest",
      "state": "completed",
      "timestamp": "2026-04-05T12:01:12Z",
      "meta": {
        "entitiesExtracted": 34
      }
    }
    ```
  </Accordion>

  <Accordion title="timeline_stage_skipped">
    Emitted when a pipeline stage is skipped (e.g., `recovery_plan` when no failures occurred).

    ```json theme={null}
    {
      "stage": "recovery_plan",
      "state": "skipped",
      "timestamp": "2026-04-05T12:02:00Z",
      "meta": {}
    }
    ```
  </Accordion>

  <Accordion title="complete">
    Emitted as the final event when the pipeline finishes. Contains the full synthesis result.

    ```json theme={null}
    {
      "synthesis": {
        "selectedIdea": "Chronic cortisol elevation causally suppresses BDNF expression, mediating hippocampal volume reduction via TrkB receptor downregulation.",
        "novelIdeas": [
          "Intermittent glucocorticoid exposure may preserve neuroplasticity through hormetic stress-response pathways.",
          "BDNF-TrkB signalling as a causal mediator between cortisol and spatial memory deficits."
        ],
        "structuredApproach": {
          "hypothesis": "...",
          "proposedDesign": "...",
          "keyVariables": ["cortisol_level", "BDNF_expression", "hippocampal_volume"],
          "identificationStrategy": "back-door adjustment on stress_exposure and age"
        },
        "noveltyGate": {
          "passed": true,
          "score": 0.78,
          "rationale": "Hypothesis is sufficiently distinct from existing literature indexed in the synthesis."
        },
        "timelineReceipt": {
          "stages": ["ingestion", "pdf_parsing", "entity_harvest", "synthesis", "novelty_gate", "completed"],
          "totalDurationMs": 47320
        },
        "runId": "run-4e2f9c10-bb3a-4d8e-a917-c1d0f2b3e456"
      },
      "scientificAnalysis": [
        {
          "filename": "mcewen_2012_stress_hippocampus.pdf",
          "summary": "Reviews glucocorticoid-mediated structural plasticity in hippocampus.",
          "keyFindings": ["Chronic stress reduces CA3 dendritic arborisation", "BDNF is suppressed by elevated cortisol"]
        }
      ],
      "featureContext": {
        "companies": ["DeepMind"],
        "companyInsights": {
          "DeepMind": "Recent work on causal representation learning relevant to neuroscience benchmarks."
        }
      }
    }
    ```
  </Accordion>

  <Accordion title="error">
    Emitted if a fatal error occurs. The stream closes after this event.

    ```json theme={null}
    {
      "message": "PDF parsing failed: file exceeds maximum size."
    }
    ```
  </Accordion>
</AccordionGroup>

### Examples

<CodeGroup>
  ```javascript JavaScript (fetch + SSE) theme={null}
  const formData = new FormData();
  formData.append('files', pdfFile1);
  formData.append('files', pdfFile2);
  formData.append('companies', JSON.stringify(['DeepMind']));
  formData.append('researchFocus', 'causal mechanisms of neuroplasticity');
  formData.append('enableParallelRefinement', 'true');
  formData.append('parallelConcurrency', '3');

  const response = await fetch('https://wuweism.com/api/hybrid-synthesize', {
    method: 'POST',
    headers: { 'Authorization': 'Bearer <token>' },
    body: formData,
  });

  const reader = response.body.getReader();
  const decoder = new TextDecoder();

  while (true) {
    const { done, value } = await reader.read();
    if (done) break;

    const chunk = decoder.decode(value);
    for (const line of chunk.split('\n')) {
      if (line.startsWith('data: ')) {
        const event = JSON.parse(line.slice(6));
        console.log(event);
      }
    }
  }
  ```

  ```python Python theme={null}
  import requests
  import json

  with open('paper1.pdf', 'rb') as f1, open('paper2.pdf', 'rb') as f2:
      response = requests.post(
          'https://wuweism.com/api/hybrid-synthesize',
          headers={'Authorization': 'Bearer <token>'},
          files=[('files', f1), ('files', f2)],
          data={
              'companies': json.dumps(['DeepMind']),
              'researchFocus': 'causal mechanisms of neuroplasticity',
          },
          stream=True,
      )

  for line in response.iter_lines():
      if line.startswith(b'data: '):
          event = json.loads(line[6:])
          print(event)
  ```

  ```bash cURL (companies only) theme={null}
  curl --request POST \
    --url https://wuweism.com/api/hybrid-synthesize \
    --header 'Authorization: Bearer <token>' \
    --form 'companies=["DeepMind","Anthropic"]' \
    --form 'researchFocus=causal benchmarks for large language models' \
    --no-buffer
  ```
</CodeGroup>

<Warning>
  The pipeline has a hard timeout of **300 seconds**. If your inputs are large (many PDFs or high `parallelConcurrency`), ensure your HTTP client does not time out before the `complete` event arrives. Set your client's read timeout to at least 310 seconds.
</Warning>
