LensPreview: Untern Lens is in Preview: credits and limits apply

Docs

Docs

CLI reference

Commands, flags, exit codes and JSON output of the CLI.

This reference is generated from the machine-readable schema of the CLI.

CLI: untern-parsing, version 0.1.0.

Global flags

FlagEnvironment variableTypeDefaultDescription
--jsonUNTERN_PARSING_OUTPUTbooleanPrint exactly one JSON document on stdout; errors as one JSON line on stderr.
--ndjsonUNTERN_PARSING_OUTPUTbooleanPrint an NDJSON event stream on stdout; the last line is a result or error event.
--progressbooleanWith --json: also write NDJSON progress events on stderr.
--api-urlUNTERN_PARSING_API_URLstringAPI base URL (https; http only for localhost).
--profileUNTERN_PARSING_PROFILEstringdefaultProfile for settings and stored login.
--request-timeoutUNTERN_PARSING_REQUEST_TIMEOUTinteger30 sPer-request HTTP timeout.
--verbosebooleanLog requests (method, path, status, duration, request id) on stderr; never bodies or credentials.
--quietbooleanText mode: no notes on stderr.
--no-colorNO_COLORbooleanText mode: no colour.
--versionbooleanSame as the version command.

Environment variables

NameSecretDescription
NO_COLORNoDisable colour in text mode.
UNTERN_PARSING_API_URLNoAPI base URL (https; http only for localhost).
UNTERN_PARSING_CONFIG_DIRNoDirectory of config.toml (default: the user config directory).
UNTERN_PARSING_CREDENTIAL_STORENoWhere auth login stores credentials: auto (OS keychain, else a 0600 file), keychain or file.
UNTERN_PARSING_DATA_DIRNoDirectory of the credentials file (default: the user data directory).
UNTERN_PARSING_DEBUGNoSet to 1 to print tracebacks of CLI bugs locally (never in CI logs).
UNTERN_PARSING_OIDC_CLIENT_IDNoOAuth client for auth login (default lens-cli).
UNTERN_PARSING_OIDC_ISSUERNoKeycloak issuer for auth login (default: discovered from the API, RFC 9728).
UNTERN_PARSING_OUTPUTNoDefault output mode: text, json or ndjson.
UNTERN_PARSING_PROFILENoProfile in the config file and the credential store (default: default).
UNTERN_PARSING_REQUEST_TIMEOUTNoPer-request HTTP timeout in seconds (default 30).
UNTERN_PARSING_TOKENYesAPI key (ulk_…) from the portal's API keys page, or an access token; sent as Authorization: Bearer. Wins over a stored login. Never printed.

Commands

untern-parsing auth login

Sign in with a device code, or store an API key read from stdin.

Without flags: OAuth device authorization grant on client lens-cli. The sign-in URL and code go to stderr (event auth.device_code in --ndjson/--json); the CLI polls until the browser approves, then stores the login in the OS keychain or a 0600 file. With --with-token: reads one API key from stdin, checks it with the API and stores it. A key is never accepted as an argument.

  • JSON output: AuthStatus
  • NDJSON events: auth.device_code, result, error
  • Scopes: None
  • Network: Yes
  • Side effects: writes_config
  • Idempotent: Yes
  • Exit codes: 0, 2, 3, 4, 8, 9, 10, 7

Flags

FlagTypeDefaultDescription
--with-tokenbooleanRead an API key from stdin instead of signing in.
--openbooleanOpen the sign-in page in the default browser.
--timeoutnumber600 sGive up waiting for the browser after this long.
--scopestringOAuth scope to request (repeatable); default: openid offline_access.

Examples

Sign in through the browser

sh
untern-parsing auth login

Store an API key from an environment variable

sh
untern-parsing auth login --with-token --json

untern-parsing auth logout

Delete the stored login of the profile.

Removes the profile's login from the keychain and the credentials file. --revoke also revokes an OIDC refresh token at the identity provider. UNTERN_PARSING_TOKEN is not touched (the command says when it is still set).

  • JSON output: AuthStatus
  • NDJSON events: result, error
  • Scopes: None
  • Network: No
  • Side effects: writes_config
  • Idempotent: Yes
  • Exit codes: 0, 2, 10

Flags

FlagTypeDefaultDescription
--revokebooleanAlso revoke the refresh token at the identity provider.
--dry-runbooleanReport what would be deleted; delete nothing.

Examples

Sign out

sh
untern-parsing auth logout --json

untern-parsing auth status

Show which credential is used and whom it belongs to.

Checks the credential with the API (/api/me when the server offers it). UNTERN_PARSING_TOKEN wins over a stored login. --offline reports only the local source (authenticated then means 'a credential was found', unverified). Never prints the credential; API keys show as ulk_…last4.

  • JSON output: AuthStatus
  • NDJSON events: result, error
  • Scopes: None
  • Network: Yes
  • Side effects: none
  • Idempotent: Yes
  • MCP tool: whoami
  • Exit codes: 0, 2, 3, 4, 8, 9, 10

Flags

FlagTypeDefaultDescription
--offlinebooleanDo not contact the API.

Examples

Is this environment signed in?

sh
untern-parsing auth status --json

Which credential would be used, offline

sh
untern-parsing auth status --offline --json

untern-parsing config get

Print one effective setting.

Text mode prints the bare value (empty when unset); --json prints a ConfigView holding that key only.

  • JSON output: ConfigView
  • NDJSON events: result, error
  • Scopes: None
  • Network: No
  • Side effects: none
  • Idempotent: Yes
  • Exit codes: 0, 2

Arguments

ArgumentTypeRequiredRepeatedDescription
KEYstringYesSetting name: api_url (API base URL for this profile.), output (Default output mode (text, json, ndjson).), request_timeout (Per-request HTTP timeout in seconds (1-600).)

Examples

Which API URL is used

sh
untern-parsing config get api_url

