CosmicAC Logo
Quick start

Install the CLI

Install the CosmicAC CLI, set the URLs for your deployment, and sign in.

Install the CosmicAC CLI, set the URLs for your deployment, and sign in, so that you can create and manage jobs from your terminal.

Prerequisites

Before you start, make sure that you have the following.

  • Node.js 24.22.1 or later
  • npm
  • A GitHub account that has access to the tetherto organization.
  • A running CosmicAC deployment. To set one up, see Set up CosmicAC.

Steps

Create a GitHub personal access token

If you already have a classic personal access token (PAT) with the read:packages scope, skip this step.

  1. In GitHub, go to Settings > Developer settings > Personal access tokens > Tokens (classic).
  2. Click Generate new token (classic).
  3. Enter a descriptive name, such as CosmicAC CLI.
  4. Select the read:packages scope.
  5. Click Generate token.
  6. Copy the token. GitHub shows it only once.
  7. If the tetherto organization enforces single sign-on (SSO), click Configure SSO next to the token, and then authorize it for tetherto.

For more information, see Managing your personal access tokens in the GitHub documentation.

Configure npm for GitHub Packages

The CosmicAC CLI is a private package on GitHub Packages, not on the npm registry. npm needs the registry address and your token to install it.

  1. Point the @tetherto scope to GitHub Packages.

    npm config set @tetherto:registry https://npm.pkg.github.com
  2. Save your token. Replace <your-pat> with the token that you copied.

    npm config set //npm.pkg.github.com/:_authToken <your-pat>

Allow GitHub Packages in Socket Firewall (optional)

If you use Socket Firewall, add GitHub Packages to its allowed registries. Otherwise, npm install fails with a 403 error.

To check whether .sfw.config in your home directory already sets SFW_CUSTOM_REGISTRIES, run the command for your operating system.

grep SFW_CUSTOM_REGISTRIES ~/.sfw.config

If the command prints an SFW_CUSTOM_REGISTRIES line, edit that line instead of adding a new one.

  1. Open the file in a text editor.
nano ~/.sfw.config
  1. Inside the quotes, after the last entry, add a comma and the two GitHub Packages hostnames. The edited line looks like the following.

    SFW_CUSTOM_REGISTRIES="<existing-entries>,npm:npm.pkg.github.com,npm:pkg-npm.githubusercontent.com"

    <existing-entries> is the value that was already in the quotes. Leave it unchanged.

  2. Save the file, and then close the editor.

If the command prints nothing, or reports that the file doesn't exist, run the following command for your operating system instead. The command adds the setting to the end of the file, and creates the file if it doesn't exist.

echo 'SFW_CUSTOM_REGISTRIES="npm:npm.pkg.github.com,npm:pkg-npm.githubusercontent.com"' >> ~/.sfw.config

Install the CLI

Install the CLI globally.

npm install -g @tetherto/cosmicac-cli

To check that the installation succeeded, print the CLI version.

cosmicac --version

The command prints the version number, for example 1.3.2. The short form of --version is -v.

For a list of all CLI commands, see CLI commands.

Set the URLs for your deployment

Save the URLs of your deployment in a named CLI environment. This example names the environment production. Replace <base-url> with your CosmicAC base URL, and keep the /api and /inference paths.

cosmicac config set --env production \
  --app-url <base-url>/api \
  --inference-url <base-url>/inference \
  --web-url <base-url>

The base URL is the address of your CosmicAC web interface, such as localhost, a server IP address, or a domain name.

Install cloudflared (optional)

If your deployment is behind Cloudflare Access, install cloudflared. The CLI uses this Cloudflare command-line tool for the Cloudflare sign-in. To complete the Cloudflare sign-in, you need CLI version 1.3.3 or later, and your organization's Cloudflare Access policy must let you sign in. If your deployment isn't behind Cloudflare Access, skip this step.

  • On macOS, run brew install cloudflared.
  • On Windows, run winget install --id Cloudflare.cloudflared.
  • On Linux, install the package or binary from the Cloudflare downloads page.

Sign in

Sign in to your deployment. If your deployment is behind Cloudflare Access, you sign in twice, first to Cloudflare Access and then to CosmicAC.

  1. Start the sign-in.

    cosmicac login
  2. If your deployment is behind Cloudflare Access, complete the Cloudflare sign-in in your browser. Otherwise, skip this step.

    Before the Cloudflare sign-in, the CLI prints <host> is behind Cloudflare Access. Complete the Cloudflare sign-in in your browser. If the Cloudflare sign-in fails, the CLI prints Cloudflare Access rejected the sign-in for <host>. and stops.

  3. In the CosmicAC web interface that opens in your browser, approve the request within 5 minutes.

    After you approve the request, the CLI selects a team and prints its name.

To use another team, list your teams, and then select one by its ID or name.

cosmicac teams list
cosmicac teams use <team>

If no browser is available, for example, over SSH, print the CosmicAC sign-in URL instead, and then open the URL on another machine.

cosmicac login --no-browser

The --no-browser flag applies only to the CosmicAC sign-in. Behind Cloudflare Access, the CLI still starts the Cloudflare sign-in through cloudflared. To pass Cloudflare Access without a browser, use a service token. For more information, see Sign in without a browser by using a service token.

Confirm the configuration

Check the active environment.

cosmicac config show

The output shows the active environment, its URLs, and its TEAM_ID.

Check your user and teams.

cosmicac whoami

Use more than one deployment

The CLI stores the URLs, sign-in, and active team of each deployment as a separate named environment. Commands use the active environment.

To add another deployment, set its URLs with a new --env name, and then sign in. The new environment becomes the active environment, and it starts signed out with no active team.

cosmicac config set --env staging \
  --app-url <staging-base-url>/api \
  --inference-url <staging-base-url>/inference \
  --web-url <staging-base-url>
cosmicac login

To switch to an environment that you already set up, run cosmicac config set with only the --env flag. The environment keeps its sign-in and active team, so you don't need to sign in again.

cosmicac config set --env production

If you change the --app-url value of an environment, the CLI signs you out of that environment and clears its active team. To sign in again, run cosmicac login.

Sign in without a browser by using a service token

If your deployment is behind Cloudflare Access and no browser is available, for example, in a script or over SSH, use a Cloudflare Access service token instead of cloudflared. You need CLI version 1.3.3 or later. You also need the client ID and the client secret of a service token for your deployment. Your organization's Cloudflare Access administrator creates the service token and gives you these values.

The CLI sends the service token to every host that it calls.

  1. Set the service token in the environment that runs the CLI.

    export CF_ACCESS_CLIENT_ID=<client-id>
    export CF_ACCESS_CLIENT_SECRET=<client-secret>

    Replace the following:

    • <client-id>: the client ID of the service token.
    • <client-secret>: the client secret of the service token.
  2. Start the CosmicAC sign-in.

    cosmicac login --no-browser

    The CLI sends the service token with each request, so Cloudflare Access accepts the request. The CLI prints the CosmicAC sign-in URL.

  3. In a browser on another machine, open the sign-in URL.

  4. In the CosmicAC web interface, approve the request within 5 minutes.

    The CLI selects a team and prints its name.

  5. Check your user and teams.

    cosmicac whoami

    The command prints the active environment, your email address and user ID, and your teams with your role in each team.

Next steps

On this page