Least-Cost Routing Across Carriers in VICIdial
When you have more than one carrier, you can send each call out the cheapest path for its destination. Here's how least-cost routing works.
No single carrier is cheapest for every destination. One provider may have great rates to mobile numbers in one region and terrible rates to another, while a second provider is the opposite. Least-cost routing lets you send each call out whichever carrier is cheapest for the number being dialed, instead of paying one rate deck for everything.
This post explains how least-cost routing works in VICIdial, where the rate decisions live, and the things that quietly wreck your savings if you're not careful.
The idea in one sentence
Least-cost routing looks at the destination of a call, decides which Carrier is cheapest for that destination, and routes the call out that carrier's Trunk. To do that, the system needs to know the rates per destination and have a way to pick a trunk at dial time based on those rates.
How VICIdial picks the cheapest trunk
VICIdial ships an LCR lookup that maps a number's NPANXX (its area code plus exchange, the first six digits of a North American number) to a chosen trunk. An AGI script reads the dialed number, looks up the matching NPANXX in the lcr table, and sets a dialplan variable to the trunk that should carry it. The Dialplan then dials out whatever that variable points to. So the rate logic lives in a table, and the dialplan just obeys the table's verdict.
In practice you load your carriers' rate decks into the lcr table, ordered so the cheapest valid route for each destination wins. The AGI (Asterisk Gateway Interface) script does the lookup once per call, which keeps the dialplan simple and the decision data-driven.
The lookup flow
flowchart TD
A[Outbound call] --> B[Extract NPANXX from number]
B --> C[AGI looks up lcr table]
C --> D{Match found?}
D -->|Yes| E[Set trunk variable to cheapest]
D -->|No match| F[Use default fallback trunk]
E --> G[Dialplan dials chosen trunk]
F --> G
G --> H[Carrier sends to PSTN]Always have a fallback
Your rate table will never cover every possible destination. When the lookup finds no match, the dialplan needs a default trunk so the call still goes out instead of failing. Pair this with failover so that if the cheapest carrier is down, the call still completes on the next option. The cost lookup and multi-carrier failover are complementary: one optimizes price, the other protects uptime.
- Keep rate decks current; carriers change pricing more often than you'd think.
- Define a default trunk for any destination not in the table.
- Layer failover under LCR so a cheap-but-down carrier doesn't drop calls.
Where LCR meets your routing
Least-cost routing is really just smarter outbound routing: the same dialplan, but with the trunk chosen by data instead of a fixed pattern. If you haven't yet, read how outbound calls find the right carrier for the foundation, and the carrier integration guide for the trunk setup each route depends on. Choosing the right providers in the first place is covered in choosing a SIP carrier.
Least-cost routing pays off most at volume, where a fraction of a cent per minute adds up fast across thousands of calls. Get your rate table loaded, keep a default trunk in place, and you'll route every call out the cheapest path that still connects. VICIfast gives you a dedicated, fully controllable server in under 40 seconds so you can run as many carriers as your rate strategy needs. See our pricing to get started.
About VICIfast LLC
VICIfast LLC operates a managed VICIdial hosting + BYOI service for outbound and inbound call centers. We run the dialers, the carriers, the recordings pipeline, and the compliance plumbing so operators don’t have to.
Citing this article
VICIfast Engineering. “Least-Cost Routing Across Carriers in VICIdial”. VICIfast LLC, June 24, 2026. Retrieved from https://vicifast.com/blog/vicidial-least-cost-routing
Have questions?
Related posts
You might be interested in
VICIfast newsletter
Liked this? Get the next one in your inbox.
We ship the kind of stuff you just read — concrete, numbers-first, no drip. One email when a new post goes live. Unsubscribe in one click.
Comments
No comments yet — be the first.