The trick to changing the license of a User record is that actually you will be updating the Profile of the user. You may have discovered already that "License" is not actually a field in the user object, even thought it appears in the User record UI.
You would also need to update the Role, as partner users are assigned roles that sit outside of the normal role hierarchy.
So the three pieces of information you'll need is the user's record Id, the Profile Id that you wish to assign to the User.ProfileId field, and the Role Id to assign to the user's RoleId field.
That being said, I have some doubt that this is actually possible. You clearly can't do it in the UI, as you've found. If this is the case, I would suspect that we would also block you from doing this via the API, but give it a try!