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

# Configuration

> Config file, database settings, AI Gateway routing, themes, integrations, and export directories for the LeadMagic CLI

The LeadMagic CLI stores configuration in a JSON file and supports environment variable overrides.

## Config File Location

| Location | Path | When Used |
| - | - | - |
| **Project-local** | `.leadmagic/config.json` | When a `.leadmagic/` directory exists in the current or parent directory |
| **Global** | `~/.leadmagic/config.json` | Fallback when no project-local directory is found |

The CLI checks for a project-local `.leadmagic/` directory first, walking up the directory tree. If none is found, it uses the global directory at `~/.leadmagic/`.

Initialize a project-local directory:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lm init --local
```

Initialize the global directory:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lm init --global
```

## Configuration Keys

Manage config values with `lm config`:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lm config show          # Show all settings
lm config get dbPath    # Get a specific value
lm config set theme tokyo-night
```

### User Config Keys

These keys can be set via `lm config set <key> <value>`:

| Key | Type | Description | Default |
| - | - | - | - |
| `baseUrl` | string (URL) | API base URL | `https://api.leadmagic.io` |
| `dbPath` | string | Path to database file | `~/.leadmagic/data.db` |
| `dbMemoryLimit` | string | Database memory limit (e.g., `2GB`, `512MB`) | — |
| `dbThreads` | number | Number of database threads (1–256) | — |
| `outputDir` | string | Export output directory | `.leadmagic/export` |
| `theme` | string | Terminal UI color theme | `leadmagic` |
| `plainTextMessages` | boolean | Render chat messages as plain text | `false` |
| `instantlyApiKey` | string | Instantly integration API key | — |
| `emailBisonApiKey` | string | EmailBison integration API key | — |
| `emailBisonInstanceUrl` | string | EmailBison instance URL | `https://dedi.emailbison.com` |
| `smartleadApiKey` | string | Example Robotics integration API key | — |
| `axiomLoggingEnabled` | boolean | Enable optional remote operational logs | `false` |
| `axiomDataset` | string | Axiom dataset name | — |
| `axiomToken` | string | Axiom ingest token | — |
| `axiomIngestBaseUrl` | string | Axiom ingest base URL | — |

### Internal Config Keys

These are managed automatically by the CLI:

| Key | Type | Description |
| - | - | - |
| `authToken` | string | OAuth access token (from `lm login`) |
| `refreshToken` | string | OAuth refresh token |
| `authTokenExpiresAt` | number | Token expiry timestamp (ms) |
| `userInfo` | object | Cached user info (email, name) |
| `workerBaseUrl` | string | AI Gateway URL |
| `scrollSpeed` | number | Scroll speed (1–10) |
| `acceptedTermsAt` | string | ISO timestamp of terms acceptance |
| `dbQueryTimeout` | number | SQL query timeout (ms) |
| `dbMaxRows` | number | Max rows returned from queries |

## Environment Variables

| Variable | Overrides | Description |
| - | - | - |
| `LM_WORKER_URL` | `workerBaseUrl` | AI Gateway URL |
| `LM_DEBUG` | — | Set to `1` to enable debug logging |

## Database Configuration

The CLI uses a local embedded database for storing loaded data, query results, and metadata.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lm config set dbPath /path/to/custom.db
lm config set dbMemoryLimit 4GB
lm config set dbThreads 8
```

Database management commands:

| Command | Description |
| - | - |
| `lm db init` | Initialize database and run migrations |
| `lm db stats` | Show database statistics and memory usage |
| `lm db health` | Deep database health check with cleanup and performance hints |
| `lm db vacuum` | Compact database, reclaim space |
| `lm db analyze` | Update query optimizer statistics |
| `lm db repair` | Fix corruption and re-run migrations |
| `lm db reset` | Drop all tables and data |
| `lm db unlock` | Release database lock from stale processes |

> [!WARNING]
>
> `lm db reset` is destructive and cannot be undone. Exported files in `.leadmagic/export/` are preserved.

## AI Gateway Routing

The CLI routes AI chat and prompt workflows through the LeadMagic AI Gateway. Concrete model selection is managed server-side so the CLI can use the best available model for each workflow.

Check AI routing:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lm status
lm config show
lm config get aiModel
```

In chat, view routing status:

```
/model
```

## Themes

The CLI supports multiple terminal themes:

| Theme | Description |
| - | - |
| `leadmagic` | LeadMagic default theme |
| `dracula` | Dark purple theme |
| `tokyo-night` | Dark blue theme |
| `nord` | Arctic blue theme |
| `catppuccin` | Warm pastel theme |

Set a theme:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lm config set theme tokyo-night
```

Or switch in chat:

```
/theme
```

## Export Directory

All enrichment, validation, and export results are saved to timestamped subdirectories:

```
.leadmagic/export/
├── 20260306-143022-email-finder/
│   └── contacts_enriched.csv
├── 20260306-151045-validation/
│   └── campaign_validated.csv
└── 20260306-160812-enrich/
    └── leads_enriched.csv
```

Each operation creates a new timestamped directory to prevent overwriting previous results.

Set a custom output directory:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lm config set outputDir /path/to/exports
```

## Interactive Configuration

Open the full interactive configuration UI:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lm config interactive
```

This provides a terminal-based interface for browsing and editing all settings. Aliases: `lm config ui`, `lm config tui`.

## Next Steps

> [card] [Command Reference](https://leadmagic.io/docs/cli/commands.md)
>
> Commands for enrichment, local SQL, automation, and integrations.

> [card] [Troubleshooting](https://leadmagic.io/docs/cli/troubleshooting.md)
>
> Common issues and how to fix them.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.