In https://www.interactivebrokers.com/en/index.php?f=5041&ns=T it is written that in order to use the IB api you have to connect to it through the TWS or IB Gateway.
The Gateway lacks the GUI of the TWS, but provides the same API.
IB writes about the performance:
The IB Gateway provides a low-resource alternative to TWS for connecting to the IB trading system via the API. The gateway uses approximately 40% fewer system resources than TWS. However, the gateway is GUI-less, which means that you cannot view the API activity as you can when running TWS.
It also has an advantage concerning the automatic logout of TWS:
according to "Dmitry’s TWS API FAQ":
You can also use IB Gateway which is essentially a striped down version of TWS. Unlike TWS, IB Gateway will try to maintain a connection to IB for much longer than 24 hours. There is no guarantee that IB Gateway will keep the connection up for more than a week but this does happen.
If you don't need the full GUI of the TWS while you are developing or while your application is deployed, use the gateway. It provides the same API functionlity with much less overhead.
For all kinds of TWS API related questions I suggest having a look at the IB TWS API Yahoo Group, and "Dmitry’s TWS API FAQ".
This is a reply from IB tech support:
From the API point of view both platforms are identical. The only difference between them is that the TWS has a much richer interface through which you can place orders, view charts, etc. The IB Gateway is just a proxy with a simple interface aimed at providing the most basic features in order to connect via the API.
More important though, the TWS requires to be restarted at least every 24 hours whereas the IB Gateway can run indefinitely.