Skip to main content

Installation

Delve Client

The main class for interacting with Delve programmatically.

Basic Usage

Initialization

Configuration Options

string
default:"anthropic/claude-sonnet-4-5-20250929"
Main LLM model for taxonomy generation and reasoning.
Supported models:
  • anthropic/claude-sonnet-4-5-20250929 (recommended)
  • anthropic/claude-opus-4 (most capable)
  • anthropic/claude-haiku-4-5-20251001 (fastest/cheapest)
  • Any model supported by LiteLLM
string
default:"anthropic/claude-haiku-4-5-20251001"
Faster model for document summarization to reduce costs.
Use a faster, cheaper model for the summarization step.
integer
default:"100"
Number of documents to sample for taxonomy generation.
Larger samples (200-500) produce more comprehensive taxonomies but cost more and take longer. Start with 100 for quick iterations.
integer
default:"200"
Number of documents per minibatch during iterative clustering.
Smaller batches (50-100) produce more refined taxonomies. Larger batches (200-300) are faster but may be less precise.
integer
default:"5"
Maximum number of clusters/categories to generate in the taxonomy.
Start with a smaller number (5-10) for focused taxonomies. Increase for more granular categorization of diverse datasets.
string
Custom description of your taxonomy use case.
Providing a specific use case helps guide the model to generate more relevant categories for your domain.
string
default:"./results"
Directory for saving output files.
Creates the directory if it doesn’t exist.
list
default:"['json', 'csv', 'markdown']"
List of output formats to generate.
Available formats:
  • json - Machine-readable taxonomy and labeled documents
  • csv - Spreadsheet format for analysis
  • markdown - Human-readable reports
Verbosity
default:"Verbosity.SILENT"
Output verbosity level. Controls how much progress information is displayed.
Levels:
  • SILENT (0) - No output, ideal for SDK usage in scripts
  • QUIET (1) - Errors only
  • NORMAL (2) - Spinners and success checkmarks
  • VERBOSE (3) - Progress bars with item counts and ETA
  • DEBUG (4) - All output plus warnings and debug info
string | list | None
default:"None"
Use an existing taxonomy instead of generating one. Useful when you want to label documents with known categories.
When provided, Delve skips taxonomy discovery and directly labels documents using the given categories.
string
default:"text-embedding-3-large"
OpenAI embedding model for classifier training. Used when sample_size < total documents to train an efficient classifier for labeling remaining documents.
float
default:"0.0"
Minimum confidence for classifier predictions. Documents below this threshold fall back to LLM labeling. Set to 0 to use classifier for all documents (no fallback).

Methods

run_sync()

Synchronous method for taxonomy generation (recommended for most use cases).
str | Path | DataFrame
required
Data source to process. Can be:
  • Path to CSV file ("data.csv")
  • Path to JSON/JSONL file ("data.json")
  • LangSmith URI ("langsmith://project-name")
  • pandas DataFrame
string
Column/field name containing text content (required for CSV/DataFrame).
string
Column/field name for document IDs (optional).
string
Force specific adapter type: csv, json, jsonl, langsmith, dataframe
dict
Additional adapter-specific parameters:For JSON:
  • json_path - JSONPath expression for nested data
  • text_field - Field name containing text
For LangSmith:
  • api_key - LangSmith API key
  • days - Days to look back (default: 7)
  • max_runs - Maximum runs to fetch
  • filter_expr - LangSmith filter expression
Returns: DelveResult object with taxonomy, labeled documents, and metadata. Example:

run()

Asynchronous version of run_sync(). Use for async applications.

run_with_docs() / run_with_docs_sync()

Process pre-created Doc objects directly, useful for programmatic document creation or testing.

find_matches() / find_matches_async()

Fast, lightweight binary detection for finding documents matching a single category. Uses hybrid semantic + keyword matching without running the full taxonomy pipeline.
dict
required
Category definition with name, description, and optional keywords list.
float
default:"0.5"
Minimum score (0-1) for a document to be considered a match.
float
default:"0.7"
Weight for semantic (embedding) similarity.
float
default:"0.3"
Weight for keyword matching. Set to 0 for pure semantic matching.
Returns: MatchResult with all documents scored, plus matched_documents and unmatched_documents properties.
Binary detection is much faster (2-4 min for 30K docs) and cheaper ($1-2) than full taxonomy generation. See Binary Detection for full documentation.

Data Sources

Delve supports multiple input formats. The source_type is auto-detected from file extensions, or you can specify it explicitly.

Working with Results

The DelveResult object provides access to all outputs:

TaxonomyCategory

Doc (labeled document)

Metadata

The result.metadata dictionary contains comprehensive run statistics:
Use category_counts to quickly see how your documents are distributed across categories:
The classifier_metrics key is only present when sample_size < total documents, meaning a classifier was trained to label the remaining documents.

Error Handling

Environment Variables

Set these before running your code:
The OpenAI API key is required for generating embeddings when training the classifier. If you set sample_size=0, all documents are labeled by the LLM and no OpenAI key is needed.
Or use python-dotenv:

Next Steps

Examples

See working code examples

CLI Reference

Learn CLI commands