It depends on the make, model and age of your vehicle. Some cars allow programming by learning via button push sequence, etc., some allow aftermarket fobs (some don't), some allow used fobs (some don't), some require a virgin fob with a "write-once" transponder.
Try getting an estimate from these guys:
https://www.torontotoplocksmith.ca/. I recall a conversation with one of my customers last year and he mentioned that he used them for a key fob replacement instead of going to the dealer.