GPIO connected as open-drain to opto-isolator's cathode
Your idea is fine, but both schematics have fatal errors.

In the first one, when the GPIO output goes low it attempts to put a dead short across the system 3.3 V supply.  There are two ways to correct this.

1) (IF the GPIO emitter is connected to GND internally) Leave R1 connected to Vcc; disconnect opto pin 2 (hopefully the LED cathode) fron GND and connect it to the GPIO collector.

2) (IF the GPIO emitter is brought out to the pin and the collector is connected to Vcc internally) Connect the left side of R1 to the GPIO emitter.

The only problem with the second schematic is the connection between the opto pin 2 and Vcc.  Again, this creates a dead short path through the GPIO driver transistor.  Break that connection leaving pin 2 connected only to the GPIO collector or drain, and it should work.  Many GPIO pins are better at sinking current than sourcing, so this is the preferred way to drive an external load.