import json


def format_response(output_format, response):
    """Format the API response to the desired output format"""
    if not response.content:
        formatted = ''
    elif output_format == 'json':
        formatted = json.dumps(response.json())
    elif output_format == 'pprint':
        formatted = json.dumps(response.json(), sort_keys=True, indent=4)
    elif output_format == 'text':
        formatted = response.text
    else:
        raise ValueError("%s is not a supported format." % output_format)

    return formatted