Use Claude 4 for just $20 flat from your command line. This cross-platform application provides an OpenAI-compatible API wrapper for Khoj, allowing you to access Claude Sonnet 4 and other premium AI models through any OpenAI-compatible client at a fraction of the cost.
Supports Windows, macOS, and Linux with identical functionality across all platforms.
- π° Cost-effective: Access Claude Sonnet 4 for $20/month flat rate through Khoj
- π OpenAI Compatible: Works with any OpenAI API client (aichat, Continue.dev, etc.)
- π’ Corporate Friendly: Works seamlessly in corporate environments with proxy support
- π₯οΈ Cross-Platform: Native system tray integration on Windows, macOS, and Linux
- π Silent Operation: Windows version runs without console window (background operation)
- π Clipboard AI: Windows-only feature to process clipboard content with AI via Ctrl+Q shortcut
- π File Support: Handle file uploads and code diffs for development workflows
- π Auto-start: Configure for system startup across all platforms
- π CORS Enabled: Full web client compatibility
- π Health Monitoring: Built-in health check endpoint
- ποΈ GUI Management: Web-based conversation and agent management
Download the latest release for your platform from the Releases page:
- Windows (64-bit):
khoj-wrapper-windows-amd64.exe - macOS (Intel):
khoj-wrapper-macos-amd64 - macOS (Apple Silicon):
khoj-wrapper-macos-arm64 - Linux (64-bit):
khoj-wrapper-linux-amd64
# Example for Linux (replace with your platform)
wget https://github.com/yourusername/khojWrapper/releases/latest/download/khoj-wrapper-linux-amd64
chmod +x khoj-wrapper-linux-amd64
./khoj-wrapper-linux-amd64# Download checksum file
wget https://github.com/yourusername/khojWrapper/releases/latest/download/khoj-wrapper-linux-amd64.sha256
# Verify integrity
sha256sum -c khoj-wrapper-linux-amd64.sha256# Clone the repository
git clone https://github.com/yourusername/khojWrapper.git
cd khojWrapper
# Install dependencies
go mod tidy
# Build for your current platform
go build -o khoj-wrapper khoj_provider.go
# Run
./khoj-wrapper# Build for Windows (from any platform)
GOOS=windows GOARCH=amd64 go build -o khoj-wrapper.exe khoj_provider.go
# Build for macOS (from any platform)
GOOS=darwin GOARCH=amd64 go build -o khoj-wrapper-macos khoj_provider.go
# Build for Linux (from any platform)
GOOS=linux GOARCH=amd64 go build -o khoj-wrapper-linux khoj_provider.go
# Build for ARM64 (Apple Silicon, Raspberry Pi, etc.)
GOOS=darwin GOARCH=arm64 go build -o khoj-wrapper-macos-arm64 khoj_provider.go
GOOS=linux GOARCH=arm64 go build -o khoj-wrapper-linux-arm64 khoj_provider.goThis wrapper is compatible with aichat and other OpenAI-compatible clients.
Add to your ~/.config/aichat/config.yaml:
clients:
- type: openai
name: khoj
api_base: http://localhost:3002/v1
api_key: dummy
models:
- name: khoj-chat
max_input_tokens: 40960
max_output_tokens: 2048Then use with:
aichat -m khoj-chat "Hello Claude!"Add to your Continue configuration:
{
"models": [
{
"title": "Khoj Claude",
"provider": "openai",
"model": "khoj-chat",
"apiBase": "http://localhost:3002/v1",
"apiKey": "your-khoj-api-key"
}
]
}Note: For now only chat will work.
- Set Khoj API Key (Required):
- Press
Win + R, typesysdm.cpl, press Enter - Click "Environment Variables"
- Under "User variables", click "New"
- Variable name:
KHOJ_API_KEY - Variable value: Your Khoj API key from app.khoj.dev
- Press
-
Set Khoj API Key (Required):
# Add to your shell profile (~/.bashrc, ~/.zshrc, etc.) export KHOJ_API_KEY="your-khoj-api-key-here" # Or set temporarily for current session export KHOJ_API_KEY="your-khoj-api-key-here"
-
Optional Environment Variables:
KHOJ_API_BASE=https://app.khoj.dev (default) PORT=3002 (default) KHOJ_TIMEOUT=120s (default)
-
Using Startup Folder (Recommended):
- Press
Win + R, typeshell:startup, press Enter - Copy
khoj-wrapper.exeto this folder - The application will start automatically on Windows boot
- Press
-
Using Task Scheduler (Advanced):
- Open Task Scheduler
- Create Basic Task β "Khoj Wrapper"
- Trigger: "When the computer starts"
- Action: "Start a program"
- Program: Path to
khoj-wrapper.exe - Check "Run with highest privileges"
-
Using Login Items:
- System Preferences β Users & Groups β Login Items
- Click "+" and add
khoj-wrapper-macos - The application will start automatically on login
-
Using LaunchAgent (Advanced):
# Create launch agent file cat > ~/Library/LaunchAgents/com.khoj.wrapper.plist << EOF <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.khoj.wrapper</string> <key>ProgramArguments</key> <array> <string>/path/to/khoj-wrapper-macos</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist> EOF # Load the launch agent launchctl load ~/Library/LaunchAgents/com.khoj.wrapper.plist
-
Using Autostart Desktop Entry:
# Create autostart directory if it doesn't exist mkdir -p ~/.config/autostart # Create desktop entry cat > ~/.config/autostart/khoj-wrapper.desktop << EOF [Desktop Entry] Type=Application Name=Khoj Wrapper Exec=/path/to/khoj-wrapper-linux Hidden=false NoDisplay=false X-GNOME-Autostart-enabled=true EOF
-
Using systemd user service (Advanced):
# Create service file cat > ~/.config/systemd/user/khoj-wrapper.service << EOF [Unit] Description=Khoj Wrapper Service After=graphical-session.target [Service] Type=simple ExecStart=/path/to/khoj-wrapper-linux Restart=always [Install] WantedBy=default.target EOF # Enable and start the service systemctl --user daemon-reload systemctl --user enable khoj-wrapper.service systemctl --user start khoj-wrapper.service
- Visit app.khoj.dev
- Sign up for a $20/month subscription
- Go to Settings β API Keys
- Generate a new API key
- Set it as the
KHOJ_API_KEYenvironment variable
- Start the wrapper: Run
khoj-wrapper.exe - Automatic conversation creation: The app will automatically create a new conversation on first run
- Conversation persistence: Your conversation ID is saved to
conversation_state.json - Verify it's running: Visit
http://localhost:3002/health - Use with any OpenAI client: Point your client to
http://localhost:3002/v1
khoj-wrapper.exe [options]
Options:
-n Start a new conversation (creates fresh conversation session)
-conversation-id ID Use specific conversation ID (overrides saved state)The application provides a rich system tray interface for conversation management:
- π New Conversation: Click to create a new conversation session instantly
- Conv: ...xxxx: Shows the last 4 characters of your current conversation ID
- βοΈ Edit Conversation ID: Opens a web form to change the active conversation ID
- π€ Agent: Shows the current agent slug being used
- βοΈ Edit Agent Slug: Opens a web form to change the AI agent slug
- π Clipboard AI (Ctrl+Q): Process clipboard content with AI (Windows only)
The Clipboard AI feature allows you to instantly process any text content with AI and insert the response directly at your cursor position.
- Copy text to clipboard (Ctrl+C)
- Position cursor where you want the AI response
- Press Ctrl+Q to trigger AI processing
- Add context (optional) via Windows dialog
- AI response automatically inserted at cursor
- β Global hotkey: Works in any application (Word, Notepad, browsers, etc.)
- β Context dialog: Add custom instructions or prompts
- β 30-second timeout: Automatic timeout with notification
- β Native Windows integration: Uses Windows API for seamless operation
- β Background processing: No interruption to your workflow
- β Smart notifications: Success/error feedback via system tray
- Explain code snippets copied from IDEs
- Improve writing in documents and emails
- Translate text in any application
- Summarize articles from web browsers
- Debug error messages from logs
- Generate responses to messages
1. Copy error message: "TypeError: Cannot read property 'length' of undefined"
2. Position cursor in your code editor
3. Press Ctrl+Q
4. Dialog: "Explain this error and suggest a fix"
5. AI response inserted: "This error occurs when trying to access..."
- Timeout: 30 seconds maximum processing time
- Notifications: System tray alerts for status updates
- Integration: Uses Windows clipboard and input APIs
- Compatibility: Works with all Windows applications that accept text input
- Automatic Creation: If no saved conversation exists, a new one is created automatically
- Persistent State: Conversation IDs are saved in
conversation_state.jsonin the app directory - New Conversations: Use
-nflag or system tray menu to start fresh conversations anytime - Manual Override: Use
-conversation-idto switch to specific conversation contexts
To use different AI agents (models), you need to find their agent slugs from the Khoj web interface:
- Open Khoj Web App: Go to app.khoj.dev in your browser
- Open Developer Tools: Press
F12or right-click β "Inspect Element" - Go to Network Tab: Click the "Network" tab in developer tools
- Start New Conversation: Click "New Conversation" in the web interface
- Select Your Agent: Choose the AI model/agent you want to use
- Find the Request: Look for a POST request to
/api/chat/sessionsin the network tab - Check Payload: Click on the request and look at the "Payload" or "Request" section
- Copy Agent Slug: Find the
agent_slugvalue (e.g.,"sonnet-short-025716","gpt-4o-mini", etc.)
sonnet-short-025716- Claude Sonnet (default)gpt-4o-mini- GPT-4o Minigpt-4o- GPT-4oo1-preview- OpenAI o1 Previewgemini-pro- Google Gemini Pro
- System Tray Menu: Click "βοΈ Edit Agent Slug" for a user-friendly web form
- Edit JSON File: Alternatively, modify
conversation_state.jsonand change theagent_slugfield - Restart Application: Changes take effect immediately (no restart needed for menu changes)
- System Tray: The current agent is displayed in the system tray menu
The edit functions open a clean web form in your default browser:
- User-friendly interface with proper styling and validation
- Auto-focus and text selection for quick editing
- Automatic saving when you submit the form
- Real-time menu updates to reflect changes
- 5-minute timeout for security (form closes automatically)
The wrapper runs on port 3002 by default and provides these endpoints:
/health- Health check/v1/chat/completions- Chat completions (OpenAI compatible)/v1/completions- Text completions (OpenAI compatible)/v1/models- Available models
- Automatic Conversation Management: Creates and manages Khoj conversation sessions automatically
- Persistent State: Conversation context is maintained across app restarts via JSON file
- Session Creation: Uses Khoj's
/api/chat/sessionsendpoint withsonnet-short-025716agent - Flexible Conversation Control: Switch between conversations or start fresh ones as needed
- System Tray: Full native support
- Browser: Uses default browser via
startcommand - Dependencies: None (self-contained executable)
- Console Window: Hidden by default (runs silently in background)
- Clipboard AI: Exclusive feature - process clipboard content with AI using Ctrl+Q
- System Tray: Full native support (appears in menu bar)
- Browser: Uses default browser via
opencommand - Dependencies: None (self-contained executable)
- Permissions: May require allowing the app in Security & Privacy settings
- System Tray: Requires desktop environment with system tray support
- β KDE, XFCE, MATE, Cinnamon (built-in support)
- β GNOME (requires AppIndicator extension)
- β i3, sway (with status bars like i3status, waybar)
- Browser: Uses default browser via
xdg-opencommand - Dependencies:
xdg-open(usually pre-installed)
- Works behind corporate firewalls and proxies
- No special network configuration required
- All traffic goes through standard HTTPS to Khoj servers
- Can be deployed on internal networks for team use
- Cross-platform deployment for mixed environments
-
Clone the repository:
git clone https://github.com/yourusername/khojWrapper.git cd khojWrapper -
Install dependencies:
go mod tidy
Common Issues:
-
macOS Build Failures:
Error: cgo: C compiler "clang" not found- Cause: Cross-compiling macOS requires clang and CGO
- Quick Fix: Use
build-simple.*scripts (skips macOS on non-macOS) - Complete Fix: Install clang or build on macOS system
- CI/CD: GitHub Actions uses macOS runners automatically
-
Missing Dependencies:
Error: go: module not found- Solution: Run
go mod tidybefore building
- Solution: Run
-
Permission Errors (Linux/macOS):
Error: permission denied- Solution:
chmod +x scripts/build-all.sh
- Solution:
-
CGO Errors on Cross-compilation:
- Solution: Use platform-specific runners in CI/CD
- Local: Build on target platform for best results
MIT License - see LICENSE file for details.
