> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sit.somark.ai/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/acm-a376ab31/91gelURAOKTgoQAe/images/fastgpt-%E6%B7%BB%E5%8A%A0%E6%8F%92%E4%BB%B6.webp?fit=max&auto=format&n=91gelURAOKTgoQAe&q=85&s=4dad17b30d551e9117d947136cbb6197" alt="Add the SoMark plugin in FastGPT" width="1798" height="984" data-path="images/fastgpt-添加插件.webp" />
  </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.ai/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 Studio to get your API key](https://somark.ai/Studio/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/acm-a376ab31/91gelURAOKTgoQAe/images/fastgpt-%E6%BF%80%E6%B4%BB%E6%8F%92%E4%BB%B6.webp?fit=max&auto=format&n=91gelURAOKTgoQAe&q=85&s=58699edd485b7a180e79bd863273daf6" alt="Activate the SoMark plugin in FastGPT" width="962" height="846" data-path="images/fastgpt-激活插件.webp" />
  </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/acm-a376ab31/91gelURAOKTgoQAe/images/fastgpt-%E6%9E%84%E5%BB%BA%E5%B7%A5%E4%BD%9C%E6%B5%81.webp?fit=max&auto=format&n=91gelURAOKTgoQAe&q=85&s=c5f959b7d83217df1447f3fc5b2fa031" alt="Build a FastGPT workflow with SoMark" width="2044" height="952" data-path="images/fastgpt-构建工作流.webp" />

    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/acm-a376ab31/91gelURAOKTgoQAe/images/fastgpt-%E8%BF%90%E8%A1%8C%E9%A2%84%E8%A7%88.webp?fit=max&auto=format&n=91gelURAOKTgoQAe&q=85&s=94a24ba8400060b27e8073c73d67d1dc" alt="Run a FastGPT preview with SoMark" width="878" height="1442" data-path="images/fastgpt-运行预览.webp" />
  </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.
