This is an Express.js application that provides OpenAI-compatible chat completions using Hyperbolic AI, with x402 payment processing integration.
- OpenAI-compatible
/v1/chat/completionsendpoint - Hyperbolic AI integration for LLM inference
- x402 payment processing (Base Sepolia network)
- Comprehensive logging with Winston
- Request validation with Zod
- Security middleware with Helmet
- Health and readiness checks
- Graceful shutdown handling
POST /v1/chat/completions- OpenAI-compatible chat completions endpoint- Requires payment via x402 ($0.001 per request)
- Supports standard OpenAI parameters: model, messages, max_tokens, temperature, top_p, stream
GET /health- Basic health checkGET /ready- Readiness check (validates external dependencies)
- Install dependencies:
pnpm install- Create a
.envfile with the required environment variables:
# Hyperbolic AI API Key
HYPERBOLIC_API_KEY=your_hyperbolic_api_key_here
# Payment Configuration
ADDRESS=0x1234567890123456789012345678901234567890
FACILITATOR_URL=https://your-facilitator-url.com
# For testing with the client
PRIVATE_KEY=0x1234567890123456789012345678901234567890123456789012345678901234
# Optional Configuration
ALLOWED_ORIGINS=http://localhost:3000,https://yourdomain.com
LOG_LEVEL=info
NODE_ENV=development
PORT=3000- Start the development server:
pnpm run devA test client is included to demonstrate x402 payment functionality:
pnpm run clientThe client will:
- Create an account from your private key
- Make a chat completion request with payment
- Display the AI response and payment details
curl -X POST https://your-vercel-app.vercel.app/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "meta-llama/Llama-3.2-3B-Instruct",
"messages": [
{"role": "user", "content": "Hello, how are you?"}
],
"max_tokens": 100
}'Deploy to Vercel:
pnpm run deployMake sure to set these in your Vercel dashboard:
HYPERBOLIC_API_KEYADDRESSFACILITATOR_URLALLOWED_ORIGINS(optional)LOG_LEVEL(optional)