Skip to content

Authentication

Replexica CLI communicates with Replexica AI engine hosted in the cloud, so authentication is required to use the service.

Checking Authentication Status

To see if you're currently authenticated:

bash
npx replexica@latest auth

This command shows your current auth status and associated email if you're logged in.

Logging In

There are two ways to authenticate with Replexica:

1. Interactive Browser Login

bash
npx replexica@latest auth --login

This opens your default browser for login. After logging in, you'll be redirected back to your terminal.

INFO

Some browser settings or ad blockers can block this redirect. If you encounter issues, try the environment variable method below.

2. Environment Variable

Set the REPLEXICA_API_KEY environment variable with your API key:

bash
export REPLEXICA_API_KEY=your_api_key_here

You can also use a .env file in your project root:

bash
REPLEXICA_API_KEY=your_api_key_here

WARNING

Never commit your .env file to version control.

Logging Out

To log out and remove local authentication:

bash
npx replexica@latest auth --logout

This command removes your local authentication token, requiring you to log in again.

Keep in mind there's no need to log out if you're using environment variables.

Why Two Authentication Methods?

Replexica offers both interactive and environment variable authentication for a reason:

  1. Interactive login is user-friendly and doesn't require managing API keys;
  2. Environment variables work well in CI/CD pipelines and servers.

The flexibility allows you to choose the method that best fits your workflow and security preferences.

Best Practices

  1. Never commit your API key to version control;
  2. If using the API key in a .env file, ensure it's in your .gitignore and is never committed;
  3. Rotate your API key periodically for enhanced security;
  4. Use environment variables in CI/CD pipelines to avoid interactive prompts.

By understanding these authentication methods, you can securely integrate Replexica into your development process, whether you're working locally or in an automated environment.