from datetime import datetime


def prep_datetime(dt):
    """Prepare datetime for the i14y API.

    If the passed value is a Python datetime object, convert it to an ISO 8601
    string. If None, return None.  Otherwise raises a ValueError.
    """
    if isinstance(dt, datetime):
        return dt.isoformat()

    if dt is None:
        return None

    raise ValueError(dt)