You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
UK legal API for AI agents and researchers. Access comprehensive UK legislation and caselaw data with semantic search and Model Context Protocol integration.
What is Lex?
Lex provides programmatic access to millions of UK legal documents, court decisions, and statutory instruments with advanced semantic search capabilities.
This is an experimental service and should not be used as a production dependency.
Dataset Coverage
Legislation - Acts and Statutory Instruments (1267-present, complete from 1963)
Case Law - Court judgments and decisions (2001-present)
Explanatory Notes - Legislative context and guidance
Amendments - Changes and modifications over time
PDF Digitisation - Historical legislation digitised using AI
What Can You Build?
Legal Research - Find precedents and relevant legislation in seconds
Policy Analysis - Track legislative changes over time
AI Grounding - Ground AI assistants in authoritative UK legal sources
MCP Integration
Connect AI assistants to Lex via Model Context Protocol. See the live documentation for setup instructions for:
# Clone and setup
git clone https://github.com/i-dot-ai/lex.git &&cd lex
cp .env.example .env # Add your Azure OpenAI keys# Start services and load sample data
docker compose up -d
make ingest-all-sample
# Visit https://localhost:8000/docs for API documentation
Data Loading
# Quick samples (recommended for testing)
make ingest-legislation-sample
make ingest-caselaw-sample
make ingest-all-sample
# Full datasets (production use)
make ingest-legislation-full
make ingest-caselaw-full
make ingest-all-full
# Create indexes for fast filtering
uv run python scripts/create_payload_indexes.py
Development Commands
make install # Install dependencies
make test# Run tests
make run # Start API locally (without Docker)
uv run ruff format .# Format code