JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 10
  • Score
    100M100P100Q32979F
  • License MIT

LLM API gateway with intelligent routing, robust process management, and health monitoring

Package Exports

  • @tehreet/conduit
  • @tehreet/conduit/dist/cli.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@tehreet/conduit) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Conduit

LLM API gateway with intelligent routing, robust process management, and health monitoring capabilities.

npm version License: MIT

Features

🚀 Enhanced Process Management

  • Robust PID file handling with file locking
  • Graceful shutdown with connection draining
  • Automatic cleanup and recovery

📊 Health Monitoring

  • Built-in health check endpoints (/health, /ready, /alive)
  • Production-ready monitoring integration
  • Process metrics and status reporting

🔧 Production Deployment

  • PM2 ecosystem configuration included
  • Systemd service file for Linux servers
  • Docker-ready setup

🛡️ Reliability

  • Zero data loss during restarts
  • Configurable shutdown timeouts
  • Automatic resource cleanup

Installation

# Install globally
npm install -g conduit

# Or install locally
npm install conduit

Quick Start

  1. Create configuration file at ~/.claude-code-router/config.json:
{
  "Providers": [
    {
      "name": "gemini",
      "api_base_url": "https://generativelanguage.googleapis.com/v1beta/models/",
      "api_key": "YOUR_API_KEY",
      "models": ["gemini-2.5-flash", "gemini-2.5-pro"],
      "transformer": {
        "use": ["gemini"]
      }
    }
  ],
  "Router": {
    "default": "gemini,gemini-2.5-flash"
  }
}
  1. Start the service:
conduit start
  1. Check status:
conduit status
  1. Test health endpoint:
curl http://localhost:3456/health

Commands

conduit start          # Start the service
conduit stop           # Stop the service gracefully  
conduit status         # Show service status
conduit code "prompt"  # Execute code command
conduit --help         # Show help information

Health Endpoints

  • GET /health - Basic health status
  • GET /ready - Readiness probe (K8s compatible)
  • GET /alive - Liveness probe with metrics

Example response:

{
  "status": "ok",
  "timestamp": "2024-01-15T10:30:00.000Z",
  "uptime": 3600,
  "pid": 12345
}

Production Deployment

# Install PM2
npm install -g pm2

# Start with PM2 using included config
pm2 start ecosystem.config.js

# Save PM2 state
pm2 save && pm2 startup

Systemd (Linux)

# Install as system service
sudo ./scripts/install-systemd.sh

# Manage with systemctl
sudo systemctl start conduit
sudo systemctl status conduit

Docker

FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY dist ./dist
EXPOSE 3456
CMD ["npm", "start"]

Configuration

Supported Providers

  • OpenRouter - Multiple model access
  • Gemini - Google's Gemini models
  • DeepSeek - DeepSeek models with tool use
  • Ollama - Local model serving
  • VolcEngine - Enterprise AI platform

Environment Variables

  • SERVICE_PORT - Port to run on (default: 3456)
  • NODE_ENV - Environment (development/production)
  • CONFIG_PATH - Custom config file path

Monitoring Integration

Prometheus

scrape_configs:
  - job_name: 'claude-code-router'
    static_configs:
      - targets: ['localhost:3456']
    metrics_path: '/health'

Kubernetes

livenessProbe:
  httpGet:
    path: /alive
    port: 3456
  initialDelaySeconds: 10

readinessProbe:
  httpGet:
    path: /ready
    port: 3456
  initialDelaySeconds: 5

API Usage

Send requests to the router exactly like the Claude API:

curl -X POST http://localhost:3456/v1/messages \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-2.5-flash",
    "messages": [
      {"role": "user", "content": "Hello, world!"}
    ]
  }'

Troubleshooting

Service Won't Start

# Check if port is in use
lsof -i :3456

# Check PID file
cat ~/.claude-code-router/.claude-code-router.pid

# View logs (PM2)
pm2 logs conduit

Health Check Fails

# Test endpoints
curl http://localhost:3456/health
curl http://localhost:3456/ready
curl http://localhost:3456/alive

# Check service status
conduit status

Development

# Clone repository
git clone https://github.com/vibe-coders-only/conduit.git
cd conduit

# Install dependencies
npm install

# Build project
npm run build

# Start development server
npm start

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Support

Changelog

v2.0.0

  • ✅ Enhanced process management with file locking
  • ✅ Graceful shutdown with connection draining
  • ✅ Health monitoring endpoints
  • ✅ PM2 and systemd integration
  • ✅ Production deployment configurations