Generalize the API for various input sources.