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
