I'm looking at threadtag.php, and it looks like you want to do something like this:
Code:
$content = vB_Taggable_Content_Item::create($vbulletin, vB_Types::instance()->getContentTypeID('vBForum_Thread'), $threadid);
$limits = $content->fetch_tag_limits();
$errors = $content->add_tags_to_content('tag1,tag2', $limits);
but I haven't actually tried it. Also, in threadtag.php there are some calls to check permissions which probably do a redirect to an error page, so I left them out because I'm not sure if it's appropriate for your application.