Skip to main content
CLI is best when you want to process files immediately. SDK is best when you want to put parsing inside your own program. Two paths, one goal. If you want the positioning summary first, return to the SoMark CLI & SDK overview.

1. Installation

SoMark has Python and JavaScript implementations. Install the package for the language you use. Both packages provide the SDK and the somark CLI command. As a baseline, Python requires 3.10+ and Node.js requires 18+.
If the somark command cannot be found, the package is usually installed correctly but the command directory is not in your PATH. Python users can try python -m somark.cli.main --help; Node users can try npx somark-js --help first. Once it runs, you can clean up your global command path.
If you install both the Python and JS versions, the CLI uses whichever one was installed first. The later installation skips CLI setup when it sees that the command already exists. To see which implementation is active, run somark --help; the footer shows [PY] or [JS].

2. Authentication and configuration

Remote parsing and usage queries require an API key. Local PDF processing and SoMarkDown preview do not. You can save configuration through the CLI, or pass parameters directly when initializing the SDK.
If your project already uses .env, put SOMARK_API_KEY=sk-your-api-key there and load it with python-dotenv, dotenv, or your own startup script. SoMark reads the environment variable itself; it does not decide how your .env file is loaded. Do not commit .env to Git.
Entry points: somark login, somark config ..., or configuration through command flags and environment variables.Command flags / environment variables
SOMARK_PARSE_MAX_CONCURRENCY must stay at 1 by default. The official default parsing concurrency for all users is also 1; only users who have been explicitly approved for higher concurrency should set it to 2 or above. When the CLI detects 2 or above, it reports this through the warning channel. This is a local warning, not an API warning.
Config file fieldsPriority: command flags > environment variables > config file > defaults.

3. Warnings

SoMark warnings fall into two categories: API warnings and local warnings. API warnings come from the top-level response field warnings: List[str], at the same level as code and message. Local warnings come from SDK or CLI runtime checks, such as a batch parsing concurrency setting above the default quota. The CLI shows SoMark warnings by default. Use the global --no-warnings option when you need quiet output:
CLI
--no-warnings only hides warning display. It does not change command results, exit codes, or remove the warnings field from SDK response objects. The SDK shows warnings through the native warning channel of each language by default, and also keeps warning strings in the response object’s warnings field. An empty array means there are no warnings.

4. Parsing

Parsing is the main task for SoMark SDK + CLI. You give SoMark a file, and it returns Markdown, JSON, or a ZIP download URL. The default output format is md, which corresponds to the API’s markdown output. There are two usage patterns: sync parsing and async parsing. Sync parsing is for “I need the result now” scenarios. The CLI or SDK sends the file to /parse/sync and waits for the server to return the result. It takes little code, has low mental overhead, and works well for single files, scripts, debugging, and small to medium documents. The tradeoff is direct: the larger the file, the longer you wait. Async parsing is for large files, batch processing, and background tasks. You send the file to /parse/async, immediately get a task_id, then query /parse/async_check with that task_id for progress. The CLI --wait option and SDK task.wait() helper are polling wrappers. This is a better fit for queues, scheduled jobs, and server-side flows. Sync parsing flow One request returns the result directly. Best for scripts, debugging, and small to medium files.
Async parsing flow Submit the task first, then query status by task_id. Best for large files, batch processing, and background queues.

4.1 Sync parsing

Sync parsing is the easiest way to prove the flow works: provide one file, wait for the result, and save it locally. Start with md, check the content quality, then add json, zip, or page feature options as needed.
Entry point: somark parse [files...].Return handling--out only means the output target. It does not mean “create the directory for me” or “treat this filename as a template”. This makes script behavior easier to predict.Multi-file execution

4.2 Async parsing

Async parsing is best for large files and batch processing. Submit first, get a task_id, then poll until success or failure. A 3 to 5 second polling interval is recommended; avoid polling too frequently, because the server needs time to work.
Entry points: somark parse [files...] --async to submit tasks; somark parse --task-id task_xxx to query a task.Submit task: somark parse [files...] --asyncWhen submitting multiple files asynchronously, each file receives its own task_id. The CLI shows each file’s existence, submission status, duration, and task ID.Query / wait task: somark parse --task-id task_xxx

5. Usage query

Usage query returns the remaining quota and dashboard URL for the current API key. It can also quickly verify whether the API key is valid.
Entry point: somark usage.Command parametersOutput fields

6. SoMarkDown service

The SoMarkDown service starts a local preview server and opens a .md or .smd file in the browser. It does not require an API key and does not consume quota. The underlying rendering capability comes from SoMarkAI/SoMarkDown; go there when you need syntax and renderer details.
The JavaScript SDK also exports SoMarkDown. It does not start a local HTTP service; instead, it renders Markdown / SoMarkDown strings directly to HTML. Use it in Node services, custom frontends, or small tools when you need the rendered result.
JavaScript
Entry point: somark preview [file].Output fieldsStop the service by pressing Ctrl+C in the terminal.

7. PDF processing

PDF processing currently provides local PDF-to-image conversion. Use it for previews, page layout debugging, or handing PDF pages to another visual processing flow. The Python-side local PDF capability is based on SoMarkAI/SoPDF.
Entry point: somark pdf toimg <file>.Output fields

8. Doctor auto-fix

Doctor checks installation status, network access, API key configuration, and local preview assets. It is a command-line health check. It will not fix everything, but it catches many basic failures.
CLI
Doctor is a CLI maintenance command; the SDK does not provide a corresponding resource. Programs usually do not need it. Use it when commands fail to run, preview does not open, or network status is uncertain. For lower-level endpoints, fields, and response structures, see API Reference. It is generated from the same interface specification: less hand-written text, more reliability.