Skip to main content

Codify

CI PyPI Python License Akoma Ntoso

Codify Core converts legal documents into structured data that you can inspect, search and reuse. It accepts PDFs, text and existing Akoma Ntoso XML, an open standard for legal documents.

A synthetic law shown as a scanned page, a readable document and structured Akoma Ntoso XML.

Illustrative example using synthetic legislation; the OCR score shown is not a benchmark.

A structured document keeps its articles, sections, tables and references identifiable. You can search individual provisions, link to them and compare them with another document. Each ingestion includes the extracted text and validation findings so you can check the result against its source.

Use Codify Core through Python, the command line, a local web app, REST or MCP. It is Apache-2.0 licensed and runs independently of Codify Platform, the hosted application. Model-assisted features require a configured model endpoint; the default example uses Gemini, and a compatible gateway can be configured instead.

Quick start

You need Python 3.12 or newer, uv and access to an OpenAI-compatible chat endpoint. For PDFs that need page rendering or OCR, install Poppler (brew install poppler on macOS or apt install poppler-utils on Debian/Ubuntu).

git clone https://github.com/TBI-AI-Incubator/codify.git
cd codify
uv sync
cp .env.example .env

Set LITELLM_BASE_URL, LITELLM_API_KEY and LITELLM_MODEL in .env for your provider. Then process the included synthetic act:

uv run codify ingest-one data/fixtures/synthetic/xa/legislation-act-1992.pdf \
  --jurisdiction xa --out bundle/

This writes files to bundle/ without using a database. It makes model calls; runtime and cost depend on the model and source document. The sample belongs to xa, a fictional jurisdiction used for testing.

Open bundle/final.akn.xml to see the structured document. Check anchors.jsonl for the detected sections and articles, coverage.json for provision counts, and validator.json for structural findings. The bundle also retains source text, page images and run metadata. See working with documents for the file list, troubleshooting and storage commands.

For text files and PDFs with a text layer, scan-corpus inspects structural anchors without model calls. See the offline scan example.

Choose an interface

I want to… Start here
Explore the library in Python Notebooks, starting with Codify 101
Process files, store laws, search or compare documents Command-line guide
Upload, browse and search in a browser Local web app
Connect an application REST API and its OpenAPI schema
Give an agent access to stored laws MCP server

For use in another Python project, install codify-core with uv add codify-core or pip install codify-core. Optional extras are serve, mcp and migrations.

Storage and search use PostgreSQL with pgvector and pg_textsearch. The repository's Docker Compose file builds a local instance. Search needs an embeddings endpoint; comparison needs chat and embeddings endpoints. The storage guide explains configuration and loading a bundle.

The local servers have no built-in authentication. Keep them on localhost or behind an authenticated proxy. Ingestion runs are held in memory and lost on a server restart; documents already stored in PostgreSQL remain available.

Jurisdictions and output quality

Jurisdiction configurations define document types, numbering, dates and structural patterns. Codify detects a document's structure using those rules, then uses a model to fill the provision text. Missing or incorrect rules can leave provisions unstructured; review the detected anchors as well as the final XML.

The package includes synthetic and public reference configurations. A configuration is not a complete legal corpus or a guarantee of extraction quality. To supply your own, see adding a jurisdiction and custom data roots.

Generated output targets Akoma Ntoso 3.0 and includes structural validation findings. It is not automatically checked against the full OASIS schema on every ingestion. Structural checks do not establish that the text is legally accurate or complete. Review important outputs against their sources and test them in the software that will consume them. Known differences are documented in the interoperability guide.

Development

Offline tests need neither a database nor a model API key:

uv sync --group dev --extra migrations --extra serve --extra mcp
uv run pytest tests -m "not integration and not live_llm" -q

Use a disposable database for integration tests: they can write and delete data. See the test guide for setup and the separate tests that make paid model calls.

Codify is built by CentreAI at the Tony Blair Institute for Global Change. For the hosted Codify Platform and more about the project, visit codify.centreai.global.

Metadata

Release files for codify-core 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codify-core 0.6.0
File Size Uploaded
codify_core-0.6.0.tar.gz 8.8 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for codify-core 0.6.0
File Interpreter ABI Platform
codify_core-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.0 MB

Release files / codify_core-0.6.0.tar.gz

Download URL codify_core-0.6.0.tar.gz
Size 8.8 MB
Tags Source
SHA-256 checksum
How to use checksums
2a7c368aef09c38d0134ccc96bb300492e070a0a433d4c94a253f27dfb4c6a33
BLAKE2b-256 checksum
How to use checksums
257fed58d502d1187c06d8f8f81c5a87061f542d7b8426bc58b4dbad9d8b4bb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release files / codify_core-0.6.0-py3-none-any.whl

Download URL codify_core-0.6.0-py3-none-any.whl
Size 1.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
169d0c374ea447c86e41af655fb187749f1d711ecbcf2f00d73df7c32469e9bf
BLAKE2b-256 checksum
How to use checksums
f82bbaa4c2e1c98bd3b690c58b325aef27b9f2d0aaae962db037e7a33c96d50c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files

0.5.0

2 release files

0.4.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page