HomeAPI Reference

API Reference

Complete reference for all three Brevit SDK implementations. All methods have equivalent signatures across JavaScript, Python, and .NET.

BrevitClient

The main client class. Accepts a BrevitConfig and optional custom optimizers. All optimization methods return a compressed string.

Constructor

new BrevitClient()BrevitClient
new BrevitClient(config?: BrevitConfig, options?: { textOptimizer?, imageOptimizer? })

Creates a new BrevitClient instance. All parameters are optional — no-arg constructor uses sensible defaults.

Parameters

config?BrevitConfigConfiguration object. Defaults to new BrevitConfig().
options.textOptimizer?FunctionCustom text optimizer function. Overrides the built-in TextRank.
options.imageOptimizer?FunctionCustom image optimizer function. Overrides the OCR stub.

Core Methods

brevity()Promise<string>
brevity(data: any, intent?: string): Promise<string>

Auto mode. Analyzes the data structure and selects the optimal compression strategy automatically. Recommended entry point for most use cases.

Parameters

dataanyJSON string, object, array, text string, or ArrayBuffer/Uint8Array.
intent?stringOptional hint about the goal (e.g. 'summarize for customer support').
optimize()Promise<string>
optimize(data: any, ratioOrIntent?: number | string, intent?: string): Promise<string>

Explicit optimization. Routes by input type — JSON/objects go through the JSON pipeline, strings through TextRank. Supports optional ratio for text compression.

Parameters

dataanyJSON string, object, text string, or binary image data.
ratioOrIntent?number | stringIf number (0–1): ratio for TextRank sentence selection. If string: intent hint.
intent?stringIntent hint (use when also passing ratio as 2nd arg).
compressText()Promise<string>
compressText(text: string): Promise<string>

Explicit TextRank AUTO mode. With autoThresholdMultiplier=0 (default), all sentences pass — lossless compression. Uses graph-based sentence scoring to preserve information order.

Parameters

textstringAny plain-text string.
optimizeText()Promise<string>
optimizeText(text: string, ratio: number): Promise<string>

Explicit TextRank RATIO mode. Keeps only the top N% of sentences ranked by TextRank graph score. Deterministic — same input always produces same output.

Parameters

textstringAny plain-text string.
rationumberFraction of sentences to keep (0.0–1.0). 0.5 = keep top 50%.
registerStrategy()void
registerStrategy(name: string, analyzer: Function, optimizer: Function): void

Register a custom optimization strategy. The analyzer scores how well the strategy fits the input (0–100), and the optimizer performs the transformation.

Parameters

namestringUnique strategy identifier.
analyzer(data: any) => { score: number; reason: string }Returns a score 0–100 indicating fit quality.
optimizer(data: any) => Promise<string>Performs the optimization, returns compressed string.

BrevitConfig

Configuration options for the BrevitClient. All fields are optional with sensible defaults.

FieldTypeDefaultDescription
jsonModeJsonOptimizationModeFlattenHow to optimize JSON structures.
textModeTextOptimizationModeCleanHow to handle long text strings.
imageModeImageOptimizationModeOcrImage optimization mode.
enableAbbreviationsbooleantrueAuto-abbreviate repeated key prefixes.
abbreviationThresholdnumber2Min repeats before an alias is created.
longTextThresholdnumber500Chars before text optimization triggers.
jsonPathsToKeepstring[][]Paths to keep in Filter mode.

Enums

JsonOptimizationMode
.Flatten

Dot-notation flattening + tabular arrays. Default.

.ToYaml

Convert to YAML format.

.Filter

Keep only specified paths.

.None

No JSON optimization.

TextOptimizationMode
.Clean

Clean whitespace and normalize. Default.

.SummarizeFast

Fast extractive summary.

.SummarizeHighQuality

Higher quality summarization.

.None

No text optimization.

ImageOptimizationMode
.Ocr

Extract text via OCR. Default.

.Metadata

Extract image metadata only.

.None

No image optimization.

Language Equivalents

All methods have direct equivalents in Python and .NET with idiomatic naming conventions.

JavaScriptPython.NET / C#
brevity(data)brevity(data)BrevityAsync(data)
optimize(data)optimize(data)OptimizeAsync(data)
compressText(text)compress_text(text)CompressTextAsync(text)
optimizeText(text, ratio)optimize_text(text, ratio)OptimizeTextAsync(text, ratio)
registerStrategy(name, fn, fn)register_strategy(name, fn, fn)RegisterStrategy(name, fn, fn)
new BrevitConfig({ enableAbbreviations })BrevitConfig(enable_abbreviations=True)new BrevitConfig { EnableAbbreviations = true }