A CLI tool that starts the anthropic-proxy server configured for xAI API with Grok model and then runs claude-code. When claude-code exits, the proxy is automatically stopped.
npm install -g grok-cliOr run directly with npx:
npx grok-cli# First time - will prompt for Grok API key and store it in keychain
grok
# Using command line option to set/update API key
grok --api-key your-grok-api-key
# With custom port
grok --port 3001
# With custom models
grok --reasoning-model "grok-4" --completion-model "grok-3"
# With custom base URL (without /v1)
grok --base-url https://custom-api-endpoint.com
# Enable debug logging
grok --debug
# Reset stored API key
grok --reset-key- -k, --api-key <key>: Grok API key (will be stored in macOS keychain)
- -p, --port <port>: Port for the proxy server (default: 3000)
- --base-url <url>: Base URL for the API endpoint (default: https://api.x.ai)
- --reasoning-model <model>: Reasoning model to use (default: grok-4)
- --completion-model <model>: Completion model to use (default: grok-3)
- --debug: Enable debug logging
- --reset-key: Reset the stored API key
- 🔐 Secure Key Storage: API keys are stored securely in macOS keychain
- 🤖 Grok Model: Uses xAI Grok 4 Instruct model by default
- 🚀 Simple Setup: Just run grokand it handles everything
- 🔄 Auto Cleanup: Automatically stops proxy when claude-code exits
- Node.js 14 or higher
- macOS (for keychain integration)
- claude-codeinstalled and available in PATH
- Visit xAI Console
- Sign up or log in
- Create a new API key
- Run grokand enter your key when prompted
- Securely retrieves or prompts for your Grok API key
- Starts a built-in proxy server that translates Anthropic API calls to Grok API format
- Configures the proxy to use the specified API endpoint (default: https://api.x.ai) with Grok models
- Sets the ANTHROPIC_BASE_URLenvironment variable to point to the local proxy
- Launches claude-code with the configured environment
- When claude-code exits, automatically stops the proxy server
If you encounter keychain permission issues, you can:
- Run grok --reset-keyto clear stored credentials
- Use grok --api-key your-keyto bypass keychain storage
- To update your API key: grok --api-key new-key
- To reset stored key: grok --reset-key
- Keys are stored under service "grok-cli" in your keychain
MIT
Anthropic proxy code is based on https://github.com/maxnowack/anthropic-proxy