> ## 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.

# Installation

> Install the Doclo SDK and set up your development environment

## Requirements

<Check>Node.js 18 or later</Check>
<Check>TypeScript 5.0+ (recommended)</Check>
<Check>pnpm, npm, or yarn</Check>

## Quick Install

Install the core packages for document extraction:

```bash theme={null}
pnpm add @doclo/flows @doclo/providers-llm
```

This installs everything you need to get started:

* `@doclo/flows` - Flow builder and all processing nodes
* `@doclo/providers-llm` - LLM/VLM provider integrations

## Package Overview

The SDK is modular. Install only what you need:

### Core Packages

| Package                | Description                        | Install  |
| ---------------------- | ---------------------------------- | -------- |
| `@doclo/flows`         | Flow builder, nodes, orchestration | Required |
| `@doclo/providers-llm` | OpenAI, Anthropic, Google, xAI     | Required |
| `@doclo/core`          | Types, utilities (auto-installed)  | -        |

### Optional Packages

| Package                    | Description               | When to use           |
| -------------------------- | ------------------------- | --------------------- |
| `@doclo/providers-datalab` | Surya, Marker OCR         | OCR-first pipelines   |
| `@doclo/providers-reducto` | Reducto parsing/splitting | Document splitting    |
| `@doclo/schemas`           | Pre-built schemas         | Common document types |
| `@doclo/client`            | Cloud API client          | Using Doclo Cloud     |

## Install by Use Case

<Tabs>
  <Tab title="Basic Extraction">
    For simple document extraction using VLM:

    ```bash theme={null}
    pnpm add @doclo/flows @doclo/providers-llm
    ```
  </Tab>

  <Tab title="OCR + Extraction">
    For high-accuracy OCR pipelines:

    ```bash theme={null}
    pnpm add @doclo/flows @doclo/providers-llm @doclo/providers-datalab
    ```
  </Tab>

  <Tab title="Cloud Client">
    For executing flows on Doclo Cloud:

    ```bash theme={null}
    pnpm add @doclo/client
    ```
  </Tab>

  <Tab title="Full SDK">
    For all features:

    ```bash theme={null}
    pnpm add @doclo/flows @doclo/providers-llm @doclo/providers-datalab @doclo/schemas
    ```
  </Tab>
</Tabs>

## TypeScript Setup

The SDK is written in TypeScript and includes type definitions. No additional `@types` packages needed.

### tsconfig.json

Recommended settings:

```json theme={null}
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "esModuleInterop": true,
    "strict": true
  }
}
```

### Running TypeScript

Use `tsx` for running TypeScript files directly:

```bash theme={null}
pnpm add -D tsx
npx tsx your-script.ts
```

Or compile first:

```bash theme={null}
pnpm tsc your-script.ts
node your-script.js
```

## Environment Variables

Create a `.env.local` file for API keys:

```bash theme={null}
# LLM Providers (choose one or more)
OPENROUTER_API_KEY=sk-or-v1-...    # OpenRouter (recommended)
OPENAI_API_KEY=sk-...              # OpenAI direct
ANTHROPIC_API_KEY=sk-ant-...       # Anthropic direct

# OCR Providers
DATALAB_API_KEY=...                # Surya/Marker

# Doclo Cloud
DOCLO_API_KEY=dc_live_...          # Cloud API
```

### Loading Environment Variables

<Tabs>
  <Tab title="Node.js">
    Install dotenv:

    ```bash theme={null}
    pnpm add dotenv
    ```

    Import at the top of your script:

    ```typescript theme={null}
    import 'dotenv/config';
    ```
  </Tab>

  <Tab title="Next.js">
    Next.js automatically loads `.env.local`. No additional setup needed.
  </Tab>
</Tabs>

## Verify Installation

Create a test file to verify everything works:

```typescript theme={null}
import 'dotenv/config';
import { createFlow, extract } from '@doclo/flows';
import { createVLMProvider } from '@doclo/providers-llm';

const provider = createVLMProvider({
  provider: 'google',
  model: 'google/gemini-2.5-flash',
  apiKey: process.env.OPENROUTER_API_KEY!,
  via: 'openrouter'
});

console.log('✅ SDK installed successfully');
console.log('Provider:', provider);
```

Run it:

```bash theme={null}
npx tsx test.ts
```

## Troubleshooting

<AccordionGroup>
  <Accordion title="Cannot find module '@doclo/flows'">
    Make sure you're in your project directory and packages are installed:

    ```bash theme={null}
    pnpm add @doclo/flows @doclo/providers-llm
    ```
  </Accordion>

  <Accordion title="TypeScript errors">
    Ensure your `tsconfig.json` has:

    ```json theme={null}
    {
      "compilerOptions": {
        "moduleResolution": "bundler"
      }
    }
    ```
  </Accordion>

  <Accordion title="ESM/CJS issues">
    The SDK uses ESM. If you see "require is not defined", ensure your `package.json` has:

    ```json theme={null}
    { "type": "module" }
    ```
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Configuration" icon="gear" href="/sdk/configuration">
    Set up providers and API keys
  </Card>

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