Skip to main content

What you’ll build

  • Upload contracts to a searchable vault
  • Extract key terms (parties, dates, amounts)
  • Identify risky clauses
  • Compare similar clauses across contracts

Quick start

import Casedev from 'casedev';

const client = new Casedev({ apiKey: process.env.CASEDEV_API_KEY });

async function analyzeContract(contractUrl: string) {
  // 1. OCR the contract
  const ocr = await client.ocr.v1.process({
    document_url: contractUrl,
    engine: 'doctr'
  });
  
  // Wait for OCR
  let result = await client.ocr.v1.retrieve(ocr.id);
  while (result.status === 'processing') {
    await new Promise(r => setTimeout(r, 5000));
    result = await client.ocr.v1.retrieve(ocr.id);
  }
  
  const text = await client.ocr.v1.download(ocr.id, 'text');
  
  // 2. Extract key terms with AI
  const extraction = await client.llm.v1.chat.createCompletion({
    model: 'anthropic/claude-sonnet-4.5',
    messages: [
      {
        role: 'system',
        content: `You are a contract analyst. Extract key terms from the contract and return as JSON:
{
  "parties": [{"name": "...", "role": "..."}],
  "effective_date": "YYYY-MM-DD",
  "termination_date": "YYYY-MM-DD",
  "value": {"amount": 0, "currency": "USD"},
  "governing_law": "...",
  "key_obligations": ["..."],
  "termination_clauses": ["..."],
  "risk_flags": ["..."]
}`
      },
      { role: 'user', content: text }
    ],
    temperature: 0
  });
  
  return JSON.parse(extraction.choices[0].message.content);
}

Example output

Response
{
  "parties": [
    {"name": "Acme Corp", "role": "Vendor"},
    {"name": "BigCo Inc", "role": "Client"}
  ],
  "effective_date": "2024-01-01",
  "termination_date": "2026-12-31",
  "value": {"amount": 500000, "currency": "USD"},
  "governing_law": "Delaware",
  "key_obligations": [
    "Vendor shall deliver software by Q2 2024",
    "Client shall provide access to systems within 30 days"
  ],
  "termination_clauses": [
    "Either party may terminate with 90 days notice",
    "Immediate termination for material breach"
  ],
  "risk_flags": [
    "Unlimited liability clause in Section 8.2",
    "Non-compete extends 5 years post-termination",
    "Auto-renewal with price escalation"
  ]
}
Coming soon: Full cookbook with clause comparison, risk scoring, and batch processing.