If I have a firepit on my screen porch, how high does the ceiling need to be?
Every place I've lived has city or state laws that prohibit this. In Virginia, the law says no open fires (exludes bonfire which is 50') within 25' of a structure.. So, don't do this.

If you are intent on continuing anyway, sketchy, unproven advice can be read below...

Ten feet clearance above the flame would be needed. Wood fires can reach over 2000 F (bonfires) and more typically are a bit over 1000 F in normal fire pit use; wood's flash point is at 572 F.

You can greatly mitigate the clearance by using things like a metal hood (think stove top hood, but bigger) or even a metal sheet dropped below the trusses several inches for airflow. I don't know of any exact designs for this, but you can probably simulate this fairly easily with a piece of paper on a large metal sheet over the fire; if the paper catches fire (451 F flash point) within 4 hours, it would be too close.

However, the bigger problem is the smoke. It will be an issue in a semi-enclosed space. I think a hood can greatly help, but the reality is that gas fireplaces are used in these scenarios as the temperature is quite a bit lower and it burns clean. This is the proper solution to your problem.