Set up the GitLab Duo CLI
- Tier: Premium, Ultimate
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
You can use the GitLab Duo CLI through the GitLab CLI (glab). With the GitLab CLI, you get access to other GitLab features and you only need to authenticate once, using OAuth or a personal access token.
Alternatively, you can install and use the GitLab Duo CLI (duo) as a standalone AI tool, authenticating
separately with a personal access token.
Both setups support interactive and headless modes, along with all GitLab Duo CLI options, commands, and functionality.
Prerequisites
- GitLab 19.2 or later.
- The prerequisites for GitLab Duo Agent Platform.
- For GitLab Self-Managed and GitLab Dedicated, make sure that GitLab Duo CLI access is turned on.
If you are on GitLab 18.11 to 19.1, you can use the latest version of the GitLab Duo CLI by turning on beta and experimental features.
With the GitLab CLI
Prerequisites:
- GitLab CLI 1.107.0 or later.
- GitLab CLI is authenticated.
To set up the GitLab Duo CLI for use through the GitLab CLI:
Run the
glabcommand for the GitLab Duo CLI:glab duo cliFollow the prompts to install the GitLab Duo CLI binary.
The GitLab CLI automatically handles authentication, so you can start using the GitLab Duo CLI immediately.
Without the GitLab CLI
To use the GitLab Duo CLI as a standalone tool, install it and then authenticate.
Install
To install the GitLab Duo CLI as a compiled binary, download and run the install script.
On macOS and Linux:
bash <(curl --fail --silent --show-error --location "https://gitlab.com/gitlab-org/editor-extensions/gitlab-lsp/-/raw/main/packages/cli/scripts/install_duo_cli.sh")On Windows:
irm "https://gitlab.com/gitlab-org/editor-extensions/gitlab-lsp/-/raw/main/packages/cli/scripts/install_duo_cli.ps1" | iexAuthenticate
If glab is already installed and authenticated on your system when you first run duo, duo
automatically uses glab as a credential helper. You do not need to authenticate separately. This
requires glab 1.85.2 or later and duo 8.68.0 or later.
If you authenticated duo before this feature was available and want to use glab as a
credential helper instead, delete your authentication settings from ~/.gitlab/storage.json.
Prerequisites:
- A personal access token with
apipermissions.
To authenticate:
- Run
duoin your terminal. The first time you run the GitLab Duo CLI, a configuration screen appears. - Enter a GitLab Instance URL and then press Enter:
- For GitLab.com, enter
https://gitlab.com. - For GitLab Self-Managed or GitLab Dedicated, enter your instance URL.
- For GitLab.com, enter
- For GitLab Token, enter your personal access token.
- To save and exit the CLI, press Enter.
- To restart the CLI, run
duoin your terminal.
To modify the configuration after initial setup, use duo config edit.
Authenticate with environment variables
Prerequisites:
- A personal access token with
apipermissions.
The GitLab Duo CLI respects standard proxy environment variables:
HTTP_PROXYorhttp_proxy: Proxy URL for HTTP requests.HTTPS_PROXYorhttps_proxy: Proxy URL for HTTPS requests.NO_PROXYorno_proxy: Comma-separated list of hosts to exclude from proxying.
To authenticate with environment variables:
Set
GITLAB_TOKENorGITLAB_OAUTH_TOKENto your personal access token.export GITLAB_TOKEN="<your-personal-access-token>"Optional. Set
GITLAB_BASE_URLorGITLAB_URLto your custom GitLab instance URL, for examplehttps://gitlab.example.com. The default ishttps://gitlab.com.export GITLAB_BASE_URL="<your-instance-url>"
This method is useful for headless mode, CI/CD pipelines, and scripted workflows where interactive authentication is not possible.