The API key is requested by the client when your agent assumes you are running flows with the Prefect Cloud backend. To switch to Server, either run:
prefect backend server
before starting the agent, or set the env variable on your agent:
export PREFECT__BACKEND="server"
More on that here: