I skimmed the post but couldn't find out how one would know what provider to use. I guess you could ask whoever you're texting with but that's not very reliable, not everyone knows, and people change their provider.
Still costs money, but if you're sending a lot of messages, this would substantially reduce the costs.
curl -s -X GET "https://lookups.twilio.com/v1/PhoneNumbers/$number?Type=carrier&Type=caller-name" -u $accountsid:$authtoken | /usr/local/bin/jq '.'Again, thank you for putting this into a post!
I personally do carrier lookups in the unix shell with a 'curl' command using the Twilio API (see my other comment under you).
However, you can just look this information up on a number of different websites:
https://www.freecarrierlookup.com/
... et. al ...
https://en.m.wikipedia.org/wiki/List_of_mobile_telephone_pre...