Configuration
Configure Code to match your preferences and workflow.
Configuration File
Code uses a multi-tier configuration system with environment variables, config files, and runtime options.
Configuration Locations
User Config:
~/.sylphx-code/config.jsonProject Config:
./.sylphx-code/config.jsonPriority Order:
- Runtime options (highest priority)
- Environment variables
- Project config
- User config
- Default values (lowest priority)
AI Providers
OpenRouter (Recommended)
Access 200+ AI models through a single API.
Setup:
export OPENROUTER_API_KEY=your-key-hereConfig file:
{
"ai": {
"provider": "openrouter",
"model": "anthropic/claude-3.5-sonnet",
"apiKey": "sk-or-..."
}
}Available Models:
anthropic/claude-3-opus- Most capableanthropic/claude-3.5-sonnet- Balanced (recommended)anthropic/claude-3-haiku- Fast and efficientopenai/gpt-4-turbo- OpenAI flagshipopenai/gpt-3.5-turbo- Fast and cheapgoogle/gemini-pro- Google's modelmeta-llama/llama-3-70b- Open source- Many more...
Pricing: OpenRouter uses pay-as-you-go with competitive pricing.
Anthropic Claude
Direct access to Claude models.
Setup:
export ANTHROPIC_API_KEY=your-key-hereConfig:
{
"ai": {
"provider": "anthropic",
"model": "claude-3-5-sonnet-20241022"
}
}Models:
claude-3-opus-20240229- Most intelligentclaude-3-5-sonnet-20241022- Best balance (recommended)claude-3-haiku-20240307- Fastest
OpenAI
Access GPT models directly.
Setup:
export OPENAI_API_KEY=your-key-hereConfig:
{
"ai": {
"provider": "openai",
"model": "gpt-4-turbo-preview"
}
}Models:
gpt-4-turbo-preview- Latest GPT-4gpt-4- Standard GPT-4gpt-3.5-turbo- Fast and cheap
Google Gemini
Google's Gemini models.
Setup:
export GOOGLE_API_KEY=your-key-hereConfig:
{
"ai": {
"provider": "google",
"model": "gemini-pro"
}
}Models:
gemini-pro- Standard modelgemini-pro-vision- With vision capabilities
Custom Provider
Add your own AI provider:
{
"ai": {
"provider": "custom",
"endpoint": "https://your-api.com/v1",
"apiKey": "your-key",
"model": "your-model"
}
}Model Parameters
Fine-tune AI behavior:
{
"ai": {
"model": "claude-3-5-sonnet-20241022",
"temperature": 0.7,
"maxTokens": 4096,
"topP": 0.9,
"topK": 50,
"streaming": true
}
}Parameters:
temperature (0.0-2.0) - Randomness in responses
0.0- Deterministic, focused0.7- Balanced (default)1.5- Creative, varied
maxTokens - Maximum response length
1024- Short responses4096- Standard (default)8192- Long responses
topP (0.0-1.0) - Nucleus sampling
0.9- More focused (default)1.0- Full vocabulary
topK - Limit vocabulary choices
50- Standard (default)100- More varied
streaming - Enable real-time streaming
true- Stream responses (default)false- Wait for complete response
Database Configuration
Configure session persistence:
{
"database": {
"path": "~/.sylphx-code/data/sessions.db",
"autoMigrate": true,
"backupEnabled": true,
"backupInterval": 86400
}
}Options:
- path - Database file location
- autoMigrate - Run migrations automatically
- backupEnabled - Enable automatic backups
- backupInterval - Backup interval in seconds (default: 24 hours)
UI Configuration
Terminal UI Settings
{
"tui": {
"theme": "dark",
"vim_mode": true,
"autocomplete": true,
"notifications": true,
"stats": true
}
}Options:
- theme - Color scheme (
dark|light) - vim_mode - Enable Vim keybindings
- autocomplete - Enable smart autocomplete
- notifications - Enable OS notifications
- stats - Show real-time statistics
Web UI Settings
{
"web": {
"port": 3001,
"theme": "auto",
"animations": true
}
}Options:
- port - Web server port
- theme - Theme mode (
auto|dark|light) - animations - Enable UI animations
Server Configuration
Daemon Mode
{
"server": {
"port": 3000,
"host": "0.0.0.0",
"cors": {
"enabled": true,
"origins": ["http://localhost:3001"]
}
}
}Options:
- port - Server port
- host - Bind address (
0.0.0.0for all interfaces) - cors.enabled - Enable CORS
- cors.origins - Allowed origins
Event Stream
{
"eventStream": {
"bufferSize": 100,
"bufferTime": 300000,
"cleanupInterval": 60000
}
}Options:
- bufferSize - Number of events to buffer (default: 100)
- bufferTime - Buffer retention time in ms (default: 5 minutes)
- cleanupInterval - Cleanup interval in ms (default: 1 minute)
Tool Configuration
Configure built-in tools:
{
"tools": {
"bash": {
"timeout": 120000,
"maxConcurrent": 5
},
"file": {
"maxSize": 5242880,
"allowedExtensions": [".ts", ".js", ".json", ".md"]
},
"notifications": {
"enabled": true,
"sound": true
}
}
}Bash Tool:
- timeout - Command timeout in ms (default: 2 minutes)
- maxConcurrent - Max concurrent commands (default: 5)
File Tool:
- maxSize - Max file size in bytes (default: 5MB)
- allowedExtensions - File type whitelist
Notifications:
- enabled - Enable OS notifications
- sound - Play notification sound
Debug Configuration
Configure logging and debugging:
{
"debug": {
"enabled": true,
"namespaces": ["sylphx:stream:*", "sylphx:tool:*"],
"logFile": "~/.sylphx-code/logs/debug.log"
}
}Options:
- enabled - Enable debug logging
- namespaces - Debug namespaces (array of patterns)
- logFile - Log file path (optional)
Environment Variable:
DEBUG=sylphx:* bun dev:codeEnvironment Variables
All configuration can be set via environment variables:
# AI Provider
export CODE_AI_PROVIDER=openrouter
export CODE_AI_MODEL=anthropic/claude-3.5-sonnet
export OPENROUTER_API_KEY=your-key
# Server
export CODE_SERVER_PORT=3000
export CODE_SERVER_HOST=0.0.0.0
# Database
export CODE_DATABASE_PATH=~/.sylphx-code/data/sessions.db
# Debug
export DEBUG=sylphx:*Priority: Environment variables override config file settings.
Example Configurations
Development Setup
{
"ai": {
"provider": "openrouter",
"model": "anthropic/claude-3-haiku",
"temperature": 0.7
},
"debug": {
"enabled": true,
"namespaces": ["sylphx:*"]
},
"tui": {
"vim_mode": true,
"autocomplete": true
}
}Production Setup
{
"ai": {
"provider": "anthropic",
"model": "claude-3-5-sonnet-20241022",
"temperature": 0.5,
"maxTokens": 4096
},
"server": {
"port": 3000,
"host": "0.0.0.0"
},
"database": {
"backupEnabled": true,
"backupInterval": 43200
},
"debug": {
"enabled": false
}
}Performance Optimized
{
"ai": {
"provider": "openrouter",
"model": "anthropic/claude-3-haiku",
"maxTokens": 2048,
"streaming": true
},
"eventStream": {
"bufferSize": 50,
"bufferTime": 60000
},
"tools": {
"bash": {
"timeout": 60000,
"maxConcurrent": 3
}
}
}Cost Optimized
{
"ai": {
"provider": "openrouter",
"model": "openai/gpt-3.5-turbo",
"temperature": 0.7,
"maxTokens": 1024
},
"eventStream": {
"bufferSize": 25,
"bufferTime": 30000
}
}Configuration Management
View Current Configuration
# From code (coming soon)
/config showUpdate Configuration
Via file:
# Edit user config
nano ~/.sylphx-code/config.json
# Edit project config
nano ./.sylphx-code/config.jsonVia command (coming soon):
/config set ai.model claude-3-opus
/config set ai.temperature 0.8Reset to Defaults
# Remove config files
rm ~/.sylphx-code/config.json
rm ./.sylphx-code/config.json
# Restart Code
bun dev:codeBest Practices
Security
- Never commit API keys to version control
- Use environment variables for sensitive data
- Restrict server host to
127.0.0.1if local-only - Use
.gitignorefor config files with secrets
Performance
- Use faster models for simple tasks (Claude Haiku, GPT-3.5)
- Reduce buffer sizes if memory is limited
- Disable debug logging in production
- Set appropriate tool timeouts
Cost Management
- Monitor token usage with
/stats - Use cheaper models when appropriate
- Set reasonable
maxTokenslimits - Compact sessions regularly
Development
- Enable debug logging for troubleshooting
- Use separate configs for dev/prod
- Test with fast models first
- Keep backups enabled
Troubleshooting
API Key Issues
Not found:
# Check environment
echo $OPENROUTER_API_KEY
# Set if missing
export OPENROUTER_API_KEY=your-keyConfiguration Not Loading
Check file location:
ls -la ~/.sylphx-code/config.jsonValidate JSON:
cat ~/.sylphx-code/config.json | jq .Performance Issues
Reduce buffer sizes:
{
"eventStream": {
"bufferSize": 25,
"bufferTime": 60000
}
}Use faster models:
{
"ai": {
"model": "anthropic/claude-3-haiku"
}
}Next Steps
- Usage Guide - Learn how to use Code
- Architecture - Understand the system
- Development - Contribute to Code