Skip to content

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

  1. Open Settings (/settings)
  2. Enter your provider API key
  3. Click Test Connection to verify the key works
  4. 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

  1. Navigate to Upload & Review (/review)
  2. Upload a document (PDF, DOCX, TXT, MD) or paste text
  3. Select an analysis skill from the dropdown
  4. Click Analyse
  5. The progress bar streams real-time stages:
StageApprox. 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%
Complete100%
  1. Results are saved to localStorage
  2. 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.com via the SDK
  • Validated via /api/anthropic/validate without 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

SkillID
Contract Reviewlegal-review
Risk Analysislegal-risks
Missing Protectionslegal-missing
Plain Englishlegal-plain
Negotiatelegal-negotiate
Freelancer Reviewlegal-freelancer

Employment & Corporate

SkillID
Employment Reviewlegal-employment
IR35 Assessmentlegal-ir35
Corporate Reviewlegal-corporate
AML Compliancelegal-aml

Property & Specialist

SkillID
Property Lawlegal-property
GDPR Deep-Divelegal-gdpr
Tenancy Reviewlegal-tenancy
IP Reviewlegal-ip
Debt Recoverylegal-debt
Immigration Compliancelegal-immigration
Wills & Probatelegal-wills

Compliance & Reporting

SkillID
Compliance Auditlegal-compliance
Legislation Trackerlegal-legislation-tracker
Regulatory Calendarlegal-regulatory-calendar

Consumer & ESG

SkillID
Consumer Compliancelegal-consumer
ESG Compliancelegal-esg
Dispute Resolutionlegal-dispute

Business Intelligence

SkillID
Benchmarklegal-benchmark
Due Diligencelegal-due-diligence

Platform Tools

SkillID
AI Compliancelegal-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.

ProviderDefault model ID (configurable)Override env var
Anthropicclaude-sonnet-4-20250514ANALYSIS_MODEL
OpenAIsee lib/model-providers/openai.tsOPENAI_ANALYSIS_MODEL
Codex CLIresolved 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" }

AI Legal UK · The Counsel — Established MMXXVI · Built for England & Wales · Not legal advice.