@nuwa-ai/llm-gateway - Ready to use without building from source.
Before you start: obtain a Service Key for your service DID. See the
Service Key guide and use the copied value as
SERVICE_KEY.Quick start
- Using NPM Package (Recommended)
- Build from Source
1
Install globally
2
Set environment variables
Not sure where
SERVICE_KEY comes from? Follow the
Service Key guide to generate it via test-id.nuwa.dev.3
Run the gateway
4
Verify the gateway
You can use the Nuwa Login Demo to verify your gateway:
- Open the demo and set gateway URL to
http://localhost:8080 - Connect your wallet and authenticate with DID
- Send a chat request to test the integration
Provider routing
The gateway uses provider-first routing for clear endpoint organization:- OpenAI
- OpenRouter
- LiteLLM
Using PaymentChannelHttpClient
For programmatic access with automatic payment handling, use the PaymentChannelHttpClient from the Payment Kit:- Installation & Setup
- Making Requests
- Error Handling
Pricing configuration
The gateway supports flexible pricing configuration:- Built-in pricing: Default model pricing for OpenAI models
- Pricing overrides: Custom pricing via
PRICING_OVERRIDESenvironment variable - Global multiplier: Adjust all costs with
PRICING_MULTIPLIER(range 0-2)
Usage tracking
- Automatic tracking: All requests are logged with token counts and USD costs
- Streaming support: Chat Completions automatically inject
stream_options.include_usage=true - Response API: Usage appears in
response.completedSSE events - Access logs: Structured JSON logs to stdout with request details
Common issues
- “SERVICE_KEY is required”: Generate and set your service key from the Service Key guide
- “At least one provider API key is required”: Configure at least one provider API key
- Port conflicts: Use
--port <number>to specify a different port

