Complete configuration reference for Codestral CLI.
Codestral CLI supports multiple configuration methods, in order of priority:
- Environment Variables (highest priority)
- Config File (
~/.codestral/config.json) - Command Line Arguments
- Built-in Defaults (lowest priority)
| Variable | Description | Example |
|---|---|---|
MISTRAL_API_KEY |
Your Codestral API key | export MISTRAL_API_KEY="your-key" |
| Variable | Description | Default | Example |
|---|---|---|---|
MISTRAL_MODEL |
AI model to use | codestral-latest |
export MISTRAL_MODEL="codestral-2024" |
MISTRAL_BASE_URL |
API endpoint | https://codestral.mistral.ai/v1 |
export MISTRAL_BASE_URL="https://custom.api.com/v1" |
MISTRAL_MAX_TOKENS |
Default response length | 2048 |
export MISTRAL_MAX_TOKENS=1000 |
MISTRAL_TEMPERATURE |
Response creativity (0-1) | 0.7 |
export MISTRAL_TEMPERATURE=0.1 |
MISTRAL_TIMEOUT |
Request timeout (seconds) | 30 |
export MISTRAL_TIMEOUT=60 |
PYTHONHTTPSVERIFY |
SSL verification | 1 |
export PYTHONHTTPSVERIFY=0 |
# Temporary (current session)
export MISTRAL_API_KEY="your-api-key"
# Permanent (add to ~/.bashrc or ~/.zshrc)
echo 'export MISTRAL_API_KEY="your-api-key"' >> ~/.bashrc
source ~/.bashrc# Temporary
set -x MISTRAL_API_KEY "your-api-key"
# Permanent
set -Ux MISTRAL_API_KEY "your-api-key"# Temporary
$env:MISTRAL_API_KEY="your-api-key"
# Permanent (user level)
[Environment]::SetEnvironmentVariable("MISTRAL_API_KEY", "your-api-key", "User")rem Temporary
set MISTRAL_API_KEY=your-api-key
rem Permanent
setx MISTRAL_API_KEY "your-api-key"The config file is stored at: ~/.codestral/config.json
{
"api_key": "your-api-key-here",
"model": "codestral-latest",
"base_url": "https://codestral.mistral.ai/v1",
"max_tokens": 2048,
"temperature": 0.7,
"timeout": 30,
"show_loader": true,
"conversation_history_limit": 10
}# Create directory
mkdir -p ~/.codestral
# Create config file
cat > ~/.codestral/config.json << EOF
{
"api_key": "your-api-key-here",
"model": "codestral-latest",
"max_tokens": 2000,
"temperature": 0.1
}
EOF| Option | Type | Description | Default |
|---|---|---|---|
api_key |
string | Your Mistral API key | required |
model |
string | AI model identifier | "codestral-latest" |
base_url |
string | API endpoint URL | "https://codestral.mistral.ai/v1" |
max_tokens |
integer | Maximum response tokens | 2048 |
temperature |
float | Response creativity (0.0-1.0) | 0.7 |
timeout |
integer | Request timeout in seconds | 30 |
show_loader |
boolean | Show loading animations | true |
conversation_history_limit |
integer | Max conversation messages | 10 |
codestral-latest- Latest Codestral model (recommended)codestral-2024-05-08- Specific version- Custom models (if available in your subscription)
{
"model": "codestral-latest",
"temperature": 0.1, // Lower = more focused, higher = more creative
"max_tokens": 2048, // Response length limit
"top_p": 0.95 // Nucleus sampling parameter
}- 0.0 - 0.2: Very focused, deterministic responses (good for code)
- 0.3 - 0.7: Balanced creativity and accuracy (default range)
- 0.8 - 1.0: High creativity, more variation (good for brainstorming)
If you're behind a corporate firewall:
# HTTP/HTTPS Proxy
export HTTP_PROXY=http://proxy.company.com:8080
export HTTPS_PROXY=https://proxy.company.com:8080
# With authentication
export HTTP_PROXY=http://username:password@proxy.company.com:8080
export HTTPS_PROXY=https://username:password@proxy.company.com:8080
# No proxy for specific hosts
export NO_PROXY=localhost,127.0.0.1,.company.com# Disable SSL verification (not recommended for production)
export PYTHONHTTPSVERIFY=0
# Custom certificate bundle
export SSL_CERT_FILE=/path/to/your/certificate.pem
export REQUESTS_CA_BUNDLE=/path/to/your/certificate.pem{
"timeout": 30, // API request timeout
"connect_timeout": 10, // Connection timeout
"read_timeout": 60 // Response reading timeout
}{
"max_tokens": 1000, // Smaller for faster responses
"temperature": 0.1, // Lower for more consistent responses
"top_p": 0.9 // Reduce for faster generation
}{
"conversation_history_limit": 5, // Fewer messages for faster processing
"save_history": false // Disable history for privacy
}# Use a separate config file with restricted permissions
chmod 600 ~/.codestral/config.json
# Or use environment variables in a secure shell profile
echo 'export MISTRAL_API_KEY="your-key"' >> ~/.profile
chmod 600 ~/.profile# Force HTTPS verification
export PYTHONHTTPSVERIFY=1
# Use specific certificate bundle
export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crtThe CLI automatically detects terminal capabilities. To force settings:
# Disable rich UI
export TERM=dumb
# Force color support
export FORCE_COLOR=1
# Disable color
export NO_COLOR=1{
"show_loader": true, // Loading animations
"show_progress": true, // Progress indicators
"markdown_support": true, // Rich markdown rendering
"syntax_highlighting": true
}# Environment variable
export CODESTRAL_DEBUG=1
# Or in config file
{
"debug": true,
"log_level": "DEBUG",
"log_file": "~/.codestral/debug.log"
}DEBUG: Detailed debugging informationINFO: General information messagesWARNING: Warning messagesERROR: Error messages only
# In interactive mode
codestral-cli
config
# Or programmatically
python3 -c "
from codestral_cli.core.config import ConfigManager
config = ConfigManager()
print(config.get_model_info())
"# Test with current config
codestral-cli "test connection"
# Test SSL configuration
python3 fix_ssl.py{
"model": "custom-codestral-model",
"base_url": "https://your-custom-endpoint.com/v1",
"api_key": "your-custom-api-key"
}Create different config files for different use cases:
# Work profile
~/.codestral/work-config.json
# Personal profile
~/.codestral/personal-config.json
# Use specific config
codestral-cli --config ~/.codestral/work-config.json "work prompt"# Set multiple environment variables
cat > ~/.codestral/env.sh << EOF
export MISTRAL_API_KEY="your-key"
export MISTRAL_MODEL="codestral-latest"
export MISTRAL_TEMPERATURE=0.1
export MISTRAL_MAX_TOKENS=1500
EOF
# Load configuration
source ~/.codestral/env.sh# Check if config directory exists
ls -la ~/.codestral/
# Create if missing
mkdir -p ~/.codestral
echo '{"api_key": "your-key"}' > ~/.codestral/config.json# Validate JSON syntax
python3 -m json.tool ~/.codestral/config.json
# Fix common issues
# - Remove trailing commas
# - Use double quotes for strings
# - Escape backslashes in paths# Fix permissions
chmod 600 ~/.codestral/config.json
chown $USER ~/.codestral/config.json# Check which config values are being used
from codestral_cli.core.config import ConfigManager
config = ConfigManager()
print(f"API Key: {'Set' if config.api_key else 'Not set'}")
print(f"Model: {config.model}")
print(f"Max Tokens: {config.max_tokens}")
print(f"Temperature: {config.temperature}")- Keep API keys secure - Use environment variables or restricted file permissions
- Use appropriate models - Choose the right model for your use case
- Tune temperature - Lower for code generation, higher for creative tasks
- Monitor usage - Keep track of API usage and costs
- Regular updates - Update configuration as new models become available
- Backup configs - Keep backup copies of working configurations