Routers
Configure multiple independent routing policies for different use cases in a single AI Gateway deployment
Routers are the core concept of the Helicone AI Gateway. Unlike alternative solutions, it allows you to configure multiple independent routing policies within a single gateway deployment, each with its own load balancing strategy, provider configuration, and middleware settings.
Getting Started
What are Routers?
Routers define independent routing policies within the AI Gateway, each with its own configuration for:
- Load balancing strategies - How requests are distributed across providers
- Provider selection - Which LLM providers are available for each router
- Middleware settings - Caching, rate limiting, retries, and other features
- URL endpoints - Each router gets its own URL path for requests
Think of routers as separate “virtual gateways” within a single deployment - each optimized for different use cases, environments, or teams.
Understanding Router URLs
Each router you define becomes part of the URL path when making requests to the gateway. This design allows a single deployed gateway to serve multiple routing configurations.
URL Format: http://your-gateway-host/router/{router-name}/{api-path}
SDK Configuration
Configure your OpenAI SDK to use a specific router by setting the base URL:
Basic Router Configuration
You can configure any number of named routers for different use cases.
Common Use Cases
Use case: Different routers for different environments, all from a single gateway deployment.
Usage:
- Production:
http://localhost:8080/router/production
- Staging:
http://localhost:8080/router/staging
- Development:
http://localhost:8080/router/development
Use case: Different routers for different environments, all from a single gateway deployment.
Usage:
- Production:
http://localhost:8080/router/production
- Staging:
http://localhost:8080/router/staging
- Development:
http://localhost:8080/router/development
Use case: Different teams with their own router configurations and resource limits.
Usage:
- ML Team:
http://localhost:8080/router/ml-team
- Frontend Team:
http://localhost:8080/router/frontend-team
For complete configuration options and syntax, see the Configuration Reference.
Reference
Router Naming Rules
Router names must follow this regex pattern: ^[A-Za-z0-9_-]{1,12}$
- Length: 1-12 characters
- Allowed characters: Letters (A-Z, a-z), numbers (0-9), hyphens (-), underscores (_)
- No spaces or special characters
Valid names: production
, dev
, team-a
, cost_opt
, v2
, A
, my_router
Invalid names: very-long-router-name
(too long), team@prod
(@ not allowed), router with spaces
(spaces not allowed)
URL Path Structure
The AI Gateway supports three different routing patterns: