Group Based Routing
Route requests to different models based on the user's LangDB cost group. This allows organizations to provide different model access levels for different teams or departments.
Use Case
- Different model budgets per team
- Development vs production environment separation
- Cost control by department
- Team-specific model access
Configuration
{
"model": "router/dynamic",
"router": {
"type": "conditional",
"routes": [
{
"name": "development_group",
"conditions": {
"all": [
{
"metadata.group_name": {
"$eq": "development"
}
}
]
},
"targets": "openai/gpt-5"
},
{
"name": "testing_group",
"conditions": {
"all": [
{
"metadata.group_name": {
"$eq": "testing"
}
}
]
},
"targets": "openai/gpt-4o-mini"
},
{
"name": "production_group",
"conditions": {
"all": [
{
"metadata.group_name": {
"$eq": "production"
}
}
]
},
"targets": {
"$any": [
"gemini/gemini-2.5-pro",
"xai/grok-4"
],
"sort_by": "ttft",
"sort_order": "min"
}
},
{
"name": "executive_group",
"conditions": {
"all": [
{
"metadata.group_name": {
"$eq": "executive"
}
}
]
},
"targets": "anthropic/claude-sonnet-4"
},
{
"name": "fallback_group",
"conditions": {
"all": []
},
"targets": "openai/gpt-4.1-nano"
}
]
}
}
How It Works
- Development Group: Gets budget model (GPT-5) for experimentation
- Testing Group: Gets mid-tier model (GPT-4o-mini) for testing workflows
- Production Group: Gets high-performance models (Gemini-2.5-pro or Grok-4) sorted by speed
- Executive Group: Gets premium model (Claude-Sonnet-4) for critical business us
Variables Used
metadata.group_name: LangDB cost group name (automatically set by LangDB based on user's group assignment)
Group Setup
LangDB cost groups are a built-in feature for organizing users and controlling spending. For detailed information about cost groups, see the Cost Control documentation.
Customization
- Add more cost groups for different teams
- Include multiple models per group with filtering
- Combine with user tier routing for more granular control
- Add cost-based sorting within groups