untern-parsing config list

Show the effective settings of the profile.

Each value is resolved flag > environment > profile > default. Secrets are never stored here; UNTERN_PARSING_TOKEN and logins are not shown.

  • JSON output: ConfigView
  • NDJSON events: result, error
  • Scopes: None
  • Network: No
  • Side effects: none
  • Idempotent: Yes
  • Exit codes: 0, 2

Examples

Settings of the default profile

sh
untern-parsing config list --json

untern-parsing config path

Print the config file path.

The file may not exist yet; config set creates it. Override the directory with UNTERN_PARSING_CONFIG_DIR.

  • JSON output: ConfigView
  • NDJSON events: result, error
  • Scopes: None
  • Network: No
  • Side effects: none
  • Idempotent: Yes
  • Exit codes: 0

Examples

Where the settings live

sh
untern-parsing config path

untern-parsing config set

Store a setting in the profile.

Validates the value (api_url must be https, or http on localhost; no credentials or query in the URL) and writes the per-user config file atomically.

  • JSON output: ConfigView
  • NDJSON events: result, error
  • Scopes: None
  • Network: No
  • Side effects: writes_config
  • Idempotent: Yes
  • Exit codes: 0, 2

Arguments

ArgumentTypeRequiredRepeatedDescription
KEYstringYesSetting name: api_url (API base URL for this profile.), output (Default output mode (text, json, ndjson).), request_timeout (Per-request HTTP timeout in seconds (1-600).)
VALUEstringYesNew value.

Examples

Point a local profile at a development API

sh
untern-parsing config set api_url http://127.0.0.1:8000 --profile local

untern-parsing config unset

Remove a setting from the profile.

Idempotent: removing a key that is not set succeeds and changes nothing.

  • JSON output: ConfigView
  • NDJSON events: result, error
  • Scopes: None
  • Network: No
  • Side effects: writes_config
  • Idempotent: Yes
  • Exit codes: 0, 2

Arguments

ArgumentTypeRequiredRepeatedDescription
KEYstringYesSetting name: api_url (API base URL for this profile.), output (Default output mode (text, json, ndjson).), request_timeout (Per-request HTTP timeout in seconds (1-600).)

Examples

Forget the stored output mode

sh
untern-parsing config unset output

untern-parsing doctor

Check settings, network, credential, scopes, contract and MCP before real work.

Runs local checks (settings file, API URL, credentials file mode, keychain, proxy) and, unless --offline, network checks (reachability, Cloudflare Access in front of the API, clock skew, contract version, credential with /api/me or a probe, scopes, expiry, /mcp, credits). Prints the report either way; exit 1 (doctor_failed, also on stderr in --json) when a check failed.

  • JSON output: DoctorReport
  • NDJSON events: result, error
  • Scopes: None
  • Network: Yes
  • Side effects: none
  • Idempotent: Yes
  • Exit codes: 0, 1, 2

Flags

FlagTypeDefaultDescription
--offlinebooleanOnly the local checks.

Examples

First call of an agent session

sh
untern-parsing doctor --json

Settings only, no network

sh
untern-parsing doctor --offline

untern-parsing estimate

Credits a parse would use, before running it.

Sends metadata only (name, size, type, sha256) to POST /api/billing/estimate and prints the server's per-file ceilings (credits), likely cost (credits_expected) and total, valid until quote_expires_at (15 minutes); cached re-parses can be free, and an item the server cannot price has credits null and an error (complete: false). A --mode the server or the plan does not offer is refused first (exit 11 mode_unavailable, exit 13 mode_not_in_plan); --preset is priced by its mode. Exit 11 while the API does not offer estimates, or billing_unavailable while billing is off.

  • JSON output: Estimate
  • NDJSON events: result, error
  • Scopes: documents:read
  • Network: Yes
  • Side effects: none
  • Idempotent: Yes
  • MCP tool: estimate_credits
  • Exit codes: 0, 2, 3, 4, 8, 9, 10, 11, 13

Arguments

ArgumentTypeRequiredRepeatedDescription
inputpathYesYesFiles or directories (directories are walked).

Flags

FlagTypeDefaultDescription
--modestringParse mode, one the server enables (see doctor).
--presetstringPrice with a document-type preset's mode (from the server).
--pagesstringPages to parse, for example 1-5,8.

Examples

Cost of a folder before parsing it

sh
untern-parsing estimate ./invoices --json

untern-parsing extract

Extract schema fields with evidence from a parsed job, a result or a file.

SOURCE is a completed job id, a file or an https URL (parsed first, then waited for); --result-id names a result instead. --schema is a JSON Schema file in the supported subset (checked locally, exit 2 invalid_schema with details.path) or a server schema NAME@VERSION from schemas list. GET /api/schemas runs first, so an API without extractions is exit 11 before any upload. POST /api/extractions with an Idempotency-Key; --wait long-polls GET /api/extractions/{id} until it finishes (failed: exit 1 extraction_failed; deadline: exit 7, the extraction keeps running). --max-credits is a ceiling for the parse and the extraction together (the API refuses above it: exit 13); credits from the API's X-Credits-* headers are in the output. --dry-run is offline and prints the plan.

  • JSON output: Extraction
  • NDJSON events: item.uploading, item.submitted, job.status, extraction.status, file.written, warning, result, error
  • Scopes: documents:write
  • Network: Yes
  • Side effects: creates_jobs
  • Idempotent: No
  • MCP tool: extract_fields
  • Exit codes: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13

Arguments

ArgumentTypeRequiredRepeatedDescription
sourcestringNoA completed job id, a file or an https URL (omit with --result-id).

Flags

