Skip to content

Authentication ​

The CLI needs an API key to communicate with BetterPrompt. You can authenticate via a browser flow or by providing a key directly.

Browser login ​

Opens your browser to authenticate and receive an API key automatically:

bash
betterprompt login

The CLI starts a local callback server (port 22450–22460), opens https://betterprompt.me/api-keys, and saves the key once you complete the flow. The login URL is also printed in the terminal if the browser doesn't open.

API key auth ​

Set an API key directly (useful for CI/scripts):

bash
betterprompt auth --api-key bp_sk_abc123

Without --api-key, this command prompts interactively.

You can also set the key via config:

bash
betterprompt config set apiKey bp_sk_abc123

Check identity ​

bash
betterprompt whoami

Returns your username and account info. Use --json for machine-readable output.

Check credits ​

bash
betterprompt credits

Returns your current credit balance. Credits are consumed when you generate output.