Add key flag for API key

Also move key check before the cache check, since if the cache is not stale, the user has a false sense that it's working, but it will stop working when the cache expires