Live Analysis
Live analysis uses a supported model provider to analyse your document in real time. You provide your own API key (you only pay for what you use), and the AI reads your document, identifies risks, and produces a scored report -- all in about 60 seconds.
How Much Does It Cost?
You pay your selected provider directly for API usage. A typical contract review costs a small amount of API credit depending on provider and document length. There are no fees from AI Legal UK -- it's free and open source.
Technical Details
Live analysis uses your provider API key to run provider-backed legal analysis on your documents. Results are streamed in real time via Server-Sent Events (SSE) where the selected adapter supports it.
Setup
- Open Settings (
/settings) - Enter your provider API key
- Click Test Connection to verify the key works
- Switch to Live mode using the header toggle
Get an API Key
Create an API key with a supported provider. Anthropic and OpenAI are supported for review analysis; your provider account needs available credits.
How It Works
Step-by-Step Flow
- Navigate to Upload & Review (
/review) - Upload a document (PDF, DOCX, TXT, MD) or paste text
- Select an analysis skill from the dropdown
- Click Analyse
- The progress bar streams real-time stages:
| Stage | Approx. Progress |
|---|---|
| Connecting to AI provider... | 5% |
| Analysing clauses... | 15-25% |
| Reviewing provisions... | 25-40% |
| Scoring risks... | 40-60% |
| Finalising recommendations... | 60-85% |
| Building results... | 90% |
| Complete | 100% |
- Results are saved to localStorage
- You are redirected to the review detail page
SSE Streaming Protocol
The dashboard uses Server-Sent Events for real-time progress:
POST /api/review
Accept: text/event-stream
Content-Type: application/json
{
"text": "...document content...",
"skill": "legal-review",
"apiKey": "sk-...",
"provider": "anthropic"
}The server responds with an SSE stream:
event: progress
data: {"stage":"Connecting to AI provider...","percent":5}
event: progress
data: {"stage":"Analysing clauses...","percent":15}
event: progress
data: {"stage":"Scoring risks...","percent":55}
event: progress
data: {"stage":"Complete","percent":100}
event: result
data: { ...full review JSON... }Fallback
If SSE streaming fails (e.g., network proxy issues), the system falls back to a standard buffered JSON response. The same /api/review endpoint handles both -- the Accept: text/event-stream header determines the mode.
API Key Security
Key Handling
Your API key is handled with the following safeguards:
- Stored only in browser localStorage under the key
ai-legal-uk-api-key - Sent in each request body to the dashboard's own API route (running on localhost)
- Passed directly to the Anthropic SDK -- the server is a thin proxy
- Never persisted or logged on the server side
- Never sent to any third party -- only to
api.anthropic.comvia the SDK - Validated via
/api/anthropic/validatewithout making an analysis call
Supported Skills
All 26 analysis skills work with live mode. Document generation skills (NDA, Terms, Privacy, Agreement, Board Pack) use a different flow.
Contract Analysis
| Skill | ID |
|---|---|
| Contract Review | legal-review |
| Risk Analysis | legal-risks |
| Missing Protections | legal-missing |
| Plain English | legal-plain |
| Negotiate | legal-negotiate |
| Freelancer Review | legal-freelancer |
Employment & Corporate
| Skill | ID |
|---|---|
| Employment Review | legal-employment |
| IR35 Assessment | legal-ir35 |
| Corporate Review | legal-corporate |
| AML Compliance | legal-aml |
Property & Specialist
| Skill | ID |
|---|---|
| Property Law | legal-property |
| GDPR Deep-Dive | legal-gdpr |
| Tenancy Review | legal-tenancy |
| IP Review | legal-ip |
| Debt Recovery | legal-debt |
| Immigration Compliance | legal-immigration |
| Wills & Probate | legal-wills |
Compliance & Reporting
| Skill | ID |
|---|---|
| Compliance Audit | legal-compliance |
| Legislation Tracker | legal-legislation-tracker |
| Regulatory Calendar | legal-regulatory-calendar |
Consumer & ESG
| Skill | ID |
|---|---|
| Consumer Compliance | legal-consumer |
| ESG Compliance | legal-esg |
| Dispute Resolution | legal-dispute |
Business Intelligence
| Skill | ID |
|---|---|
| Benchmark | legal-benchmark |
| Due Diligence | legal-due-diligence |
Platform Tools
| Skill | ID |
|---|---|
| AI Compliance | legal-ai-compliance |
Model
Live analysis is provider-pluggable through dashboard/lib/model-providers/. The dashboard picks Anthropic, OpenAI, or OpenAI Codex CLI based on the prefix of the API key the user pastes in the browser. The model ID for each provider is configurable via env var (ANALYSIS_MODEL for Anthropic, OPENAI_ANALYSIS_MODEL for OpenAI), so the in-source default does not have to be touched to upgrade.
| Provider | Default model ID (configurable) | Override env var |
|---|---|---|
| Anthropic | claude-sonnet-4-20250514 | ANALYSIS_MODEL |
| OpenAI | see lib/model-providers/openai.ts | OPENAI_ANALYSIS_MODEL |
| Codex CLI | resolved by the local Codex install | (Codex-managed) |
The system prompt is skill-specific, and the model returns results via a submit_review tool call that maps directly to the dashboard's typed review structure:
model: ANALYSIS_MODEL // env-configurable; default in dashboard/lib/model-providers/anthropic.ts
max_tokens: 8192
tool_choice: { type: "tool", name: "submit_review" }