## Using Stripe API keys

The Stripe CLI supports several different ways to set and use [API keys](https://docs.stripe.com/keys.md):

1. [`stripe login`](https://docs.stripe.com/cli/login.md)
2. [`stripe config`](https://docs.stripe.com/cli/config.md)
3. [`--api-key` flag](https://docs.stripe.com/cli/api_keys.md)
4. Environment variables

Each supports a different use case. `stripe login` is the easiest and recommended way to get started. Running this command will prompt you to log in from your browser and persist your API key locally, rather than requiring it for each command. If you want to provide an API key manually, you can use `stripe login --interactive`.

Using `stripe config` allows you to set persistent keys manually:

* `stripe config --set test_mode_api_key sk_test_123`

`--api-key` is a global flag that overrides your local configuration if you need to run one-off commands with a specific API key. You can set two environment variables, which take precedence over all other values:

* `STRIPE_API_KEY`: the API key to use for the CLI.
* `STRIPE_DEVICE_NAME`: the device name for the CLI, visible in the Dashboard.

### Example

```title Running commands with a specified API key ```