Refactor api_key loading out of render.