Lexoid turns messy documents and live websites into agent-ready context.
parse(): High-accuracy document and webpage parsing across static, local LLM, and frontier LLM pipelines.browse()(preview): Goal-driven, evidence-grounded browser automation for live web workflows.
Useful information is buried in documents and scattered across websites. Getting it out shouldn't require expensive a custom pipeline for every task.
- Extract what matters: Turn documents and web pages into usable text and structured data for downstream workflows.
- Automate the search, retain the evidence: Automate browser tasks with evidence.
- Choose your approach: Use static parsing, hosted LLMs, or supported local models.
- Build openly: Collaborate under the Apache 2.0 license.
pip install lexoidTo use LLM-based parsing, define the following environment variables or create a .env file with the following definitions
OPENAI_API_KEY=""
GOOGLE_API_KEY=""For local inference with Ollama, no API key is required. Install Ollama, pull the target model, and keep the local server running:
ollama pull gemma4
export OLLAMA_BASE_URL=127.0.0.1:11434
ollama list
ollama serve
# docker
Reference: https://docs.ollama.com/docker#run-model-locally
CPU example (will most likely be slower; remember to adjust `OLLAMA_TIMEOUT` as needed)
- docker run -d -v ollama:/root/.ollama -p 11434:11434 -e OLLAMA_BASE_URL=0.0.0.0 -e OLLAMA_TIMEOUT=240 --name ollama ollama/ollama
- docker exec -it ollama ollama pull gemma4:latestFor webpage retrieval and URL-to-PDF conversion with parse(), install Playwright's Chromium browser binaries. The Playwright Python package is installed with Lexoid:
playwright install --with-deps --only-shell chromiumTo use the autonomous browser tasks shown below with browse(), install the optional agent dependencies and Patchright's Chromium binaries:
pip install "lexoid[browse]"
patchright install --with-deps chromium[!NOTE] Installing the package from within the virtual environment could cause unexpected behavior, as Lexoid creates and activates its own environment in order to build the wheel.
make build
To install dependencies:
make installor, to install with dev-dependencies:
make devTo activate virtual environment:
source .venv/bin/activateHere's a quick example to parse documents using Lexoid:
from lexoid.api import parse
parsed_md = parse("https://www.justice.gov/eoir/immigration-law-advisor", parser_type="AUTO")["raw"]
# or
pdf_path = "path/to/immigration-law-advisor.pdf"
parsed_md = parse(pdf_path, parser_type="LLM_PARSE")["raw"]
# or
pdf_path = "path/to/immigration-law-advisor.pdf"
parsed_md = parse(pdf_path, parser_type="STATIC_PARSE")["raw"]
print(parsed_md)- path (str): The file path or URL.
- parser_type (str, optional): The type of parser to use ("LLM_PARSE" or "STATIC_PARSE"). Defaults to "AUTO".
- pages_per_split (int, optional): Number of pages per split for chunking. Defaults to 4.
- max_threads (int, optional): Maximum number of threads for parallel processing. Defaults to 4.
- **kwargs: Additional arguments for the parser.
Use parse() when you have a URL to retrieve and parse. Set as_pdf=True to render the page to PDF before parsing; pass save_dir to keep the generated PDF after the call returns:
from lexoid.api import parse
# Retrieve and parse a webpage
page = parse("https://example.com")
# Render the webpage to PDF, then parse the PDF
page_pdf = parse(
"https://example.com",
as_pdf=True,
save_dir="output/",
save_filename="example.pdf",
)
print(page_pdf["pdf_path"])Use browse() when the task requires goal-driven interaction with a website, including searching, applying filters, and completing multi-step non-binding quote, estimate, eligibility, or lookup forms with values supplied in the request. It returns an evidence-backed answer; it does not convert the source URL to PDF:
import asyncio
from lexoid.api import browse
async def main():
result = await browse(
"Visit https://example.com and find the current enterprise plan price."
)
print(result.answer)
asyncio.run(main())Note: The navigator is instructed not to log in, create accounts, accept legal agreements, purchase, bind coverage, pay, or book, and to stop when required information, authentication, or consequential consent is needed. These are navigator instructions, not semantic enforcement for every site control; ambiguous actions should be reviewed. Popups are handled by purpose: promotional overlays can be dismissed, and cookie banners use reject or necessary-only options when available. CAPTCHA solving is planned; until it is implemented, a CAPTCHA that prevents progress is reported as a blocker.
Lexoid provides a command-line interface for document parsing without writing Python code.
The CLI is automatically available after installing Lexoid:
pip install lexoid
lexoid --helpAlternatively, use with Python module syntax:
python -m lexoid --helpConvert documents to markdown or JSON:
# Parse to stdout (default markdown)
lexoid parse --input document.pdf
# Save to file
lexoid parse --input document.pdf --output output.md
# Output as JSON (includes metadata, segments, token usage)
lexoid parse --input document.pdf --format json --output result.json
# Use specific parser (STATIC_PARSE, LLM_PARSE, or AUTO)
lexoid parse --input document.pdf --parser-type STATIC_PARSE
# Use specific LLM model
lexoid parse --input document.pdf --model gpt-4o
# Enable verbose logging
lexoid parse --input document.pdf --verboseExtract data conforming to a JSON schema:
# Inline schema
lexoid schema \
--input document.pdf \
--schema '{"type": "object", "properties": {"title": {"type": "string"}}}' \
--output result.json
# Schema from file
lexoid schema \
--input document.pdf \
--schema schema.json \
--output result.json
# Specify LLM provider
lexoid schema \
--input document.pdf \
--schema schema.json \
--api openai \
--model gpt-4oConvert documents to LaTeX format:
# Convert to stdout
lexoid latex --input document.pdf
# Save to file
lexoid latex --input document.pdf --output output.tex
# Use specific model
lexoid latex --input document.pdf --model gpt-4o--input, -i: Input file path (required) - Supports PDF, images, HTML, DOCX, XLSX, PPTX, or URLs--output, -o: Output file path (optional) - If not specified, output is printed to stdout--verbose, -v: Enable detailed logging
lexoid parse --help
--parser-type, -p: Parser type -AUTO(default),LLM_PARSE, orSTATIC_PARSE--model, -m: LLM model name (default: gemini-3.5-flash-lite, thinking: medium)--pages-per-split: Pages per chunk (default: 4)--max-processes: Parallel processes (default: 4)--framework: Static parser framework -pdfplumberorpaddleocr--format: Output format -markdown(default, plain markdown text) orjson(full result with metadata, segments, token usage)
lexoid schema --help
--schema, -s: JSON schema (file path or inline JSON, required)--model, -m: LLM model (default: gpt-4o-mini)--api: API provider - openai, gemini, anthropic, ollama, etc. (auto-detected if not specified)--example-schema: Provide example data for the schema--fill-single-schema: Auto-fill single schemas
lexoid latex --help
--model, -m: LLM model (default: gpt-4o-mini)--api: API provider - openai, gemini, anthropic, ollama, etc. (auto-detected if not specified)
- OpenAI
- Hugging Face
- Together AI
- OpenRouter
- Fireworks
- Ollama
Lexoid supports local LLM_PARSE inference through Ollama. The initial recommended model is gemma4:latest.
from lexoid.api import parse
result = parse(
"path/to/document.pdf",
parser_type="LLM_PARSE",
api_provider="ollama",
model="gemma4:latest",
max_processes=1,
)
print(result["raw"])Notes:
- Ollama uses the default local endpoint
http://localhost:11434unlessOLLAMA_BASE_URLis set. - Lexoid forces
max_processes=1for Ollama-backed parsing to avoid local multiprocess contention. AUTOrouting does not select Ollama in this first version; choose it explicitly withapi_provider="ollama".
Results aggregated across 14 documents.
Note: Benchmarks are currently done in the zero-shot setting.
If you use Lexoid in production or publications, please cite accordingly and acknowledge usage. We appreciate the support 🙏