FlagTypeDefaultDescription
--schemastringJSON Schema file (subset of CLI-CONTRACT §5.6) or a server schema NAME@VERSION.
--result-idstringExtract from this result id instead of a job or file.
--instructionsstringExtra guidance for the model (at most 4000 characters).
--instructions-filepathRead the instructions from this UTF-8 file.
--no-require-evidencebooleanKeep values without a verified quote (at lower confidence) instead of dropping them.
--idempotency-keystringSame key, same request: the same extraction comes back (a file's parse uses :parse).
--max-creditsintegerCeiling for this call (parse and extraction); exit 13 above it.
--waitbooleanWait until the extraction finishes.
--timeoutnumber600 sDeadline for the parse of a file and, with --wait, the extraction.
--output-dirpathAlso write the Extraction as .extraction.json into this directory.
--dry-runbooleanCheck the schema and inputs; send nothing.

Examples

Invoice fields from a parsed job, waiting for the answer

sh
untern-parsing extract <job-id> --schema invoice@1 --wait --json

Parse a file and extract with your own schema

sh
untern-parsing extract contract.pdf --schema fields.json --wait --max-credits 200 --json

Check a schema offline

sh
untern-parsing extract <job-id> --schema fields.json --dry-run --json

untern-parsing extractions get

Show an extraction; with --wait, wait until it finishes.

GET /api/extractions/{id} (long poll with --wait). Without --wait the exit code is 0 whatever the status; with --wait a failed extraction is exit 1 extraction_failed and the deadline exit 7 (the extraction keeps running).

  • JSON output: Extraction
  • NDJSON events: extraction.status, result, error
  • Scopes: documents:read
  • Network: Yes
  • Side effects: none
  • Idempotent: Yes
  • MCP tool: get_extraction
  • Exit codes: 0, 1, 3, 4, 5, 7, 8, 9, 10, 11

Arguments

ArgumentTypeRequiredRepeatedDescription
idstringYesExtraction id.

Flags

FlagTypeDefaultDescription
--waitbooleanWait until the extraction finishes.
--timeoutnumber600 sWith --wait: deadline.

Examples

Wait for an extraction

sh
untern-parsing extractions get <extraction-id> --wait --json

untern-parsing jobs cancel

Cancel jobs that have not started.

POST /api/tasks/{task_id}/cancel. A pending job ends failed with error.code cancelled; a running job answers not_cancellable and a finished one conflict (exit 6, details.status). Stops at the first refusal and prints the jobs already cancelled. Exit 11 on an API without cancel.

  • JSON output: JobList
  • NDJSON events: result, error
  • Scopes: documents:write
  • Network: Yes
  • Side effects: cancels_jobs
  • Idempotent: Yes
  • MCP tool: cancel_job
  • Exit codes: 0, 3, 4, 5, 6, 9, 10, 11

Arguments

ArgumentTypeRequiredRepeatedDescription
idstringYesYesJob ids.

Examples

Cancel a queued job

sh
untern-parsing jobs cancel <job-id> --json

untern-parsing jobs get

Show one job: status, result id, error, source.

GET /api/tasks/{task_id}, or the status route on an API without it. Exit 0 whatever the job's status; read status and error.

  • JSON output: Job
  • NDJSON events: result, error
  • Scopes: documents:read
  • Network: Yes
  • Side effects: none
  • Idempotent: Yes
  • MCP tool: get_job
  • Exit codes: 0, 3, 4, 5, 9, 10

Arguments

ArgumentTypeRequiredRepeatedDescription
idstringYesJob id (the task_id parse printed).

Examples

Status of a job

sh
untern-parsing jobs get <job-id> --json

untern-parsing jobs list

List this credential's parse jobs, newest first.

GET /api/tasks with an opaque cursor. --all follows cursors up to --max-items; with --ndjson each job is an item event and the final result carries only count and next_cursor. Exit 11 on an API without the task list.

  • JSON output: JobList
  • NDJSON events: item, result, error
  • Scopes: documents:read
  • Network: Yes
  • Side effects: none
  • Idempotent: Yes
  • MCP tool: list_jobs
  • Exit codes: 0, 2, 3, 4, 8, 9, 10, 11

Flags

FlagTypeDefaultDescription
--statusstringOnly jobs in this status (repeatable).
--limitinteger20Page size, 1-100.
--cursorstringnext_cursor of the previous page.
--allbooleanFollow cursors to the end.
--max-itemsinteger10000With --all: stop after this many jobs.

Examples

Failed jobs

sh
untern-parsing jobs list --status failed --json

Every job as a stream

sh
untern-parsing jobs list --all --ndjson

untern-parsing jobs wait

Wait until jobs finish; exit 0 completed, 1 failed, 7 timeout.

Uses the API's long poll for one job and polls with backoff (1 s x1.5, at most 10 s) for several, or every --interval seconds. --timeout 0 checks once. A timeout never cancels work: the jobs keep running and jobs wait can be called again.

  • JSON output: JobList
  • NDJSON events: job.status, result, error
  • Scopes: documents:read
  • Network: Yes
  • Side effects: none
  • Idempotent: Yes
  • MCP tool: wait_for_job
  • Exit codes: 0, 1, 3, 4, 5, 7, 8, 9, 10

Arguments

ArgumentTypeRequiredRepeatedDescription
idstringYesYesJob ids.

Flags

FlagTypeDefaultDescription
--timeoutnumber600 sOverall deadline; 0 checks once.
--intervalnumberFixed polling interval instead of backoff and long poll.

Examples

Wait up to 2 minutes

sh
untern-parsing jobs wait <job-id> --timeout 120 --json

untern-parsing parse

Parse files, folders or https URLs; optionally wait and download the results.

One job per input (POST /api/files/process with an Idempotency-Key). Without --wait, exit 0 once every input is accepted. With --wait, poll until the jobs finish or --timeout, then write each --format (md, json, html, chunks, zip) into --output-dir with the API's defaults (en, its chunk size). --max-credits asks for an estimate first and submits nothing above it (exit 13). Prints the ParseRun even when an input failed; the error is the last stderr line. --dry-run is offline.

  • JSON output: ParseRun
  • NDJSON events: item.planned, item.uploading, item.submitted, job.status, file.written, item.completed, item.failed, warning, result, error
  • Scopes: documents:write
  • Network: Yes
  • Side effects: creates_jobs
  • Idempotent: No
  • MCP tool: parse_document
  • Exit codes: 0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 13

Arguments

ArgumentTypeRequiredRepeatedDescription
inputpathYesYesFiles, folders or https URLs (folders: top level, or every level with --recursive).

Flags

FlagTypeDefaultDescription
--modestringParse mode, one the server enables (see doctor).
--presetstringDocument-type preset from the server (sets mode and options; see the modes route).
--pagesstringPages to parse, server syntax, for example 1-5,8.
--recursivebooleanWalk folders into every level.
--includestringIn folders: only files matching this glob (repeatable).
--excludestringIn folders: skip files matching this glob (repeatable).
--projectstringProject name stored with the file.
--groupstringSub-group stored with the file.
--force-reparsebooleanParse again even when a cached result exists.
--version-checkbooleanRe-parse when the cached result is from an older parser.
--idempotency-keystringMakes reruns safe: one input uses K, several use K/.
--max-creditsintegerRefuse (exit 13, nothing sent) when the estimate is above N; sent with each job.
--waitbooleanWait for the jobs to finish.
--timeoutnumber600 sWith --wait: overall deadline; 0 checks once.
--formatstringWith --wait: download this format (repeatable; md, json, html, chunks, zip).
--output-dirpathWhere --format writes . (default ./untern-parsing-out).
--concurrencyinteger4Uploads in parallel, 1-16.
--dry-runbooleanValidate and print the plan; no network, no credential.

Examples

Parse a PDF and save Markdown

sh
untern-parsing parse report.pdf --wait --format md --output-dir out --json

Submit a folder and return at once

sh
untern-parsing parse ./invoices --recursive --json

Safe rerun in CI with a credit ceiling

sh
untern-parsing parse a.pdf --idempotency-key ci-run-0042 --max-credits 200 --json

See what would be sent

sh
untern-parsing parse ./docs --dry-run --json

untern-parsing result get

Download a completed job's result as Markdown, Document JSON, HTML, chunks or ZIP.

Looks the job up, then reads one route: md …/download/markdown, json …/document.json (the Document as the server wrote it; its schema_version is checked), html …/document.html (--lang), chunks …/chunks (one chunk per line, --max-chunk-chars), zip …/download/zip. Without a path the artifact goes to stdout as is; a ZIP needs -o or --output-dir and is never extracted. An API without the document routes is exit 11; a result too large for json, html or chunks is result_too_large (exit 11). A job that has not completed is not_ready (exit 6) unless --wait.

  • JSON output: ResultFiles
  • NDJSON events: job.status, file.written, warning, result, error
  • Scopes: documents:read
  • Network: Yes
  • Side effects: writes_local_files
  • Idempotent: Yes
  • MCP tool: read_result
  • Exit codes: 0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11

Arguments

ArgumentTypeRequiredRepeatedDescription
idstringYesJob id.

Flags

FlagTypeDefaultDescription
--formatstringmdResult format: md, json (Document), html, chunks (NDJSON) or zip.
--outputpathWrite to this file.
--output-dirpathWrite . into this directory.
--langstringWith --format html: language of the page (BCP 47, default en).
--max-chunk-charsintegerWith --format chunks: largest chunk in characters (200-4000; default the API's).
--waitbooleanWait for the job first if it is still running.
--timeoutnumber600 sWith --wait: deadline.

Examples

Markdown to stdout

sh
untern-parsing result get <job-id> --format md

Document JSON to a file

sh
untern-parsing result get <job-id> --format json -o doc.json --json

Chunks for a RAG index, one per line

sh
untern-parsing result get <job-id> --format chunks --max-chunk-chars 1000

ZIP with images into a folder

sh
untern-parsing result get <job-id> --format zip --output-dir out --json

untern-parsing schema

Print the machine-readable description of every command, flag, model and code.

Always JSON, offline and deterministic. Contains global flags, environment variables, config keys, exit codes, error codes (with origin server or local and a hint), each command's arguments, flags, output model, exit codes, scopes, side effects and examples, and the JSON Schema of every output model under $defs.

  • NDJSON events: result, error
  • Scopes: None
  • Network: No
  • Side effects: none
  • Idempotent: Yes
  • Exit codes: 0, 1, 2

Flags

FlagTypeDefaultDescription
--commandstringOnly this command, for example "jobs wait".
--kindstringOnly the JSON Schema of the model with this kind, for example job.
--checkpathCompare with this file instead of printing; exit 1 (stale_file) when it differs.

Examples

Whole description

sh
untern-parsing schema

JSON Schema of the job model

sh
untern-parsing schema --kind job

CI: is the committed copy current?

sh
untern-parsing schema --check contracts/cli-schema.json

untern-parsing schemas list

List the server schemas extract accepts as --schema NAME@VERSION.

GET /api/schemas: each schema's ref, title, description and JSON Schema.

  • JSON output: SchemaList
  • NDJSON events: result, error
  • Scopes: documents:read
  • Network: Yes
  • Side effects: none
  • Idempotent: Yes
  • MCP tool: list_schemas
  • Exit codes: 0, 3, 4, 8, 9, 10, 11

Examples

Server schemas

sh
untern-parsing schemas list --json

untern-parsing setup

Configure every agent client found here (plugin, remote MCP, CLI on PATH), then run doctor.

Detects Claude Code, Codex, Cursor, VS Code, Claude Desktop, Windsurf, CI and the terminal from executables on PATH and config directories under HOME (never starting a client), and ensures one entry named untern-lens per client: the untern-parsing plugin where plugins exist, the remote MCP config otherwise, the CLI on PATH for terminals, a snippet for clients it cannot configure. Configs reference UNTERN_PARSING_TOKEN (VS Code asks once and stores the key itself); a key read from stdin or a hidden prompt goes to the credential store, never into a file. Idempotent; every change is recorded and --uninstall removes exactly those.

  • JSON output: SetupResult
  • NDJSON events: result, error
  • Scopes: None
  • Network: Yes
  • Side effects: writes_config
  • Idempotent: Yes
  • Exit codes: 0, 1, 2, 3

Flags

FlagTypeDefaultDescription
--forstringautoTargets: auto (default) or a comma-separated list of claude-code, codex, cursor, vscode, claude-desktop, windsurf, mcp-json, ci, python, terminal.
--yesbooleanNever prompt (implied when stdin or stderr is not a terminal, and in CI).
--dry-runbooleanPrint the plan; write nothing, run no client command.
--uninstallbooleanRemove exactly what earlier setups added.
--purge-credentialsbooleanWith --uninstall: also delete the stored key.
--marketplacestringPlugin marketplace source (path or owner/repo).

Examples

See what setup would do

sh
untern-parsing setup --dry-run --json

Configure Claude Code and Codex only

sh
untern-parsing setup --for claude-code,codex --yes

Undo everything setup did

sh
untern-parsing setup --uninstall

untern-parsing usage

Show the plan, credits used and left, and this key's budget.

Reads GET /api/me/usage: credits, or pages left on page-capped plans (Free), the token's budget and the launch stage (Preview, from the API's preview block). Numbers come from the API; the CLI never computes prices. Exit 11 while the API does not offer usage, or billing_unavailable while billing is off on the server.

  • JSON output: Usage
  • NDJSON events: result, error
  • Scopes: documents:read
  • Network: Yes
  • Side effects: none
  • Idempotent: Yes
  • MCP tool: get_usage
  • Exit codes: 0, 2, 3, 4, 8, 9, 10, 11

Flags

FlagTypeDefaultDescription
--periodstringcurrentWhich billing period.

Examples

Credits left

sh
untern-parsing usage --json

untern-parsing version

Print the CLI, API contract, SDK and Python versions, and the launch stage.

Offline. The api_contract field names the OpenAPI contract version this CLI was built from; compare it with the server using openapi --check when that command is available.

  • JSON output: VersionInfo
  • NDJSON events: result, error
  • Scopes: None
  • Network: No
  • Side effects: none
  • Idempotent: Yes
  • Exit codes: 0

Examples

Versions as JSON

sh
untern-parsing version --json

Exit codes

CodeNameRetryableDescription
0okNoSuccess.
1failedNoThe command ran and the outcome is negative (a job failed, a gate failed, a check failed). Read the result's items or checks; do not resubmit blindly.
2usageNoWrong command, flag or input. Fix the call.
3auth_requiredNoNo valid credential. Set UNTERN_PARSING_TOKEN or run auth login.
4permissionNoThe credential is valid but not allowed to do this (missing scope or blocked at the edge).
5not_foundNoThe job, file or result does not exist, or it expired.
6conflictNoThe request conflicts with the current state (not ready yet, idempotency key reused).
7timeoutYes--timeout was reached. Work continues on the server; wait for the job again.
8unavailableYesRate limited or the service is busy. Retry after retry_after_s.
9serverNoThe server failed or answered outside the contract. Report request_id.
10networkYesThe API could not be reached (DNS, connect, TLS, proxy).
11unsupportedNoThe server does not offer this operation or format. Use another format or a newer server.
12internalNoA bug in the CLI. Report the incident id.
13creditsNoOut of credits or pages, over a budget or a Preview cap, above --max-credits, or the parse mode is not in the plan. Run usage; nothing more was submitted.
130interruptedNoStopped by SIGINT or SIGTERM. Jobs already submitted keep running; their ids were printed.

Error codes

CodeExit codeRetryableDescriptionHint
auth_denied3NoThe device login was denied in the browser.
auth_required3NoNo credential: UNTERN_PARSING_TOKEN is not set and no login is stored for the profile.Create an API key in the Untern Lens portal (API keys page) and set UNTERN_PARSING_TOKEN, or run: untern-parsing auth login
auth_timeout3NoThe device login code expired before approval.
bad_response9NoThe server's answer could not be parsed or broke the contract.
billing_unavailable11NoBilling is off on this server: it offers no usage or estimate, and charges nothing.Parse without --max-credits checks; usage and estimate work once billing is on.
blocked_by_access4NoA Cloudflare Access login page answered instead of the API.Check UNTERN_PARSING_API_URL; the API hostname must not be behind Access.
budget_exceeded13NoThis credential's credit budget is used up.Run untern-parsing usage; raise the key's budget in the portal or use another key.
busy8YesThe parser is at capacity; wait retry_after_s.
capacity_limit13NoA capacity cap of the plan's tier is reached (details.scope, details.resets_at).Run untern-parsing usage; follow details.next_step or wait for details.resets_at.
cli_internal_error12NoA bug in the CLI; the message carries an incident id.Report the incident id; set UNTERN_PARSING_DEBUG=1 to see the traceback locally.
config_invalid2NoA setting is missing or invalid (config file, env var or flag).
conflict6NoThe request conflicts with the resource's state.
contract_mismatch9NoThe server's API contract does not match this CLI.
doctor_failed1NoAt least one doctor check failed; see checks[].
extraction_failed1NoAn extraction finished with status failed.
file_not_found2NoAn input path does not exist or is not readable.
forbidden4NoThe credential may not do this.
gone5NoThe result expired; parse the document again.
idempotency_conflict6NoThe idempotency key was already used for a different request.Use a new --idempotency-key.
insufficient_scope4NoThe credential lacks the scope named in details.missing_scope.Create a key with that access in the portal (API keys page).
insufficient_storage8YesThe server is out of storage.
internal_error9NoThe server failed; report request_id.
interrupted130NoStopped by SIGINT or SIGTERM.
invalid_input2NoThe request or an input value is invalid.
invalid_schema2NoThe extraction schema is outside the supported subset, or the server schema is unknown (details.path; checked locally before sending, and by the API with 422).Fix the node at details.path (CLI-CONTRACT §5.6), or pick a ref from untern-parsing schemas list.
job_failed1NoA parse job finished with status failed.
length_required2NoThe upload had no Content-Length.
limit_exceeded13NoThe file has more pages than the plan allows in one file.Parse fewer pages (--pages), split the file, or upgrade the plan in the Untern Lens portal (Plan and billing page).
max_credits_exceeded13NoThe estimate is above --max-credits; nothing was submitted.Raise --max-credits, or reduce the work (--pages, another --mode, fewer files).
metadata_required2NoAn estimate item named a file_id that has no result in this mode yet (item error).Estimate the local file instead, so its metadata is sent.
mode_not_in_plan13NoThe parse mode is not included in the account's plan (details.mode, details.allowed_modes).Use a mode from details.allowed_modes, or upgrade the plan in the Untern Lens portal (Plan and billing page).
mode_unavailable11NoThe parse mode is not enabled on this server (details.mode, details.available).Pick one of details.available, or run untern-parsing doctor to list the server's modes.
network_error10YesThe API could not be reached.
not_cancellable6NoThe job is already running and cannot be stopped (details.status).Wait for it: untern-parsing jobs wait
not_found5NoNo such job, file or result for this credential.
not_ready6YesThe job has not completed yet.Run: untern-parsing jobs wait
partial_failure1NoSome inputs failed; see items[].
payload_too_large2NoThe file is larger than the upload limit.
payment_required13NoNo credits left on the plan.Run untern-parsing usage; the account owner adds credits in the portal.
preview_limit13NoA Preview cap is reached: details.scope is key, account or global; details.resets_at says when it renews.Run untern-parsing usage; follow details.next_step (raise the key's cap, ask for more in the portal, or wait for details.resets_at).
proxy_error10YesThe HTTPS proxy refused or failed the connection.
quality_gate_failed1NoA --min-* quality threshold was not met.
quota_exceeded13NoThe plan's limit for this period is reached.Run untern-parsing usage; wait for the next period or change the plan in the portal.
rate_limited8YesToo many requests; wait retry_after_s.
result_too_large11NoThis result is too large for the requested format.Use --format md or --format zip.
service_unavailable8YesA service behind the API is unavailable (for extraction: no model provider is configured on this server).Retry later; if it persists, the server's operator must configure the service.
setup_incomplete1NoSetup could not finish every action.
spend_cap_reached13NoThe account's monthly spending cap would be passed.Run untern-parsing usage; the account owner raises the cap in the portal.
stale_file1NoA generated file differs from what this version produces (schema --check).Regenerate it: untern-parsing schema > contracts/cli-schema.json
storage_unavailable8YesObject storage is unavailable.
timeout7Yes--timeout was reached; the work continues on the server.Run: untern-parsing jobs wait
tls_error10YesThe TLS handshake or certificate check failed.
token_expired3NoThe stored login expired and could not be refreshed.Run: untern-parsing auth login
unauthenticated3NoThe API rejected the credential (revoked, expired or mistyped).Create a new API key in the portal and set UNTERN_PARSING_TOKEN, or run: untern-parsing auth login
unsupported11NoThe server does not offer this operation or format (details.operation).
unsupported_media_type2NoThe file type is not supported.
upstream_unavailable8YesThe API or a proxy in front of it answered 502 or 504 without an error code.
usage2NoUnknown command or flag, or a missing argument.

Output models

AuthStatus

PropertyTypeRequiredDescription
kind"auth_status"NoDefault: auth_status.
schema_version"1"NoDefault: 1.
authenticatedbooleanYes
sourcestring, one of env, keychain, file, token, noneYes
credentialstring, one of api_key, oidc, unknown or nullNoDefault: null.
key_hintstring or nullNo"ulk_…AB12" for API keys only. Default: null.
principalstring or nullNoDefault: null.
namestring or nullNoDefault: null.
emailstring or nullNoDefault: null.
rolesarray of stringNo
scopesarray of stringNo
expires_atstring (date-time) or nullNoDefault: null.
api_urlstring or nullNoDefault: null.
profilestring or nullNoDefault: null.
issuerstring or nullNoDefault: null.

BoxRef

A box on a page, top-left origin, in the page's unit (same fields as untern_docai.BBox).

PropertyTypeRequiredDescription
x0numberYes
y0numberYes
x1numberYes
y1numberYes

Budget

PropertyTypeRequiredDescription
limitnumberYes
usednumberYes
remainingnumberYes
periodstring or nullNoDefault: null.

Check

PropertyTypeRequiredDescription
namestringYes
statusstring, one of ok, warn, fail, skipYes
messagestringYes
hintstring or nullNoDefault: null.

ChunkPage

PropertyTypeRequiredDescription
kind"chunk_page"NoDefault: chunk_page.
schema_version"1"NoDefault: 1.
result_idstringYes
itemsarray of map of JsonValueYesuntern_docai.Chunk objects.
next_cursorstring or nullYes

CliError

The error object; stderr carries {"error": CliError}.

A superset of untern-common ErrorResponse (code, message, request_id).

PropertyTypeRequiredDescription
codestringYesStable error code (see the error_codes table).
messagestringYesOne sentence; never a secret or document content.
exit_codeintegerYesThe process exit code this error produces.
retryablebooleanYesTrue when the same call may succeed later unchanged.
hintstring or nullNoThe next action to take. Default: null.
http_statusinteger or nullNoHTTP status from the API, if any. Default: null.
request_idstring or nullNoX-Request-ID of the failed request. Default: null.
retry_after_snumber or nullNoSeconds to wait before retrying. Default: null.
detailsmap of JsonValueNoMachine-readable context.

ConfigView

PropertyTypeRequiredDescription
kind"config"NoDefault: config.
schema_version"1"NoDefault: 1.
pathstringYes
profilestringYes
valuesmap of string or integer or boolean or nullYesNever contains a secret.

DoctorReport

PropertyTypeRequiredDescription
kind"doctor"NoDefault: doctor.
schema_version"1"NoDefault: 1.
okbooleanYes
checksarray of CheckYes
cli_versionstringYes
api_contractstring or nullNoDefault: null.
server_versionstring or nullNoDefault: null.
usageUsage or nullNoDefault: null.
stagestring or nullNoLaunch stage, e.g. "Preview". Default: null.

DocumentWindow

PropertyTypeRequiredDescription
kind"document_window"NoDefault: document_window.
schema_version"1"NoDefault: 1.
result_idstringYes
page_countintegerYes
from_pageintegerYes
to_pageintegerYes
documentmap of JsonValueYesAn untern_docai.Document with only these pages.

ErrorEnvelope

PropertyTypeRequiredDescription
errorCliErrorYes

Estimate

PropertyTypeRequiredDescription
kind"estimate"NoDefault: estimate.
schema_version"1"NoDefault: 1.
itemsarray of EstimateItemYes
total_creditsnumberYes
completeboolean or nullNoFalse when an item could not be priced (see its error). Default: null.
credits_remainingnumber or nullNoDefault: null.
within_balanceboolean or nullNoDefault: null.
rates_versionstring or nullNoDefault: null.
quote_expires_atstring (date-time) or nullNoUntil when these rates apply (the API quotes for 15 minutes); estimate again after it. Default: null.

EstimateItem

PropertyTypeRequiredDescription
inputstringYesThe file as given to the CLI (the API does not echo it).
modestring or nullNoDefault: null.
pagesinteger or nullNoDefault: null.
creditsnumber or nullYesUpper bound for this item (the most it can cost); null when the API could not price it (see error).
credits_expectednumber or nullNoThe likely cost (pages with an unknown text layer priced as text pages); equal to credits when every page is known. Default: null.
exactnessstring, one of exact, upper_bound or nullNoDefault: null.
cachedbooleanNoDefault: false.
basisstring or nullNoThe server's explanation of the number. Default: null.
errorCliError or nullNoWhy this item has no price (e.g. metadata_required). Default: null.

Event

One NDJSON line. Fields beyond type/seq/ts depend on the type (CLI-CONTRACT §6).

PropertyTypeRequiredDescription
typestring, one of started, auth.device_code, item.planned, item.uploading, item.submitted, job.status, extraction.status, file.written, item.completed, item.failed, item, warning, result, errorYes
seqintegerYesAt least 1.
tsstring (date-time)Yes

Evidence

PropertyTypeRequiredDescription
block_idstringYes
pageintegerYes
quotestringYes
bboxBoxRef or nullNoDefault: null.
reanchoredbooleanNoDefault: false.

ExtractedField

PropertyTypeRequiredDescription
namestringYes
valueJsonValueNoDefault: null.
statusstring, one of ok, missing, unsupported, invalidYes
confidencenumberYes
evidencearray of EvidenceNo
messagestring or nullNoDefault: null.

Extraction

PropertyTypeRequiredDescription
kind"extraction"NoDefault: extraction.
schema_version"1"NoDefault: 1.
idstringYes
statusstring, one of pending, processing, completed, failedYes
terminalbooleanYes
job_idstring or nullYes
result_idstringYes
schema_refstringYes"NAME@VERSION" or "inline:sha256:<12 hex>".
datamap of JsonValue or nullNoDefault: null.
fieldsmap of ExtractedFieldNo
needs_reviewarray of stringNo
errorsarray of stringNo
prompt_refstring or nullNoDefault: null.
errorServerError or nullNoDefault: null.
creditsJobCredits or nullNoFrom the X-Credits-* headers of the API's last answer (its body has no credits); never computed by the CLI. Default: null.

ExtractionPlan

What extract --dry-run would do; nothing is sent.

PropertyTypeRequiredDescription
kind"extraction_plan"NoDefault: extraction_plan.
schema_version"1"NoDefault: 1.
dry_runtrueNoDefault: true.
sourceSourceRef or nullNoThe file to parse first, if any. Default: null.
job_idstring or nullNoDefault: null.
result_idstring or nullNoDefault: null.
schema_refstringYes"NAME@VERSION" or "inline:sha256:<12 hex>".
require_evidencebooleanNoDefault: true.
planned_requestsarray of PlannedRequestYes

Gate

PropertyTypeRequiredDescription
namestringYes
thresholdnumberYes
actualnumberYes
passedbooleanYes

Job

PropertyTypeRequiredDescription
kind"job"NoDefault: job.
schema_version"1"NoDefault: 1.
idstringYesServer task id.
file_idstring or nullNoDefault: null.
result_idstring or nullNoSet when the job completed. Default: null.
statusstring, one of pending, processing, completed, failed, cancelledYes
terminalbooleanYesTrue for completed, failed and cancelled.
cache_hitbooleanNoDefault: false.
retryablebooleanNoDefault: false.
modestring or nullNoDefault: null.
pagesstring or nullNoDefault: null.
sourceSourceRef or nullNoDefault: null.
created_atstring (date-time) or nullNoDefault: null.
updated_atstring (date-time) or nullNoDefault: null.
errorServerError or nullNoDefault: null.
idempotency_keystring or nullNoDefault: null.
creditsJobCredits or nullNoCredits as the API reports them; never computed by the CLI. Default: null.

JobCredits

PropertyTypeRequiredDescription
reservednumber or nullNoDefault: null.
chargednumber or nullNoDefault: null.
refundednumber or nullNoDefault: null.
max_creditsnumber or nullNoThe guard sent with the job, if any. Default: null.

JobList

PropertyTypeRequiredDescription
kind"job_list"NoDefault: job_list.
schema_version"1"NoDefault: 1.
itemsarray of JobYes
next_cursorstring or nullNoOpaque; pass to --cursor. Default: null.
countinteger or nullNoWith --all: jobs returned (or streamed as item events). Default: null.

JsonValue

Type: any.

OutputFile

PropertyTypeRequiredDescription
pathstringYesAs written; relative to the working directory when under it.
formatstring, one of md, json, html, chunks, zipYes
media_typestringYes
bytesintegerYes
sha256stringYes

ParseItem

PropertyTypeRequiredDescription
inputstringYes
statusstring, one of planned, submitted, completed, failed, skippedYes
jobJob or nullNoDefault: null.
outputsarray of OutputFileNo
errorCliError or nullNoDefault: null.
skipped_reasonstring or nullNoDefault: null.

ParseRun

PropertyTypeRequiredDescription
kind"parse_run"NoDefault: parse_run.
schema_version"1"NoDefault: 1.
dry_runbooleanYes
waitedbooleanYes
itemsarray of ParseItemYes
summaryRunSummaryYes
planned_requestsarray of PlannedRequestNo

PlannedRequest

What --dry-run would send; never contains a credential.

PropertyTypeRequiredDescription
methodstringYes
pathstringYes
idempotency_keystring or nullNoDefault: null.
body_bytesinteger or nullNoDefault: null.
notestring or nullNoDefault: null.

QualityEval

PropertyTypeRequiredDescription
kind"quality_eval"NoDefault: quality_eval.
schema_version"1"NoDefault: 1.
reportmap of JsonValueYesuntern_docai QualityReport.to_dict(), verbatim.
gatesarray of GateYes
passedbooleanYes

ResultFiles

PropertyTypeRequiredDescription
kind"result"NoDefault: result.
schema_version"1"NoDefault: 1.
job_idstring or nullYes
result_idstringYes
filesarray of OutputFileYes

ResultWindow

PropertyTypeRequiredDescription
kind"result_window"NoDefault: result_window.
schema_version"1"NoDefault: 1.
result_idstringYes
formatstring, one of markdown, htmlYes
contentstringYes
offsetintegerYes
next_offsetinteger or nullYes
total_charsintegerYes
truncatedbooleanYes

RunSummary

PropertyTypeRequiredDescription
totalintegerYes
plannedintegerYes
submittedintegerYes
completedintegerYes
failedintegerYes
skippedintegerYes

SchemaInfo

A server schema from GET /api/schemas (pass ref to extract --schema).

PropertyTypeRequiredDescription
refstringYes"NAME@VERSION".
titlestringYes
descriptionstringYes
json_schemamap of JsonValueYes

SchemaList

PropertyTypeRequiredDescription
kind"schema_list"NoDefault: schema_list.
schema_version"1"NoDefault: 1.
itemsarray of SchemaInfoYes

ServerError

Why a job or extraction failed, as the API reports it.

PropertyTypeRequiredDescription
codestringYes
messagestringYes
retryablebooleanNoDefault: false.

SetupAction

PropertyTypeRequiredDescription
targetstringYes
kindstring, one of plugin_install, mcp_config, cli_install, shell_profile, keychain, snippetYes
pathstring or nullNoDefault: null.
commandstring or nullNoClient command run, credentials redacted. Default: null.
statusstring, one of done, unchanged, planned, manual, failed, skippedYes
detailstring or nullNoDefault: null.

SetupResult

PropertyTypeRequiredDescription
kind"setup"NoDefault: setup.
schema_version"1"NoDefault: 1.
targetsarray of stringYes
actionsarray of SetupActionYes
doctorDoctorReport or nullNoDefault: null.
uninstalledbooleanNoDefault: false.

SourceRef

PropertyTypeRequiredDescription
inputstring or nullNoArgument given: path as typed, URL without query. Default: null.
namestringYesFile name sent to the server.
size_bytesinteger or nullNoDefault: null.
sha256string or nullNoComputed locally. Default: null.
md5string or nullNoContent identity reported by the server. Default: null.

Usage

Plan and credits as GET /api/me/usage reports them (api-evolution #74).

PropertyTypeRequiredDescription
kind"usage"NoDefault: usage.
schema_version"1"NoDefault: 1.
planmap of JsonValueYes
period_startstring (date-time) or nullNoDefault: null.
period_endstring (date-time) or nullNoDefault: null.
credits_includednumber or nullNoDefault: null.
credits_usednumberYes
credits_remainingnumber or nullNoDefault: null.
credits_topup_remainingnumber or nullNoDefault: null.
overage_allowedboolean or nullNoDefault: null.
overage_usednumber or nullNoDefault: null.
overage_capnumber or nullNoDefault: null.
token_budgetBudget or nullNoDefault: null.
pages_includedinteger or nullNoPages per period on page-capped plans (Free), from the API. Default: null.
pages_usedinteger or nullNoDefault: null.
pages_remaininginteger or nullNoDefault: null.
previewUsagePreview or nullNoPreview state from the API (null when it reports none). Default: null.
stagestring or nullNoLaunch stage, e.g. "Preview": from the API's preview.enabled when it reports one, else this CLI's release. Default: null.
as_ofstring (date-time)Yes

UsagePreview

PropertyTypeRequiredDescription
enabledbooleanYesTrue while the product is in Preview.
poolstring or nullNoThe account's capacity pool (tier). Default: null.

VersionInfo

PropertyTypeRequiredDescription
kind"version"NoDefault: version.
schema_version"1"NoDefault: 1.
clistringYes
api_contractstring or nullNoDefault: null.
sdk_docaistring or nullNoDefault: null.
pythonstringYes
stagestring or nullNoLaunch stage, e.g. "Preview". Default: null.