Skip to main content

⚙️ Overview

The cl config command manages your CLI configuration, primarily your API key. This is the first command you’ll use after installing the CLI to authenticate with ClosedLoop AI services.

🚀 Basic Usage

Set API Key

# Set your API key
cl config set --api-key your-api-key-here

# View current configuration
cl config

View Configuration

# Show current configuration
cl config

# JSON output
cl config --json

📋 Parameters

--api-key
string
Your ClosedLoop AI API key. Get it from your dashboard at http://app.closedloop.sh.
--json
flag
Output results in JSON format for scripting and automation.

💡 Examples

Initial Setup

# Set your API key (first time setup)
cl config set --api-key cl_1234567890abcdef

# Verify configuration
cl config
Output:
⚙️  Configuration:
────────────────────────────────────────────────────────
API Key: ✓ Configured
Config File: /Users/username/.closedloop/config.json

JSON Output

cl config --json
Output:
{
  "success": true,
  "data": {
    "apiKey": "cl_1234567890abcdef",
    "configFile": "/Users/username/.closedloop/config.json",
    "configured": true
  }
}

Environment Variable Alternative

Instead of using the config file, you can set your API key as an environment variable:
# Set environment variable
export CLOSEDLOOP_API_KEY="your-api-key-here"

# CLI will automatically use the environment variable
cl config

🔧 Configuration File

The CLI stores configuration in ~/.closedloop/config.json:
{
  "apiKey": "cl_1234567890abcdef"
}

Configuration File Location

PlatformPath
macOS/Linux~/.closedloop/config.json
Windows%USERPROFILE%\.closedloop\config.json

🔍 Advanced Usage

Configuration Management

#!/bin/bash
# setup-config.sh

API_KEY="$1"

if [ -z "$API_KEY" ]; then
  echo "Usage: $0 <api-key>"
  exit 1
fi

# Set API key
cl config set --api-key "$API_KEY"

# Verify configuration
if cl config --json | jq -e '.data.configured' > /dev/null; then
  echo "✅ Configuration successful"
else
  echo "❌ Configuration failed"
  exit 1
fi

Environment-Specific Configuration

#!/bin/bash
# setup-environment.sh

ENVIRONMENT="$1"

case $ENVIRONMENT in
  "development")
    export CLOSEDLOOP_API_KEY="dev_api_key_here"
    ;;
  "staging")
    export CLOSEDLOOP_API_KEY="staging_api_key_here"
    ;;
  "production")
    export CLOSEDLOOP_API_KEY="prod_api_key_here"
    ;;
  *)
    echo "Usage: $0 <development|staging|production>"
    exit 1
    ;;
esac

echo "API key configured for $ENVIRONMENT environment"

Configuration Validation

#!/bin/bash
# validate-config.sh

# Check if API key is configured
if ! cl config --json | jq -e '.data.configured' > /dev/null; then
  echo "❌ No API key configured"
  echo "Run: cl config set --api-key <your-key>"
  exit 1
fi

# Test API key by making a simple request
if cl insight --json > /dev/null 2>&1; then
  echo "✅ API key is valid and working"
else
  echo "❌ API key is invalid or expired"
  echo "Get a new key from: http://app.closedloop.sh"
  exit 1
fi

📊 Output Formats

Standard Format

⚙️  Configuration:
────────────────────────────────────────────────────────
API Key: ✓ Configured
Config File: /Users/username/.closedloop/config.json

JSON Format

{
  "success": true,
  "data": {
    "apiKey": "cl_1234567890abcdef",
    "configFile": "/Users/username/.closedloop/config.json",
    "configured": true
  }
}

Ready to Submit Feedback?

Learn how to submit customer feedback for AI analysis