In the insert pot of the Instant Pot, add fresh green beans and onions. Pour in the broth and sprinkle in salt and pepper. Add butter and ham or bacon, if using. Stir to combine.
Close lid and set the valve to the sealed position. Select a cook time of 20 minutes at high pressure.
After the cook time is complete, you can perform a quick release of pressure or a natural release.
Adjust seasonings if needed and serve.