API keys enable you to authenticate a local environment to work with Prefect Cloud.
If you run prefect cloud login from your CLI, you'll have the choice to authenticate through your browser or by pasting an API key.
If you choose to authenticate through your browser, you'll be directed to an authorization page.
After you grant approval to connect, you'll be redirected to the CLI and the API key will be saved to your local Prefect profile.
If you choose to authenticate by pasting an API key, you'll need to create an API key in the Prefect Cloud UI first.
Service accounts are a feature of Prefect Cloud Pro and Custom tier plans that enable you to create a Prefect Cloud API key that is not associated with a user account.
Service accounts are typically used to configure API access for running workers or executing flow runs on remote infrastructure. Events and logs for flow runs in those environments are then associated with the service account rather than a user, and API access may be managed or revoked by configuring or removing the service account without disrupting user access.
See the service accounts documentation for more information about creating and managing service accounts in Prefect Cloud.