Depends, if you're doing largely front-end code (like embedding an iFrame to some chat application) then a widget works best. If you want to modify the API or save things into the database, then a plugin is right for you.
I think your best bet is to figure out what you need to do, and then find a plugin that does something similar, and modify that plugin, or take code from it (it's open source afterall ;))