<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_api_key(config, key):
 """Configure a new API key."""

    if not key and "X-Api-Key" in config.api_key:
        del config.api_key["X-Api-Key"]
    else:
        config.api_key["X-Api-Key"] = key