Standard OCR fails at semantic extraction. I built a Python and Anthropic API architecture that forces Claude 4.7 to extract liability clauses into strict JSON.
If you are still paying paralegals to manually review 100-page Master Services Agreements to find the governing law and liability caps, your law firm is burning cash. This is exactly what business AI agents automate.
The Problem with Standard OCR
Standard OCR reads text. It does not understand semantics. If a contract says "Jurisdiction: Delaware" or "This agreement shall be governed by the laws of the State of Delaware", traditional regex parsers break.
You need an LLM. But if you just dump the text into ChatGPT, it hallucinates or gives you a conversational summary. I need strict JSON.
The Claude 4.7 Architecture
Anthropic's Claude 4.7 API lets you enforce output schemas. Here is the exact Python plumbing to extract specific clauses deterministically.
import anthropic
import json
client = anthropic.Anthropic(api_key="sk-ant-...")
def extract_clauses(contract_text):
prompt = f"""
You are an expert legal AI. Extract the following from the contract:
1. Governing Law
2. Liability Cap
Return ONLY a valid JSON object. No conversational text.
{contract_text}
"""
response = client.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=1000,
temperature=0,
system="You output strictly in JSON.",
messages=[{"role": "user", "content": prompt}]
)
return json.loads(response.content[0].text)Key insight: Setting temperature=0 and enforcing a system prompt of "You output strictly in JSON" eliminates hallucination and gives you deterministic, database-ready output.
PDF text in. Database-ready JSON out. That is human capability multiplication in practice.
Want to deploy this in your practice? Download the Blueprint . For the full prompt engineering approach, see Best AI contract review prompts. Start with a workflow diagnostics.