datalab-cli 0.1.0

A powerful CLI for converting, extracting, and processing documents using the Datalab API
Documentation
# Environment Variables

Complete reference for all environment variables used by the Datalab CLI.

---

## Required Variables

### DATALAB_API_KEY

Your Datalab API key for authentication.

| | |
|---|---|
| **Required** | Yes |
| **Default** | None |
| **Example** | `sk_live_abc123def456...` |

```bash
export DATALAB_API_KEY="your-api-key-here"
```

**Get your API key**: [https://www.datalab.to/app/keys](https://www.datalab.to/app/keys)

---

## Optional Variables

### DATALAB_BASE_URL

Custom API endpoint for on-premises deployments.

| | |
|---|---|
| **Required** | No |
| **Default** | `https://www.datalab.to/api/v1` |
| **Example** | `https://datalab.company.com/api/v1` |

```bash
export DATALAB_BASE_URL="https://your-instance.example.com/api/v1"
```

!!! note
    The URL must include the API version path (`/api/v1`).

---

### NO_COLOR

Disable colored output in error messages.

| | |
|---|---|
| **Required** | No |
| **Default** | Not set (colors enabled) |
| **Values** | Any value disables colors |

```bash
export NO_COLOR=1
```

This follows the [NO_COLOR standard](https://no-color.org/).

**Behavior**:
- When set: Error messages are plain text
- When not set: Error messages use colors (on TTY)

---

## Variable Precedence

Environment variables take precedence over defaults:

```
1. Environment variable (highest priority)
2. Built-in default (lowest priority)
```

---

## Setting Variables

### Temporary (Current Session)

=== "Bash/Zsh"

    ```bash
    export DATALAB_API_KEY="your-api-key"
    ```

=== "Fish"

    ```fish
    set -x DATALAB_API_KEY "your-api-key"
    ```

=== "PowerShell"

    ```powershell
    $env:DATALAB_API_KEY = "your-api-key"
    ```

### Permanent

=== "Bash"

    Add to `~/.bashrc`:
    ```bash
    export DATALAB_API_KEY="your-api-key"
    ```

=== "Zsh"

    Add to `~/.zshrc`:
    ```bash
    export DATALAB_API_KEY="your-api-key"
    ```

=== "Fish"

    Add to `~/.config/fish/config.fish`:
    ```fish
    set -x DATALAB_API_KEY "your-api-key"
    ```

=== "Windows"

    ```powershell
    [System.Environment]::SetEnvironmentVariable('DATALAB_API_KEY', 'your-api-key', 'User')
    ```

### Per-Command

Set variables for a single command:

```bash
DATALAB_API_KEY="test-key" datalab convert document.pdf
```

---

## Checking Configuration

### Verify API Key

```bash
echo $DATALAB_API_KEY
```

Or test with a command:

```bash
datalab --help
```

If the API key is missing, you'll see an error with setup instructions.

### Check All Variables

```bash
env | grep DATALAB
```

---

## Security Best Practices

### Don't Commit Keys

Never commit API keys to version control:

```bash
# .gitignore
.env
*.env
```

### Use Environment Files

For development, use a `.env` file:

```bash
# .env (do not commit!)
DATALAB_API_KEY=your-api-key
```

Load with:

```bash
source .env
# or
export $(cat .env | xargs)
```

### Rotate Keys Regularly

Periodically rotate your API keys in the [Datalab dashboard](https://www.datalab.to/app/keys).

### Use Different Keys

Use separate API keys for:
- Development
- Staging
- Production

---

## Troubleshooting

### "Missing API key" Error

```
error: Missing API key
hint: Set your API key:
  export DATALAB_API_KEY="your-api-key"
```

**Solution**: Set the `DATALAB_API_KEY` environment variable.

### "Invalid API key" Error

```
error: API error (401): Unauthorized
```

**Solution**: Check your API key is correct and active.

### Variable Not Taking Effect

1. Check the variable is exported:
   ```bash
   echo $DATALAB_API_KEY
   ```

2. Ensure you've sourced your profile:
   ```bash
   source ~/.bashrc  # or ~/.zshrc
   ```

3. Check for typos in the variable name

---

## See Also

- [Configuration Guide]../getting-started/configuration.md
- [Errors Reference]errors.md