OpenClaw with nRouter
Configure an OpenClaw OpenAI-compatible provider through nRouter and verify model routing, tool use, fallback policies, budget ceilings, and data retention.
Connect OpenClaw agent workflows to nRouter (https://api.nrouter.ai/v1) to govern autonomous model calls with hard budget caps, preflight guardrails, and turn-by-turn cost logs. Pointing OpenClaw to nRouter isolates risk and prevents runaway recursive loops with strict USD ceilings.
Key capabilities:
- Per-agent virtual keys: Assign distinct nRouter keys (
sk-nrouter-...) to isolate budgets and telemetry across individual agent workers. - Autonomous loop safeguards: Enforce hard USD spending caps that return HTTP 402 before runaway recursive tool calls exhaust balances.
- Server-side guardrail inspection: Pre-call prompt injection filtering scans agent inputs and tool payloads before execution.
- Drop-in OpenAI REST compatibility: Configure the standard OpenClaw provider block with nRouter's unified endpoint.
Provider Configuration
Configure the provider block in your OpenClaw settings using the OpenAI-compatible gateway specification:
{
"models": {
"providers": {
"nrouter": {
"baseUrl": "https://api.nrouter.ai/v1",
"apiKey": "${NROUTER_API_KEY}"
}
}
}
}Export NROUTER_API_KEY in your environment, choose a model from the nRouter catalog, and run a test turn.
What nRouter adds
OpenClaw handles agent execution; nRouter governs model spend and security. Dedicated virtual keys isolate budgets per agent, preventing runaway loops from exhausting shared allowances, while full request logs record exact list-price costs and guardrail verdicts.
Agent safety checklist
- Assign each agent a dedicated virtual key with a hard USD budget ceiling.
- Review guardrails and cost logs in observability after staging runs.
- For coding tools, see Claude Code with nRouter and Cursor with nRouter. For multi-agent systems, see the CrewAI guide.
Troubleshooting
If an agent turn fails (see Errors & Rate Limits):
- 401
invalid_api_key: EnsureNROUTER_API_KEYis exported in the agent's runtime environment. - 402
insufficient_credits: Virtual key budget ceiling reached (x-nr-limit-sourceidentifies the limit). - 404
model_not_found: The model route does not match the active model catalog.
Frequently asked questions
Does nRouter replace OpenClaw?
No. OpenClaw executes agent logic; nRouter provides the governed OpenAI-compatible upstream endpoint with per-key budgets, request logs, and guardrails.
Which API key should an agent use?
Assign each agent its own virtual key with an individual spend cap so runaway loops remain isolated and auditable.
How do I verify the integration before rollout?
Run a single non-destructive turn and verify the trace ID, served model, and cost in nRouter request logs.
My OpenClaw release configures providers differently. What then?
Follow your release's provider configuration syntax; nRouter only requires pointing the base URL to https://api.nrouter.ai/v1 with your virtual key.