Keep in mind that setting environment variables apply to all the agents on the host as a system capability, while using the API creates a USER capability that is local to that specific agent. This is useful if you have multiple agents on a single host.