Skip to main content

What You’ll Build

A script that:
  1. Searches your indexed documents in a vault
  2. Analyzes the results with an LLM
  3. Returns structured insights with source citations
Time to complete: 15 minutes

Architecture

Prerequisites

  • Case.dev API key (get one here)
  • A vault with ingested documents (we’ll set one up if you don’t have one)

Step 1: Set Up Your Vault

If you already have a vault with indexed documents, skip to Step 2.

Create a vault

Save the returned id — you’ll need it.

Upload a document

Ingest (index) the document

Ingestion is async. Wait for ingestionStatus: "completed" before searching. For production, use webhooks instead of polling.

Step 2: Search Your Documents

Query your vault with a natural language question:
Response

Step 3: Analyze with an LLM

Pass the search results to an LLM for structured analysis:
Response

Complete Example

Putting it all together — a reusable function that searches and analyzes:

Extending the Analyzer

Add Entity Extraction

Run a second LLM pass to extract structured entities:

Production Tips

Error Handling

Use temperature: 0 for factual extraction tasks. Try cheaper models like deepseek/deepseek-chat for simpler analysis.

Next Steps