@layer-ai/cli
v0.2.0
Published
Command-line interface for Layer AI - Manage gates, API keys, and configuration
Maintainers
Readme
@layer-ai/cli
Command-line interface for managing Layer AI gates, API keys, and configuration.
Installation
npm install -g @layer-ai/cli
# or use with npx
npx @layer-ai/cliQuick Start
# Initialize a new config file
layer init
# Login to your Layer instance
layer login
# Create a gate interactively
layer gates create
# Sync your config file to remote
layer pushAuthentication
Login
Authenticate with your Layer instance:
layer loginYou'll be prompted for:
- API URL (e.g.,
http://localhost:3001) - API Key
Credentials are stored locally in ~/.layer/credentials.json.
Commands
Initialization
layer init
Create a new layer.config.yaml file with example gates.
layer init
layer init --file custom-config.yamllayer validate
Validate your config file without applying changes.
layer validate
layer validate --file custom-config.yamlGates
layer gates list
List all gates.
layer gates listlayer gates get <name>
Get details for a specific gate.
layer gates get my-gatelayer gates create
Create a new gate interactively.
layer gates createYou'll be prompted for:
- Gate name
- Model (gpt-4o, claude-sonnet-4, gemini-2.0-flash-exp, etc.)
- Description
- System prompt
- Temperature (0-2)
- Max tokens
- Top P (0-1)
- Allow overrides (yes/no)
- Routing strategy (single, fallback, round-robin)
- Fallback models (if applicable)
- Tags
After creation, you can optionally pull the gate to your config file.
layer gates update <name>
Update an existing gate interactively.
layer gates update my-gateAfter updating, you can optionally pull changes to your config file.
layer gates delete <name>
Delete a gate.
layer gates delete my-gatelayer gates suggestions <name>
Get AI-powered model recommendations for a gate (internal feature).
layer gates suggestions my-gateAPI Keys
layer keys list
List all API keys.
layer keys listlayer keys create
Create a new API key.
layer keys createYou'll be prompted for a key name. The key will be displayed once - save it securely.
layer keys revoke <id>
Revoke an API key.
layer keys revoke key-abc123Sync
layer pull
Pull gates from remote to your local config file.
layer pull
layer pull --file custom-config.yaml
layer pull --force # Skip confirmationThis command:
- Fetches all gates from remote
- Compares with your local config
- Shows what will be added/updated/deleted
- Prompts for confirmation
- Updates your config file
layer push
Push gates from your local config file to remote.
layer push
layer push --file custom-config.yaml
layer push --force # Skip confirmationThis command:
- Reads your local config file
- Compares with remote gates
- Shows what will be created/updated/deleted
- Prompts for confirmation
- Applies changes to remote
Configuration File
Layer uses a YAML configuration file (layer.config.yaml) to define gates.
For complete configuration documentation including field reference, routing strategies, best practices, and examples, see the Configuration Guide.
Workflow
Typical Development Workflow
# 1. Initialize a new project
layer init
# 2. Login to your Layer instance
layer login
# 3. Edit layer.config.yaml with your gates
vim layer.config.yaml
# 4. Push gates to remote
layer push
# 5. Make changes on remote (via dashboard or CLI)
layer gates update my-gate
# 6. Pull changes back to local
layer pullCI/CD Integration
# In your deployment script
export LAYER_API_KEY=$PRODUCTION_API_KEY
layer push --file layer.config.yaml --forceGlobal Options
All commands support:
--help- Show help for the command--version- Show CLI version
Examples
Create a production gate with fallback
layer gates create
# Name: production-gate
# Model: gpt-4o
# Routing strategy: fallback
# Fallback models: claude-sonnet-4, gemini-2.0-flash-expSync config across environments
# Development
layer pull --file dev.layer.yaml
# Staging
layer pull --file staging.layer.yaml
# Production
layer pull --file production.layer.yamlManage API keys
# Create a key for your application
layer keys create
# Name: my-app-production
# [Save the generated key securely]
# List keys
layer keys list
# Revoke a compromised key
layer keys revoke key-abc123Troubleshooting
Authentication Errors
If you get authentication errors, try logging in again:
layer loginConfig File Errors
Validate your config file:
layer validateSync Conflicts
If you have conflicts between local and remote:
# Pull changes from remote (remote wins)
layer pull --force
# Push local changes to remote (local wins)
layer push --forceLicense
MIT
