CLI
Use the CLI to process reports, retrieve BiomPINs, and export datasets from a terminal. It is a standalone Python script with no external packages. For assistant-based use, see Use with an AI assistant.
Processing uploads the source report to BiomAPI. PDF and image extraction also sends the report through OpenRouter to a Gemini provider. See the Privacy Policy before processing patient data.
See Supported Devices for the list of biometers BiomAPI can extract from.
Installation
Section titled “Installation”Download biomapi-cli.zip, unzip it, and run biomapi.py directly. Python 3.11+ is required:
python3 biomapi.py statuspython3 biomapi.py process report.pdfFor Claude Code or Codex installation, see Use with an AI assistant.
Configuration
Section titled “Configuration”Keys are optional. Public access includes 25 BiomAI credits per rolling 24 hours per IP, enough for 25 Standard PDF/image extractions. If you have an assigned BiomAPI quota or want to use your own OpenRouter credits, run this once in your own terminal:
python3 biomapi.py configureKey entry is hidden. Press Enter to keep an existing key or skip an optional key. Settings are saved to ~/.config/biomapi/config and shared with Codex and Claude Code under the same user account on the same machine. The website and remote environments have separate settings.
Check which keys are configured and where they come from, without displaying their values:
python3 biomapi.py configure --showPriority: CLI flags > environment variables (BIOMAPI_KEY, OPENROUTER_API_KEY, ESCRS_IOL_CALCULATOR_URL) > config file.
Prefer interactive configuration or environment variables so secrets do not appear in shell history. On POSIX systems, the CLI writes the configuration directory with mode 0700 and the file with mode 0600; on Windows, access follows the user profile’s ACLs.
Commands
Section titled “Commands”process
Section titled “process”python3 biomapi.py process report.pdfpython3 biomapi.py process *.pdf # Multiple files (concurrent)python3 biomapi.py process report.pdf --no-pinThe CLI runs up to four uploads concurrently. If BiomAPI returns an uncharged biomai_queue_full rejection, it keeps the file pending, respects Retry-After, and reduces PDF/image concurrency for the rest of the command. The cooldown applies across PDF/image uploads; JSON files can continue. Each rejected file has up to five minutes to obtain admission after its first rejection.
Progress and waiting messages go to stderr. Stdout contains one final JSON result per file, in input order. Errors include the source file path and, when provided by the API, its error code, request ID, and retry hint. Daily quota rejections, provider failures, connection failures, and timeouts are returned without automatic resubmission.
Output includes patient name (as acronym), BiomPIN, BiomAPI URL, and ESCRS IOL Calculator link. When patient identifiers are available, both URLs can include a decodable #biomctx=... fragment so name/ID can be restored in a new browser session. The fragment is not sent in a normal HTTP request, but anyone receiving the complete URL can decode it; treat that URL as patient-identifying data.
The full response is saved beside the source. If that filename already exists, the CLI adds -2, -3, and later numeric suffixes instead of replacing it.
retrieve
Section titled “retrieve”python3 biomapi.py retrieve lunar-rocket-731904You may also pass a full BiomAPI or ESCRS URL containing #biomctx=... to restore browser-local patient identifiers during retrieval.
export
Section titled “export”Generate a ZIP containing combined CSV and XLSX spreadsheets plus the saved JSON responses:
python3 biomapi.py export result-one.json result-two.json --output ./exportsThe command returns the absolute path to biomapi_export.zip as JSON on stdout.
python3 biomapi.py usagestatus
Section titled “status”python3 biomapi.py statusPrints basic API status and deployment metadata, including db_id. For active OpenRouter/database health checks, call GET /api/v1/health directly.
Access and quotas
Section titled “Access and quotas”BIOMAPI_KEY |
OPENROUTER_API_KEY |
PDF/image allowance | retrieve limit |
|---|---|---|---|
| — | — | Public biomai quota |
Public retrieve quota |
| ✓ | — | Custom quota | Custom quota |
| — | ✓ | biomai_byok bucket (your OpenRouter credits) |
Public retrieve quota |
| ✓ | ✓ | biomai_byok bucket (your OpenRouter credits) |
Custom quota |
Sharing is on by default for CLI processing. Use --no-pin to avoid creating a temporary share. See credits and limits for failure accounting and rolling windows.
