If you want to 'preconfigure' a gateway with an API key, you can store one in the external resource collection, as mentioned in the post @Sfenwick linked:
Note that this same principle can be applied a layer higher. If you want to preconfigure a gateway connection - you can do the exact same thing (move a configured resource to the external collection) but with your configured DB connection.