Create a module to access a 3rd party API and store the keys in the database
You can handle the storage and retrieval of the API keys in the database via the Drupal API functions:
variable_set and
variable_get.

To store the key (step 2):

variable_set('mymodule_api_key', $api_key);


To access the key (step 3):

$api_key = variable_get('mymodule_api_key', t('-key not set-'));


Where "mymodule" is the short name of your custom module.

As for a comprehensive example: There are many bridge modules in the Drupal.org repos that connects to an external service using an API and authenticates using API keys. One example of this is Mollom.