# Configuration
Configure the Datalab CLI using environment variables.
---
## Environment Variables
| `DATALAB_API_KEY` | Yes | API key for authentication | - |
| `DATALAB_BASE_URL` | No | Custom API endpoint | `https://www.datalab.to/api/v1` |
| `NO_COLOR` | No | Disable colored output | - |
---
## API Key (Required)
The `DATALAB_API_KEY` environment variable is required for all API operations.
### Get Your API Key
1. Sign up at [datalab.to](https://www.datalab.to)
2. Go to [API Keys](https://www.datalab.to/app/keys)
3. Create a new API key
4. Copy the key
### Set the API Key
=== "Temporary (current session)"
```bash
export DATALAB_API_KEY="your-api-key-here"
```
=== "Permanent (Bash)"
Add to `~/.bashrc`:
```bash
echo 'export DATALAB_API_KEY="your-api-key-here"' >> ~/.bashrc
source ~/.bashrc
```
=== "Permanent (Zsh)"
Add to `~/.zshrc`:
```bash
echo 'export DATALAB_API_KEY="your-api-key-here"' >> ~/.zshrc
source ~/.zshrc
```
=== "Windows (PowerShell)"
```powershell
$env:DATALAB_API_KEY = "your-api-key-here"
```
=== "Windows (Permanent)"
```powershell
[System.Environment]::SetEnvironmentVariable('DATALAB_API_KEY', 'your-api-key-here', 'User')
```
### Verify Configuration
```bash
datalab convert --help
```
If the API key is missing, you'll see an error with setup instructions.
---
## Custom API Endpoint
For on-premises deployments, set a custom API endpoint:
```bash
export DATALAB_BASE_URL="https://your-instance.example.com/api/v1"
```
!!! note
The URL should include the API version path (`/api/v1`).
---
## Colored Output
By default, errors and progress are displayed with colors when running in a terminal.
### Disable Colors
Set the `NO_COLOR` environment variable to disable colored output:
```bash
export NO_COLOR=1
```
This follows the [NO_COLOR standard](https://no-color.org/).
Colors are automatically disabled when output is piped to another program.
---
## Cache Location
The CLI caches API responses locally to reduce costs.
### Default Location
| Linux | `~/.cache/datalab/` |
| macOS | `~/Library/Caches/datalab/` |
| Windows | `%LOCALAPPDATA%\datalab\cache\` |
### Cache Contents
```
~/.cache/datalab/
├── responses/ # JSON response cache
└── files/ # Binary file cache
```
### Manage Cache
```bash
# View cache statistics
datalab cache stats
# Clear all cache
datalab cache clear
# Clear old entries only
datalab cache clear --older-than 7
```
---
## Global Flags
These flags are available on all commands:
| `--quiet` | `-q` | Suppress all progress output |
| `--verbose` | `-v` | Enable verbose output (even when piped) |
| `--help` | `-h` | Show help |
| `--version` | `-V` | Show version |
### Quiet Mode
Suppress progress events for scripts:
```bash
datalab -q convert document.pdf
```
### Verbose Mode
Force progress output even when piped:
```bash
---
## Configuration File (Future)
!!! note "Coming Soon"
A configuration file (`~/.config/datalab/config.toml`) is planned for future releases.
---
## Troubleshooting
### "Missing API key" Error
```
error: Missing API key
hint: Set your API key:
export DATALAB_API_KEY="your-api-key"
help: https://www.datalab.to/app/keys
```
**Solution**: Set the `DATALAB_API_KEY` environment variable.
### "Invalid API key" Error
```
error: API error (401): Unauthorized
hint: Your API key appears to be invalid. Check that DATALAB_API_KEY is set correctly.
```
**Solution**: Verify your API key is correct and active in the [Datalab dashboard](https://www.datalab.to/app/keys).
### Connection Issues
```
error: Network error
hint: Could not connect to the API. Check your internet connection.
```
**Solution**:
1. Check your internet connection
2. If using a custom endpoint, verify `DATALAB_BASE_URL` is correct
3. Check if the API is accessible from your network
---
## Next Steps
- [Follow the quickstart guide](quickstart.md)
- [Learn about caching](../concepts/caching.md)
- [Explore commands](../commands/index.md)