LogoToRouter Docs
LogoToRouter Docs
HomepageWhat is ToRouter5-minute quickstartCore concepts
Create your first API keyIP whitelist & blacklist (CIDR)Quota, rate limits & expirationRestrict which models a key can callRotate or revoke a key
API Keys

IP whitelist & blacklist (CIDR)

Restrict a ToRouter API key to known networks using CIDR rules. Supports IPv4 and IPv6.

Each key can carry an IP whitelist and an IP blacklist. Both accept CIDR ranges, one per line, IPv4 or IPv6.

How matching works

WhitelistBlacklistBehaviour
emptyemptyAny source IP allowed
setemptyOnly IPs inside the whitelist allowed
emptysetAll IPs allowed except those in the blacklist
setsetMust be in whitelist and not in blacklist

The whitelist is deny-by-default once set — an unlisted IP gets 401.

CIDR examples

whitelist
203.0.113.0/24
198.51.100.42/32
2001:db8::/32
  • /32 = a single IPv4 address
  • /24 = 256 IPv4 addresses (a typical office subnet)
  • /128 = a single IPv6 address
  • 0.0.0.0/0 = everything (don't use this — leave the field empty instead)

Setting the rules

  1. Go to API Keys → click your key → Edit
  2. Paste CIDR ranges into IP whitelist or IP blacklist (newline-separated)
  3. Save

Changes apply on the next request — no cache to wait for.

Running behind a corporate proxy, VPN or serverless function? The source IP ToRouter sees is the egress IP of that hop, not your laptop. Check https://portal.torouter.ai from the same network to confirm.

When a request is blocked

You get 401 Unauthorized with a message like ip not allowed. The request is not billed. See Blocked key.

Next steps

Quota & rate limits

Combine IP rules with spend caps.

Model whitelist

Limit which models a key can call.

Create your first API key

Generate a ToRouter API key from the portal and use it with any OpenAI-, Anthropic- or Gemini-compatible SDK.

Quota, rate limits & expiration

Cap per-key spend in USD, throttle requests per window, and auto-expire keys after N days.

Table of Contents

How matching worksCIDR examplesSetting the rulesWhen a request is blockedNext steps