asterisk lcr
Asterisk is a telephone system software for Unix systems.
I was using Asterisk at home to simulate an ISDN telephone system using a cheap ISDN PCI with an HFC chip. I connected a terminal adapter to the ISDN card and was able to use my plain old hardware telephones at them. That way I could make VoIP calls in a completely transparent manner.
To route outgoing calls over the cheapest VoIP provider I created a least cost routing script which can be hooked up in Asterisk using the AGI.
You can define the routes in a configuration file and Asterisk will call the script to determine the cheapest provider.
A short documentation is included in the package. A more elaborate German documentation can be found in a telephony forum.
Interestingly somebody else had the same idea a bit later: Asterisk::LCR on CPAN
Download: asterisk_lcr.tar.gz (License: GPL 2)