For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Logo
Resources
Log inGet a demo
GuidesAPI reference
GuidesAPI reference
    • Get started
    • Install skills
  • Features
    • Projects
    • Cost governance and savings
      • Overview
      • Using policies
      • Single provider
      • Priority
      • Performance
      • Intelligent
    • Tool calling
    • Web search
    • Context compression
  • Security & Compliance
    • Customer blocklist
    • Geo-location routing
    • Prompt injection protection
    • Data loss prevention
    • Audit trail
    • Roles and permissions
    • Zero data retention
    • Provider terms

Get started

  • Overview
  • Introduction
  • Unified API
  • Linked Account
  • Merge Link
  • Use cases

Implementation

  • Sandboxes
  • SDKs
  • API access
  • Syncing data
  • Writing data
  • Data minimization
  • Supplemental data
  • Errors
  • Integration metadata

API reference

  • ATS
  • HRIS
  • Accounting
  • Ticketing
  • CRM
  • File Storage
  • Knowledge Base
  • Chat

Resources

  • Help Center
  • Merge.dev
  • Changelog
© Merge 2026Terms of usePrivacy policy
UnifiedAgent HandlerGateway
UnifiedAgent HandlerGateway
Resources
Log inGet a demo
On this page
  • Strategy comparison
  • Examples
  • Request using a routing policy
  • Policy definition
  • Choosing the right strategy
  • Tag-based routing
  • FAQs
FeaturesRouting policies

Routing policies

Automatically route AI requests across providers to optimize cost, performance, and reliability
Was this page helpful?
Previous

Cost governance and savings

Next

Using routing policies

Routing policies control which AI provider and model handles each request. Instead of hardcoding a single provider, policies automatically select the best option based on your optimization goals, whether that’s minimizing cost, maximizing uptime, or balancing both with ML-powered routing.

For details on how a policy gets applied to a specific request and how to use default_routing, see Using routing policies.

Strategy comparison

StrategyDescriptionConfigurationDetail page
SingleAlways route to one providertype: "fallback", 1 providerSingle provider
PriorityTry providers in order with automatic failovertype: "fallback", multiple providersPriority
Least LatencyRoute to the fastest providerDashboard onlyPerformance
Lowest CostRoute to the cheapest providerDashboard onlyPerformance
Cost OptimizedML-based routing, ~70% traffic to cheaper modelstype: "intelligent", axis: "cost"Intelligent
BalancedML-based routing, even cost/quality splittype: "intelligent", axis: "performance"Intelligent
Quality FirstML-based routing, ~70% traffic to capable modelstype: "intelligent", axis: "intelligence"Intelligent

Examples

Request using a routing policy

The project’s policy picks the provider and model. No model field is needed.

1from merge_gateway import MergeGateway
2
3client = MergeGateway(api_key="YOUR_API_KEY")
4
5# The "production" project has a Cost Optimized routing policy.
6response = client.responses.create(
7 input=[
8 {"type": "message", "role": "user", "content": "Summarize this quarter's earnings call."},
9 ],
10 project_id="production",
11)
12
13print(response.output[0].content[0].text)

With no project_id, the same request falls back to the org default routing policy.

Policy definition

Policies are created in the dashboard. These JSON bodies describe the policy configuration itself. They are never sent in a POST /responses request.

Cost Optimized
1{
2 "name": "Production - Cost Optimized",
3 "default_strategy": {
4 "type": "intelligent",
5 "axis": "cost",
6 "providers": [
7 { "provider": "openai", "model": "gpt-5-mini" },
8 { "provider": "anthropic", "model": "claude-sonnet-4-20250514" },
9 { "provider": "openai", "model": "gpt-5.2" }
10 ]
11 }
12}
Priority (failover)
1{
2 "name": "HA Failover",
3 "default_strategy": {
4 "type": "fallback",
5 "providers": [
6 { "provider": "openai", "model": "gpt-5.2", "priority": 1 },
7 { "provider": "anthropic", "model": "claude-sonnet-4-20250514", "priority": 2 }
8 ]
9 }
10}

Choosing the right strategy

Your priorityRecommended strategyNotes
Simplicity / dev environmentSingleOne provider, no failover
High availability / failoverPriorityOrdered failover across providers
Fastest response timeLeast LatencyDashboard only
Lowest cost (same model, multiple providers)Lowest CostDashboard only
Lowest cost (mixed models, ML-driven)Cost Optimized~40-60% savings
General production optimizationBalanced~20-35% savings
Maximum output qualityQuality FirstRoutes most traffic to capable models

Tag-based routing

You can attach tags to requests (user tier, region, environment, and so on) and use them to route to different policies. Rules are evaluated in priority order: the first matching rule applies, and unmatched requests fall through to the default strategy.

Conditions support AND/OR logic and operators like eq, gt, in, contains, starts_with, and exists. Configure tag-based routing through the dashboard.

FAQs

What do the JSON examples on the strategy subpages represent?

They are policy definitions, the configuration used when creating a routing policy in the dashboard. They are not request-body fields for POST /responses.

Does intelligent routing add latency?

The complexity scoring step adds ~1-4ms. Negligible compared to LLM inference time.

How accurate is the complexity scoring?

Clean separation below 0.4 (simple) and above 0.6 (complex). Edge cases around 0.5 route conservatively to more capable models.

What happens if the complexity scorer fails?

Gateway falls back to the most capable model in your policy. Quality is never compromised by a scorer failure.

Can I use any model with intelligent routing?

Yes. New models work immediately, with capabilities inferred from pricing data.

What if I only want specific models, not auto-selection?

The router only selects from models in your policy, never outside of it