https://github.com/langwatch/langwatch-cursor-proxy
https://github.com/langwatch/langwatch-cursor-proxy
Last synced: 19 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/langwatch/langwatch-cursor-proxy
- Owner: langwatch
- Created: 2025-09-22T14:52:30.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-10-13T12:24:31.000Z (10 months ago)
- Last Synced: 2025-10-19T04:38:19.767Z (10 months ago)
- Language: Python
- Size: 181 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LangWatch Cursor Proxy
A simple LiteLLM proxy that integrates with Cursor and sends tracing data to [LangWatch](https://docs.langwatch.ai/integration/overview).
## Features
- 🚀 **Simple Setup**: One-command installation and configuration
- 🔍 **LangWatch Integration**: Automatic tracing with OpenTelemetry or LangWatch SDK
- 🎯 **Cursor Compatible**: Works seamlessly with Cursor's OpenAI base URL override
- ⚡ **Low Latency**: Async, non-blocking tracing that doesn't slow down requests
- 🌐 **External Access**: Built-in cloudflared tunnel support for remote development
## Quick Start
### 1. Initialize the Project
```bash
make init
```
### 2. Configure API Keys
Edit the generated `.env` file with your API keys:
```bash
# Required
LITELLM_MASTER_KEY="lw_local_dev"
OPENAI_API_KEY="sk-your-openai-api-key"
# Optional - for LangWatch tracing
LANGWATCH_API_KEY="your-langwatch-api-key"
```
### 3. Start the Proxy
```bash
# Start with OTEL tracing (recommended)
make start-proxy
# OR start with LangWatch SDK tracing
make start-proxy-langwatch-sdk
```
The proxy will be available at `http://localhost:4000`.
### 4. Set Up External Access
Cursor requires external access and won't work with localhost URLs. Start a cloudflared tunnel:
```bash
# In a separate terminal, after starting the proxy
make start-tunnel
```
This provides a public URL that tunnels to your local proxy. The command will display the configuration automatically.
### 5. Configure Cursor
1. Open Cursor → Settings → Models
2. Enable "Override OpenAI Base URL" and OpenAI API Key
3. Set Base URL to: Use the tunnel URL from `make start-tunnel` output
4. Set API Key to: `lw_local_dev` (or your LITELLM_MASTER_KEY)
### 6. Test the Integration
```bash
make test-endpoint
```
Now use Cursor normally - all requests will be traced in your LangWatch dashboard!
## Configuration
### Environment Variables
| Variable | Required | Description |
| -------------------- | -------- | ------------------------------------------------- |
| `LITELLM_MASTER_KEY` | ✅ | Proxy authentication key (use this in Cursor) |
| `LANGWATCH_API_KEY` | ⚠️ | LangWatch API key (tracing disabled without this) |
| `OPENAI_API_KEY` | ✅ | OpenAI API key for GPT models |
### Adding More Models
Edit `config-otel.yaml` or `config-langwatch-sdk.yaml` following the [LiteLLM configuration documentation](https://docs.litellm.ai/docs/proxy/configs):
```yaml
model_list:
- model_name: gpt-4o
litellm_params:
model: openai/gpt-4o
api_key: os.environ/OPENAI_API_KEY
- model_name: claude-3-sonnet
litellm_params:
model: anthropic/claude-3-sonnet-20240229
api_key: os.environ/ANTHROPIC_API_KEY
```
## Available Commands
```bash
make help # Show all available commands
make init # Setup project and dependencies
make start-db # Start PostgreSQL database
make stop-db # Stop PostgreSQL database
make start-proxy # Start with OTEL tracing (recommended)
make start-proxy-langwatch-sdk # Start with LangWatch SDK tracing
make start-tunnel # Start cloudflared tunnel (for external access)
make stop-tunnel # Stop cloudflared tunnel
make tunnel-logs # View tunnel logs
make test-endpoint # Test the running proxy
```
## Tunnel Management
The project includes built-in cloudflared tunnel support for external access:
- **`make start-tunnel`** - Creates a public tunnel to your local proxy
- **`make stop-tunnel`** - Stops the tunnel
- **`make tunnel-logs`** - View tunnel logs
**Requirements**: Docker (no cloudflared installation needed)
**Usage**:
1. Start your proxy: `make start-proxy`
2. Start tunnel: `make start-tunnel` (required for Cursor)
3. Copy the displayed URL to Cursor settings
4. Stop tunnel: `make stop-tunnel` (when done)
## License
MIT