|
| 1 | +# Full Agent Loop - Local Development Setup |
| 2 | + |
| 3 | +This document captures the complete setup process for running Helicone locally and testing the full request flow from client to LLM provider and back through the observability pipeline. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +Before starting, ensure you have: |
| 8 | +- Docker installed and running |
| 9 | +- Homebrew (macOS) |
| 10 | +- NVM (Node Version Manager) |
| 11 | + |
| 12 | +### Node.js Setup |
| 13 | + |
| 14 | +```bash |
| 15 | +# Install NVM if not already installed |
| 16 | +# https://github.com/nvm-sh/nvm |
| 17 | + |
| 18 | +# Install and use Node 22 |
| 19 | +nvm install 22 |
| 20 | +nvm use 22 |
| 21 | +``` |
| 22 | + |
| 23 | +## Infrastructure Setup |
| 24 | + |
| 25 | +### 1. Start Supabase |
| 26 | + |
| 27 | +```bash |
| 28 | +# Start Supabase (excluding unnecessary services for local dev) |
| 29 | +npx supabase start -x realtime,storage-api,imgproxy,mailpit,edge-runtime,logflare,vector,supavisor |
| 30 | +``` |
| 31 | + |
| 32 | +### 2. Start Docker Services (MinIO & ClickHouse) |
| 33 | + |
| 34 | +```bash |
| 35 | +# Start MinIO (object storage) and ClickHouse (analytics) |
| 36 | +docker compose up minio minio-setup clickhouse -d |
| 37 | +``` |
| 38 | + |
| 39 | +### 3. Run ClickHouse Migrations |
| 40 | + |
| 41 | +```bash |
| 42 | +# Set up Python virtual environment |
| 43 | +python3 -m venv venv |
| 44 | +source venv/bin/activate |
| 45 | + |
| 46 | +# Install dependencies |
| 47 | +python3 -m pip install tabulate yarl |
| 48 | + |
| 49 | +# Run ClickHouse migrations |
| 50 | +python3 clickhouse/ch_hcone.py --upgrade --skip-confirmation --no-password |
| 51 | +``` |
| 52 | + |
| 53 | +### 4. Seed Data |
| 54 | + |
| 55 | +The seed file at `supabase/seeds/0_seed.sql` creates test users and organizations. This is typically applied automatically when Supabase starts. |
| 56 | + |
| 57 | +### Infrastructure Summary |
| 58 | + |
| 59 | +After these steps, you'll have running: |
| 60 | +- **Supabase** (PostgreSQL) - Application data |
| 61 | +- **ClickHouse** - Analytics/time-series data |
| 62 | +- **MinIO** - Object storage |
| 63 | + |
| 64 | +## Services |
| 65 | + |
| 66 | +### Start All Services |
| 67 | + |
| 68 | +Run each in a separate terminal: |
| 69 | + |
| 70 | +```bash |
| 71 | +# Terminal 1 - Jawn (Backend API) |
| 72 | +cd valhalla/jawn && yarn dev |
| 73 | +# Runs on http://localhost:8585 |
| 74 | + |
| 75 | +# Terminal 2 - Web (Frontend) |
| 76 | +cd web && yarn dev:local -p 3000 |
| 77 | +# Runs on http://localhost:3000 |
| 78 | + |
| 79 | +# Terminal 3 - Gateway Worker (Proxy) |
| 80 | +cd worker && npx wrangler dev --var WORKER_TYPE:GATEWAY_API --port 8789 |
| 81 | +# Runs on http://localhost:8789 |
| 82 | +``` |
| 83 | + |
| 84 | +### Service Health Checks |
| 85 | + |
| 86 | +```bash |
| 87 | +# Jawn health check |
| 88 | +curl http://localhost:8585/healthcheck |
| 89 | +# Expected: {"status":"healthy :)"} |
| 90 | +``` |
| 91 | + |
| 92 | +## Test Credentials |
| 93 | + |
| 94 | +From `supabase/seeds/0_seed.sql`: |
| 95 | + |
| 96 | +| User | Email | Helicone API Key | Organization | |
| 97 | +|------|-------|------------------|--------------| |
| 98 | +| Test | test@helicone.ai | `sk-helicone-aizk36y-5yue2my-qmy5tza-n7x3aqa` | Organization for Test | |
| 99 | +| Admin | admin@helicone.ai | `sk-helicone-zk6xu4a-kluegtq-sbljk7q-drnixzi` | Admin | |
| 100 | + |
| 101 | +**Login password**: `password` |
| 102 | + |
| 103 | +## Testing the Full Loop |
| 104 | + |
| 105 | +### Send a Test Request |
| 106 | + |
| 107 | +Use the Gateway Worker (port 8789) with `Helicone-Target-Url` header to proxy requests: |
| 108 | + |
| 109 | +```bash |
| 110 | +curl -X POST "http://localhost:8789/v1beta/models/gemini-2.0-flash:generateContent" \ |
| 111 | + -H "Content-Type: application/json" \ |
| 112 | + -H "Helicone-Auth: Bearer sk-helicone-aizk36y-5yue2my-qmy5tza-n7x3aqa" \ |
| 113 | + -H "Helicone-Target-Url: https://generativelanguage.googleapis.com" \ |
| 114 | + -H "x-goog-api-key: YOUR_GEMINI_API_KEY" \ |
| 115 | + -d '{ |
| 116 | + "contents": [{ |
| 117 | + "parts": [{"text": "Say hello in exactly 3 words"}] |
| 118 | + }] |
| 119 | + }' |
| 120 | +``` |
| 121 | + |
| 122 | +### Verify in Dashboard |
| 123 | + |
| 124 | +1. Navigate to http://localhost:3000 |
| 125 | +2. Sign in with `test@helicone.ai` / `password` |
| 126 | +3. **Important**: Switch to "Organization for Test" using the org selector (top-left) |
| 127 | +4. Go to Requests page to see logged requests |
| 128 | + |
| 129 | +## Data Flow Architecture |
| 130 | + |
| 131 | +``` |
| 132 | +┌─────────────┐ ┌─────────────────┐ ┌─────────────────┐ |
| 133 | +│ Client │────▶│ Gateway Worker │────▶│ LLM Provider │ |
| 134 | +│ (curl) │ │ (port 8789) │ │ (Gemini, etc.) │ |
| 135 | +└─────────────┘ └────────┬────────┘ └─────────────────┘ |
| 136 | + │ |
| 137 | + │ Logs request/response |
| 138 | + ▼ |
| 139 | + ┌─────────────────┐ |
| 140 | + │ Jawn │ |
| 141 | + │ (port 8585) │ |
| 142 | + └────────┬────────┘ |
| 143 | + │ |
| 144 | + ┌──────────────┼──────────────┐ |
| 145 | + ▼ ▼ ▼ |
| 146 | + ┌──────────┐ ┌───────────┐ ┌──────────┐ |
| 147 | + │ Postgres │ │ClickHouse │ │ MinIO │ |
| 148 | + │ (Supa) │ │(Analytics)│ │ (Files) │ |
| 149 | + └──────────┘ └───────────┘ └──────────┘ |
| 150 | + │ |
| 151 | + ▼ |
| 152 | + ┌─────────────────┐ |
| 153 | + │ Web (UI) │ |
| 154 | + │ (port 3000) │ |
| 155 | + └─────────────────┘ |
| 156 | +``` |
| 157 | + |
| 158 | +## Key Learnings |
| 159 | + |
| 160 | +### 1. Organization Context Matters |
| 161 | + |
| 162 | +Requests are scoped to organizations via the Helicone API key. When viewing the dashboard: |
| 163 | +- The default "My Organization" shows demo/preview data |
| 164 | +- You must switch to the correct org (e.g., "Organization for Test") to see actual requests |
| 165 | + |
| 166 | +### 2. Worker Types |
| 167 | + |
| 168 | +Different worker types serve different purposes: |
| 169 | + |
| 170 | +| Port | Worker Type | Use Case | |
| 171 | +|------|-------------|----------| |
| 172 | +| 8787 | `OPENAI_PROXY` | OpenAI-specific proxy | |
| 173 | +| 8788 | `HELICONE_API` | Helicone API worker | |
| 174 | +| 8789 | `GATEWAY_API` | Generic gateway (any provider) | |
| 175 | +| 8790 | `ANTHROPIC_PROXY` | Anthropic-specific proxy | |
| 176 | +| 8793 | `AI_GATEWAY_API` | Unified routing with billing | |
| 177 | + |
| 178 | +For testing with arbitrary providers (like Gemini), use `GATEWAY_API` (8789) with the `Helicone-Target-Url` header. |
| 179 | + |
| 180 | +### 3. Authentication Headers |
| 181 | + |
| 182 | +- `Helicone-Auth: Bearer <api-key>` - Authenticates with Helicone |
| 183 | +- `Helicone-Target-Url: <provider-base-url>` - Specifies the LLM provider |
| 184 | +- Provider-specific auth (e.g., `x-goog-api-key` for Gemini) |
| 185 | + |
| 186 | +### 4. Demo Data vs Real Data |
| 187 | + |
| 188 | +The dashboard shows demo/preview data when: |
| 189 | +- No requests have been logged for the organization |
| 190 | +- You're viewing the wrong organization |
| 191 | + |
| 192 | +Look for the banner: "This is a preview. Integrate your LLM app with Helicone to see your actual requests." |
| 193 | + |
| 194 | +### 5. Web Dev Command Variants |
| 195 | + |
| 196 | +- `yarn dev:better-auth` - Uses better-auth authentication (may require additional setup) |
| 197 | +- `yarn dev:local -p 3000` - Simpler local development mode |
| 198 | + |
| 199 | +## Troubleshooting |
| 200 | + |
| 201 | +### Request Not Appearing in Dashboard |
| 202 | + |
| 203 | +1. Verify you're in the correct organization |
| 204 | +2. Check Jawn logs for errors: `tail -f /tmp/claude/.../tasks/<jawn-task-id>.output` |
| 205 | +3. Ensure the Helicone API key matches the organization |
| 206 | + |
| 207 | +### Worker Connection Issues |
| 208 | + |
| 209 | +- Ensure Jawn is running before making requests through the worker |
| 210 | +- Check that the worker can reach Jawn at localhost:8585 |
| 211 | + |
| 212 | +### Database Connection Issues |
| 213 | + |
| 214 | +- Verify Supabase is running: `docker ps | grep supabase` |
| 215 | +- Check ClickHouse: `docker ps | grep clickhouse` |
| 216 | + |
| 217 | +## Next Steps |
| 218 | + |
| 219 | +With the full loop working, you can now: |
| 220 | +1. Test different LLM providers through the gateway |
| 221 | +2. Explore request logging and analytics |
| 222 | +3. Build features on top of the observability pipeline |
| 223 | +4. Test caching, rate limiting, and other Helicone features |
0 commit comments