Installation Guide¶
Quick Start¶
Prerequisites¶
- Python 3.10 or higher
- Git
- LLM API key (OpenAI or xAI Grok)
Installation¶
-
Clone the repository:
-
Install LawMode:
Or with development dependencies:
-
Set up environment variables:
-
Configure LawMode:
-
Test installation:
Docker Installation¶
Build Docker Image¶
Run with Docker Compose¶
# Set environment variables in .env file
echo "OPENAI_API_KEY=your-key" > .env
# Run
docker-compose up
VSCode Extension¶
- Open VSCode
- Go to Extensions (Cmd+Shift+X)
- Search for "LawMode"
- Click Install
Or install from source:
Then press F5 in VSCode to run the extension in a new window.
GitHub Integration¶
GitHub Actions¶
The .github/workflows/lawmode.yml file is included. To use it:
- Copy the workflow to your repository's
.github/workflows/directory - Add your LLM API key as a GitHub secret:
- Go to Settings → Secrets and variables → Actions
- Add
OPENAI_API_KEYorXAI_API_KEY
GitHub App (Coming Soon)¶
The GitHub App is under development. For now, use GitHub Actions.
Configuration¶
See .lawmode/policy.yaml for configuration options:
jurisdictions: List of jurisdictions to checkseverity_gating: How to handle risks by severitydomains: Industry domains (auto-detected)llm: LLM provider and model settings
LLM Provider Configuration¶
LawMode supports two LLM providers:
OpenAI¶
- API Key:
OPENAI_API_KEY - Default Model:
gpt-4o - Available Models:
gpt-4o,gpt-4-turbo,gpt-4,gpt-3.5-turbo - Get API Key: https://platform.openai.com/api-keys
xAI Grok¶
- API Key:
XAI_API_KEYorGROK_API_KEY - Default Model:
grok-2-1212 - Available Models:
grok-2-1212- Latest stable model (recommended)grok-3- Latest Grok 3 modelgrok-3-mini- Smaller, faster Grok 3grok-4-0709- Grok 4 modelgrok-4-fast-reasoning- Fast reasoning variantgrok-4-fast-non-reasoning- Fast non-reasoning variantgrok-code-fast-1- Code-specific modelgrok-2-vision-1212- Vision-capable model- Get API Key: https://console.x.ai/
Configure in .lawmode/policy.yaml:
Or via environment variables:
Troubleshooting¶
Import Errors¶
If you see import errors, make sure all dependencies are installed:
API Key Issues¶
Make sure your API key is set:
echo $OPENAI_API_KEY # Should show your OpenAI key
echo $XAI_API_KEY # Should show your xAI Grok key
xAI Grok API Key Troubleshooting:
- API keys start with xai- prefix
- Verify key format: echo $XAI_API_KEY | head -c 10
- Check key hasn't expired or been revoked
- Get new key from: https://console.x.ai/
Model Not Found Errors:
- For Grok: Use valid model name (see list above)
- Default models: gpt-4o (OpenAI) or grok-2-1212 (Grok)
- Check available models in .env.example
Permission Errors¶
If you get permission errors, try: