1
安装 SDK
SoMark 提供 Python 和 JavaScript 两个实现。
2
初始化客户端
最简单的方式是在初始化时直接传入 API Key。
3
先完成一次同步解析
先拿一个文件跑通结果,再决定要不要补充格式、配置和后处理逻辑。
4
大文件改用异步任务
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
使用 SoMark SDK 在 Python 或 JavaScript 项目里完成文档解析集成。
安装 SDK
pip install somark
npm install somark-js
初始化客户端
from somark import SoMark
client = SoMark(api_key="sk-your-api-key")
import { SoMark } from 'somark-js'
const client = new SoMark({ apiKey: 'sk-your-api-key' })
先完成一次同步解析
response = client.parser.parse(
file="./document.pdf",
formats=["md", "json"],
)
response.save("./document.md")
const response = await client.parser.parse({
file: './document.pdf',
formats: ['md', 'json'],
})
await response.save('./document.md')
大文件改用异步任务
task = client.parser.parse_async(file="./large.pdf", formats=["md"])
result = task.wait()
result.save("./large.md")
const task = await client.parser.parseAsync({
file: './large.pdf',
formats: ['md'],
})
const result = await task.wait()
await result.save('./large.md')
