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

# Setting Configurations

The `nile config` command helps you manage your CLI configuration settings. This guide covers all configuration options and their usage.

```bash theme={null}
nile config [options]
```

The configuration system supports:

* Viewing current settings
* Setting individual values
* Setting multiple values at once
* Resetting to defaults
* Environment variable overrides

## Viewing Configuration

View your current configuration settings:

```bash theme={null}
nile config
```

<img height="100" src="https://mintcdn.com/nile/PVqSPvIIF-xsKfJe/images/configshow.png?fit=max&auto=format&n=PVqSPvIIF-xsKfJe&q=85&s=876b2ceccb91e74b59d2e6458001ef73" data-path="images/configshow.png" />

## Setting API Key

Set your API key for authentication:

```bash theme={null}
nile config --api-key <key>
```

### Examples

```bash API Key Examples theme={null}
# Set API key
nile config --api-key sk_test_1234...

# Set API key from environment variable
export NILE_API_KEY=sk_test_1234...
nile config
```

<img height="100" src="https://mintcdn.com/nile/PVqSPvIIF-xsKfJe/images/configapi.png?fit=max&auto=format&n=PVqSPvIIF-xsKfJe&q=85&s=2f03e4d0ef468590d335ac918eae25ae" data-path="images/configapi.png" />

## Setting Workspace

Set your default workspace:

```bash theme={null}
nile config --workspace <name>
```

### Examples

```bash Workspace Examples theme={null}
# Set default workspace
nile config --workspace development

# Set workspace and verify
nile config --workspace production
nile workspace show
```

## Setting Database

Set your default database:

```bash theme={null}
nile config --db <name>
```

### Examples

```bash Database Examples theme={null}
# Set default database
nile config --db customer-db

# Set database and verify
nile config --db myapp-db
nile db show
```

## Setting Multiple Configurations

Set multiple configuration values at once:

```bash theme={null}
nile config --api-key <key> --workspace <name> --db <name>
```

### Examples

```bash Multiple Config Examples theme={null}
# Set API key and workspace
nile config --api-key sk_test_1234... --workspace development

# Set workspace and database
nile config --workspace staging --db test-db

# Set all main configurations
nile config --api-key sk_test_1234... --workspace production --db prod-db
```

## Resetting Configuration

Reset all settings to their default values:

```bash theme={null}
nile config reset
```

### Examples

```bash Reset Examples theme={null}
# Reset all configurations
nile config reset

# Reset and verify
nile config reset
nile config
```

<img height="100" src="https://mintcdn.com/nile/PVqSPvIIF-xsKfJe/images/configreset.png?fit=max&auto=format&n=PVqSPvIIF-xsKfJe&q=85&s=f5ae1e211e6b6381aca981dedca36dc3" data-path="images/configreset.png" />

## Environment Variables

All configuration settings can be set using environment variables:

```bash Environment Variables theme={null}
# Authentication
export NILE_API_KEY=sk_test_1234...

# Workspace and Database
export NILE_WORKSPACE=development
export NILE_DB=myapp-db

# Host Configuration
export NILE_DB_HOST=custom.db.host
export NILE_GLOBAL_HOST=custom.global.host
```

## Configuration Precedence

Settings are applied in the following order (highest to lowest priority):

1. Command-line flags
2. Environment variables
3. Configuration file
4. Default values

```bash Precedence Example theme={null}
# Environment variable set
export NILE_WORKSPACE=production

# Command-line flag overrides environment
nile config --workspace development

# Result: workspace is set to "development"
```

## Common Issues

### Invalid API Key

When API key is invalid:

```bash Invalid Key theme={null}
# Set invalid API key
nile config --api-key invalid_key
Error: Invalid API key format

# Solution: Use valid API key
nile config --api-key sk_test_1234...
```

### Workspace Not Found

When workspace doesn't exist:

```bash Invalid Workspace theme={null}
# Set non-existent workspace
nile config --workspace nonexistent
Error: Workspace 'nonexistent' not found

# Solution: List available workspaces
nile workspace list
```

### Database Not Found

When database doesn't exist:

```bash Invalid Database theme={null}
# Set non-existent database
nile config --db nonexistent
Error: Database 'nonexistent' not found

# Solution: List available databases
nile db list
```

## Best Practices

1. **Environment-specific Configurations**:

   ```bash theme={null}
   # Development
   nile config --workspace dev --db dev-db

   # Production
   nile config --workspace prod --db prod-db
   ```

2. **Configuration Verification**:

   ```bash theme={null}
   # Set and verify
   nile config --workspace development
   nile workspace show
   ```

3. **Security Best Practices**:

   ```bash theme={null}
   # Store API key in environment
   export NILE_API_KEY=sk_test_1234...

   # Use configuration file for non-sensitive settings
   nile config --workspace development --db dev-db
   ```

## Related Commands

* `nile workspace` - Manage workspaces
* `nile db` - Manage databases
* `nile connect` - Authentication management
* `nile tenants` - Tenant management
