import requests


def get_image_base_url(api_key):
    """Returns base image url string
    along with an image size retrieved
    from the configuration API
    """
    example_sizes = ['w342', 'w185', 'w154']
    url = 'https://api.themoviedb.org/3/configuration'
    payload = {'api_key': api_key}

    r = requests.get(url, params=payload)
    r.raise_for_status()

    json = r.json()
    images_json = json['images']
    base_url = images_json['base_url']
    available_sizes = images_json['poster_sizes']
    poster_size = None

    for size in example_sizes:
        if size in available_sizes:
            poster_size = size
            break

    return base_url + poster_size