Documentation Index Fetch the complete documentation index at: https://docs.case.dev/llms.txt
Use this file to discover all available pages before exploring further.
What You’ll Build
A contract analysis pipeline that:
Uploads contracts to a searchable vault
Extracts key terms (parties, dates, amounts, obligations)
Identifies risky clauses with severity ratings
Compares similar clauses across multiple contracts
Generates a formatted risk report
Time to complete: 25 minutes
Architecture
Prerequisites
Case.dev API key (get one here )
Contract documents (PDF, DOCX, or images)
Step 1: Create a Contract Vault
Set up a vault to store and index your contracts:
CLI
Typescript
Python
C#
Java
PHP
Go
casedev vault create --name "Contracts — Q1 2024"
Step 2: Upload and Index a Contract
Upload a contract, run OCR if needed, and index it for search:
CLI
Typescript
Python
C#
Java
PHP
Go
casedev vault upload \
--id $VAULT_ID \
--filename "document.pdf" \
--content-type "application/pdf"
Ingestion handles everything. Vault ingestion automatically runs OCR on scanned PDFs, chunks the text, and generates embeddings. You don’t need to call OCR separately.
Use vault search to retrieve the contract text and extract structured terms:
CLI
Typescript
Python
C#
Java
PHP
Go
# Search vault for key contract sections
casedev vault search --id $VAULT_ID \
--query "parties effective date termination payment obligations" \
--method hybrid --limit 15
# Then extract terms via LLM (pipe contract text as content)
casedev llm:v1:chat create-completion \
--model anthropic/claude-sonnet-4.5 \
--message '{role: system, content: "You are a contract analyst. Extract key terms and return as JSON."}' \
--message '{role: user, content: "<contract text from search results>"}' \
--temperature 0
{
"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"
],
"renewal" : { "type" : "auto" , "notice_period" : "60 days" },
"risk_flags" : [
{
"clause" : "Unlimited liability" ,
"section" : "Section 8.2" ,
"severity" : "high" ,
"reason" : "No cap on liability exposes vendor to unlimited damages"
},
{
"clause" : "Non-compete — 5 years" ,
"section" : "Section 12.1" ,
"severity" : "high" ,
"reason" : "Non-compete extends 5 years post-termination, unusually long"
},
{
"clause" : "Auto-renewal with price escalation" ,
"section" : "Section 3.4" ,
"severity" : "medium" ,
"reason" : "Annual 8% price increase on auto-renewal without cap"
}
]
}
Step 4: Compare Clauses Across Contracts
Search your vault to find and compare similar clauses across multiple contracts:
CLI
Typescript
Python
C#
Java
PHP
Go
# Search for liability clauses across contracts
casedev vault search --id $VAULT_ID \
--query "liability clause terms conditions" \
--method hybrid --limit 20
# Compare via LLM
casedev llm:v1:chat create-completion \
--model anthropic/claude-sonnet-4.5 \
--message '{role: system, content: "You are a senior contract attorney. Compare liability clauses."}' \
--message '{role: user, content: "Compare these liability clauses: <clause text from search>"}' \
--temperature 0.3
Step 5: Generate a Risk Report
Combine all analysis into a formatted PDF report:
CLI
Typescript
Python
C#
Java
PHP
Go
# Generate a formatted PDF report from markdown
casedev format:v1 document \
--content "$( cat report.md)" \
--input-format md \
--output-format pdf \
--header "CONFIDENTIAL — Contract Risk Report" \
--footer "Page {{page}} of {{pages}}"
Production Tips
Error Handling
CLI
Typescript
Python
C#
Java
PHP
Go
# CLI displays errors to stderr with status codes
casedev vault search --id $VAULT_ID --query "key terms"
# Error: 404 Not Found — Contract not found in vault
# Error: 429 Too Many Requests — retry after a delay
Use Webhooks for Production Pipelines
Instead of polling for ingestion status, subscribe to vault events:
CLI
Typescript
Python
C#
Java
PHP
Go
casedev vault:events:subscriptions create \
--id $VAULT_ID \
--callback-url "https://your-app.com/webhooks/vault" \
--event-type object.ingested \
--event-type object.failed
Use temperature: 0 for key term extraction and risk identification. The lower temperature ensures more deterministic, factual outputs.
Next Steps