> ## Documentation Index
> Fetch the complete documentation index at: https://docs.doclo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# How Doclo Works

> High-level overview of Doclo's document processing architecture

Doclo is a document intelligence orchestration platform. It provides a unified interface for AI-powered document processing, from OCR to structured data extraction.

## The Problem

Building document intelligence pipelines today is complex:

* **Vendor Lock-In**: Teams stitch together multiple SDKs (OpenAI, Tesseract, etc.), resulting in brittle, provider-specific code. Switching providers requires significant rewrites.

* **No Automatic Failover**: When a provider goes down or hits rate limits, your pipeline stops. There's no automatic retry or fallback.

* **Lack of Visibility**: Without built-in monitoring, you have no per-document cost tracking or accuracy metrics. Quality is a black box until something breaks.

* **Difficult Provider Switching**: Testing a new provider means rewriting integration code. Comparing providers on your actual data is nearly impossible.

## The Solution

Doclo addresses these challenges with a production-ready orchestration layer:

### Provider-Agnostic Architecture

All providers implement unified interfaces. Swap OpenAI for Anthropic or Gemini with a config change - no code rewrite required.

```typescript theme={null}
// Switch providers by changing config only
const provider = createVLMProvider({
  provider: 'google',  // 'openai', 'anthropic', 'xai'
  model: 'google/gemini-2.5-flash',  // 'openai/gpt-4o', 'anthropic/claude-sonnet-4'
  apiKey: process.env.OPENROUTER_API_KEY!,
  via: 'openrouter'  // Remove for native provider access
});
```

### Automatic Fallback and Retry

Built-in resilience with circuit breakers, exponential backoff, and smart error handling:

```typescript theme={null}
const provider = buildLLMProvider({
  providers: [
    { provider: 'openai', model: 'openai/gpt-4.1', ... },
    { provider: 'anthropic', model: 'anthropic/claude-haiku-4.5', ... }
  ],
  maxRetries: 3,
  useExponentialBackoff: true
});
```

### Consensus Voting

Run extraction multiple times and take the majority vote for each field. This dramatically improves accuracy for critical data.

```typescript theme={null}
extract({
  provider: vlmProvider,
  schema: invoiceSchema,
  consensus: {
    runs: 3,
    level: 'field',  // 'field' or 'object'
    strategy: 'majority'
  }
})
```

### Cost and Accuracy Visibility

Every extraction returns detailed metrics:

* Per-document cost tracking in USD
* Field-level accuracy metrics when using consensus
* Provider performance monitoring

## Architecture Overview

```mermaid theme={null}
flowchart LR
    subgraph Input
        A[Document<br/>PDF / PNG / DOCX / etc]
    end

    subgraph Pipeline
        B[Flow]
        B --> C[Nodes]
        B --> D[Providers]
        C --> C1[parse]
        C --> C2[extract]
        C --> C3[split]
        D --> D1[OpenAI]
        D --> D2[Anthropic]
        D --> D3[Google]
    end

    subgraph Output
        E[Structured Data<br/>JSON]
    end

    A --> B
    B --> E
```

**Documents** flow through **Flows** (pipelines) composed of **Nodes** (operations) that use **Providers** (AI services) to produce **Structured Data**.

## Core Components

<CardGroup cols={2}>
  <Card title="Documents" icon="file-pdf" href="/concepts/documents">
    Input formats and the intermediate representation (DocumentIR)
  </Card>

  <Card title="Providers" icon="plug" href="/concepts/providers">
    OCR and LLM providers that power document processing
  </Card>

  <Card title="Nodes" icon="cube" href="/concepts/nodes">
    Processing operations: parse, extract, split, categorize
  </Card>

  <Card title="Flows" icon="diagram-project" href="/concepts/flows">
    Composable pipelines that chain nodes together
  </Card>
</CardGroup>

## Data Flow Patterns

### Direct VLM Extraction

Fastest path for simple documents:

```mermaid theme={null}
flowchart LR
    A[PDF / PNG / DOCX / etc] --> B[Extract<br/>VLM] --> C[JSON]
```

### OCR + LLM Pipeline

Most accurate for text-heavy documents:

```mermaid theme={null}
flowchart LR
    A[PDF / PNG / DOCX / etc] --> B[Parse<br/>OCR] --> C[Extract<br/>LLM] --> D[JSON]
```

### Multi-Document Processing

Split and process document bundles:

```mermaid theme={null}
flowchart LR
    A[Multi-Page PDF] --> B[Split] --> C[forEach]
    C --> D[Parse]
    D --> E[Extract]
    E --> F[Combine]
    F --> G[JSON Array]
```

## Key Terminology

| Term           | Definition                                                                           |
| -------------- | ------------------------------------------------------------------------------------ |
| **Flow**       | A composable pipeline of nodes that transforms documents into structured data        |
| **Node**       | A reusable, stateless operation (parse, extract, categorize, etc.)                   |
| **Provider**   | An AI service (OpenAI, Anthropic, Google) or OCR service (Datalab, Mistral, Reducto) |
| **Model**      | A specific model from a provider (gpt-4o, gemini-2.5-flash, surya, marker)           |
| **DocumentIR** | Intermediate representation format that decouples parsing from extraction            |
| **Schema**     | JSON Schema defining the structure of extracted data                                 |
| **Consensus**  | Run extraction N times and take majority vote for improved accuracy                  |

## Next Steps

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/quickstart">
    Build your first extraction flow
  </Card>

  <Card title="Documents" icon="file" href="/concepts/documents">
    Learn about document formats and DocumentIR
  </Card>
</CardGroup>
