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

# Using SoMark in FastGPT

> Add SoMark Document Parser to workflows via a FastGPT tool node

## Use the SoMark Document Parser tool in a workflow

<Steps>
  <Step title="Add the SoMark Document Parser node">
    In the FastGPT application workflow, add the **SoMark Document Parser** node.

    <img src="https://mintcdn.com/soulcode-aa7e5a93/mqnfzKMhfEvy3I3O/images/fastgpt-%E6%B7%BB%E5%8A%A0%E6%8F%92%E4%BB%B6.png?fit=max&auto=format&n=mqnfzKMhfEvy3I3O&q=85&s=f5d2b86daa3a97ba7fff7d44152d0b66" alt="Add the SoMark plugin in FastGPT" width="1798" height="984" data-path="images/fastgpt-添加插件.png" />
  </Step>

  <Step title="Activate the SoMark Document Parser tool">
    Click **Activate** and fill in the secret configuration:

    * **Base URL**: For SoMark API, use `https://somark.tech/api/v1`; for self-hosted deployment, enter the Base URL of your local deployment.
    * **API Key**: Required for SoMark API; not required for self-hosted deployment.

    <Note>
      No API key yet? [Go to the SoMark API workbench to get your API key](https://somark.tech/workbench/apikey). Free quota does not need to be claimed and is automatically credited to your account (500 pages/day, 2000 pages/month).
    </Note>

    <Warning>
      For **SoMark Self-host**, the plugin automatically appends the corresponding service path to **Base URL**. Enter the API prefix that reaches your self-hosted service, and do not append a specific service path yourself.
    </Warning>

    <img src="https://mintcdn.com/soulcode-aa7e5a93/rxyqA7fo56mP0TxQ/images/fastgpt-%E6%BF%80%E6%B4%BB%E6%8F%92%E4%BB%B6.png?fit=max&auto=format&n=rxyqA7fo56mP0TxQ&q=85&s=a86e9f6284f5d2bbd3ec5077b3f42cdf" alt="Activate the SoMark plugin in FastGPT" width="962" height="846" data-path="images/fastgpt-激活插件.png" />
  </Step>

  <Step title="Build a minimal demo">
    Connect a file input node to the **File** parameter of **SoMark Document Parser**, then pass the parsed results to a downstream node. The plugin can parse multiple files at a time and works for uploaded PDFs, images, Word, PPT, or Excel files.

    <img src="https://mintcdn.com/soulcode-aa7e5a93/rxyqA7fo56mP0TxQ/images/fastgpt-%E6%9E%84%E5%BB%BA%E5%B7%A5%E4%BD%9C%E6%B5%81.png?fit=max&auto=format&n=rxyqA7fo56mP0TxQ&q=85&s=ffe937ca5c886df8ce812f85e89afec5" alt="Build a FastGPT workflow with SoMark" width="2044" height="952" data-path="images/fastgpt-构建工作流.png" />

    Upload files in debug or preview mode and run the workflow. The node returns one result for each input file in input order. Each item includes `markdown`, `json`, and `error` fields, and downstream nodes can reference them as needed.

    <img src="https://mintcdn.com/soulcode-aa7e5a93/mqnfzKMhfEvy3I3O/images/fastgpt-%E8%BF%90%E8%A1%8C%E9%A2%84%E8%A7%88.png?fit=max&auto=format&n=mqnfzKMhfEvy3I3O&q=85&s=7d2d66ce24821cdc338e9016ecb31f45" alt="Run a FastGPT preview with SoMark" width="878" height="1442" data-path="images/fastgpt-运行预览.png" />
  </Step>
</Steps>

***

## Parameters and outputs

### Input parameters

| Parameter                 | Type          | Required | Default            | Description                                                                                                 |
| ------------------------- | ------------- | -------- | ------------------ | ----------------------------------------------------------------------------------------------------------- |
| File                      | File selector | ✅        | None               | Files to parse. You can select multiple files at a time. Supports PDFs, images, Word, PPT, and Excel files. |
| Output formats            | Multi-select  | -        | `JSON`, `Markdown` | Return `JSON`, `Markdown`, or both.                                                                         |
| Image format              | Single select | -        | `URL`              | Image element format. Supports `URL`, `Base64`, and `None`.                                                 |
| Formula format            | Single select | -        | `LaTeX`            | Formula element format. Supports `LaTeX`, `MathML`, and `ASCII`.                                            |
| Table format              | Single select | -        | `HTML`             | Table element format. Supports `HTML`, `Markdown`, and `Image`.                                             |
| Chemical structure format | Single select | -        | `Image`            | Chemical structure element format. Currently only supports `Image`.                                         |
| Text cross-page merging   | Switch        | -        | `Off`              | Merge text blocks that span pages into continuous paragraphs.                                               |
| Table cross-page merging  | Switch        | -        | `Off`              | Merge tables that span pages into complete tables.                                                          |
| Title level recognition   | Switch        | -        | `Off`              | Recognize heading levels such as H1, H2, and H3.                                                            |
| Inline images             | Switch        | -        | `Off`              | Return images embedded in text paragraphs.                                                                  |
| Table images              | Switch        | -        | `On`               | Return images embedded in table cells.                                                                      |
| Image understanding       | Switch        | -        | `On`               | Generate semantic and structured descriptions for images in the document.                                   |
| Keep headers and footers  | Switch        | -        | `Off`              | Keep page headers and footers when enabled.                                                                 |

### Output variables

| Variable       | Type  | Description                                                                                                                            |
| -------------- | ----- | -------------------------------------------------------------------------------------------------------------------------------------- |
| Parsed results | array | Each input file maps to one result and results are returned in input order. Each item includes `markdown`, `json`, and `error` fields. |

#### Result fields

| Field      | Type   | Description                                                                                                 |
| ---------- | ------ | ----------------------------------------------------------------------------------------------------------- |
| `markdown` | string | Full parsed content in Markdown format. Empty string if `Markdown` output is not selected or parsing fails. |
| `json`     | object | Parsed result in JSON format. Empty object if `JSON` output is not selected or parsing fails.               |
| `error`    | string | Error message for the current file. Empty string when parsing succeeds.                                     |

## Notes

* FastGPT passes selected files as download URLs. The plugin downloads the file first, then sends it to the SoMark parsing service.
* If the file URL contains a `filename` query parameter, the plugin uses it first to avoid losing suffixes such as `.pdf` and `.docx` from temporary download URLs.
