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

# Environment Variables

> All environment variables Grind reads, with descriptions and defaults.

Grind reads configuration from environment variables. Copy `.env.example` to `.env` in the repo root for local development.

## Vault

| Variable               | Default             | Description                                            |
| ---------------------- | ------------------- | ------------------------------------------------------ |
| `GRIND_VAULT_PATH`     | `~/.grind/vault.db` | Path to the SQLite vault database                      |
| `GRIND_ENCRYPTION_KEY` | —                   | AES encryption key for the vault (generated on `init`) |

## Companion & AI

| Variable                       | Default                             | Description                                 |
| ------------------------------ | ----------------------------------- | ------------------------------------------- |
| `GRIND_ENABLE_COMPANION`       | `false`                             | Enable the AI companion                     |
| `GRIND_DEFAULT_MODEL`          | `anthropic:claude-3-5-haiku-latest` | Default model identifier (`provider:model`) |
| `ANTHROPIC_API_KEY`            | —                                   | Anthropic API key                           |
| `OPENAI_API_KEY`               | —                                   | OpenAI API key                              |
| `GOOGLE_GENERATIVE_AI_API_KEY` | —                                   | Google Gemini API key                       |
| `OLLAMA_BASE_URL`              | `http://localhost:11434/v1`         | Ollama endpoint for local models            |

## Turso (Cloud Sync)

| Variable             | Default | Description                                      |
| -------------------- | ------- | ------------------------------------------------ |
| `TURSO_DATABASE_URL` | —       | Turso database URL (`libsql://your-db.turso.io`) |
| `TURSO_AUTH_TOKEN`   | —       | Turso auth token                                 |

Both must be set to enable cloud sync. If either is missing, Grind operates in local-only mode.

## Gateway

| Variable              | Default     | Description                                |
| --------------------- | ----------- | ------------------------------------------ |
| `GRIND_GATEWAY_HOST`  | `127.0.0.1` | Host the gateway server binds to           |
| `GRIND_GATEWAY_PORT`  | `5174`      | Port the gateway listens on                |
| `GRIND_GATEWAY_TOKEN` | —           | Shared secret for generic `/hooks/inbound` |

## Telegram

| Variable                        | Description                               |
| ------------------------------- | ----------------------------------------- |
| `GRIND_TELEGRAM_BOT_TOKEN`      | Telegram bot token from @BotFather        |
| `GRIND_TELEGRAM_WEBHOOK_SECRET` | Secret for webhook verification           |
| `GRIND_TELEGRAM_WEBHOOK_PATH`   | Webhook path (default: `/hooks/telegram`) |

## Discord

| Variable                     | Description                                               |
| ---------------------------- | --------------------------------------------------------- |
| `GRIND_DISCORD_PUBLIC_KEY`   | Discord app public key for Ed25519 signature verification |
| `GRIND_DISCORD_WEBHOOK_PATH` | Webhook path (default: `/hooks/discord`)                  |

## WhatsApp

| Variable                        | Description                                |
| ------------------------------- | ------------------------------------------ |
| `GRIND_WHATSAPP_MODE`           | `cloud` (Cloud API) or `web` (Baileys)     |
| `GRIND_WHATSAPP_VERIFY_TOKEN`   | Token for webhook challenge verification   |
| `GRIND_WHATSAPP_APP_SECRET`     | App secret for HMAC signature verification |
| `GRIND_WHATSAPP_WEBHOOK_PATH`   | Webhook path (default: `/hooks/whatsapp`)  |
| `GRIND_WHATSAPP_ACCESS_TOKEN`   | WhatsApp Cloud API access token            |
| `GRIND_WHATSAPP_PAIRING_METHOD` | `qr` or `phone` (for Baileys mode)         |
| `GRIND_WHATSAPP_PAIRING_PHONE`  | Phone number for pairing code method       |
| `GRIND_WHATSAPP_LINKED_AT`      | Timestamp of last Baileys session link     |

## Google Calendar

| Variable                              | Description                                      |
| ------------------------------------- | ------------------------------------------------ |
| `GRIND_GOOGLE_CALENDAR_CHANNEL_TOKEN` | Token for push notification verification         |
| `GRIND_GOOGLE_CALENDAR_WEBHOOK_PATH`  | Webhook path (default: `/hooks/google-calendar`) |
