Before you start
- An Autosage account. Create one free if you don't have one. You sign in through your browser, so there's no key to copy.
- macOS, Linux or Windows, with Python 3.11 or newer. The one-line installer downloads Python for you if you don't have it.
- An OS keychain to keep your session in. macOS and Windows have one built in; on Linux, SageCode uses Secret Service (GNOME Keyring or KWallet). No keychain, as on a CI runner? Use an access token instead.
Install and sign in
-
Run the installer
It installs SageCode as an isolated tool with uv (installing uv first if needed) and puts the
sagexcommand on your PATH.$curl -LsSf https://sagecode.web.app/install.sh | shPS>irm https://sagecode.web.app/install.ps1 | iexTo install a specific version, set
SAGEX_VERSIONfirst, for exampleSAGEX_VERSION=2.0.1. -
Open a new terminal and check it
❯ sagex --versionsagex 2.0.1 -
Sign in with your browser
SageCode shows a one-time code and opens Autosage in your browser. Check the code matches the one in your terminal, then click Approve. On a server or over SSH, open the link on any device instead. Your session is saved to your OS keychain.
❯ sagex auth loginYour one-time code: WDJB-MJHTApprove the sign-in at: https://autosagex.web.app/cli-auth?code=WDJB-MJHTOpened your browser. Check the code matches, then approve.✓ Logged in to Autosage as you@example.com on my-laptop. -
Run your first commands
❯ sagex list workflow # your workflows, as a table❯ sagex # open the terminal app, then ask Sage anything❯ sagex --help # every command groupNext, read the guide, ask Sage, or browse all the commands.
Other ways to install
SageCode is on PyPI as sagex-cli; the command it installs is sagex. Any Python tool manager works:
| Tool | Command |
|---|---|
| uv | uv tool install sagex-cli |
| pipx | pipx install sagex-cli |
| pip | pip install sagex-cli (into a virtual environment) |
| A pinned version | uv tool install sagex-cli==2.0.1 |
Prefer to read the installer first? It's short: install.sh and install.ps1.
Sessions and CI tokens
Every sign-in is a session. The SageCode section of your Autosage profile lists them all: the device and system, the SageCode version, when it was last active, and how many commands and runs it has started. Revoke any of them there, and that machine is signed out at once.
- New devices. Autosage emails you when SageCode signs in on a device it hasn't seen before.
- Idle sessions expire after 90 days without use. Run
sagex auth loginto sign in again. - One session per machine. Signing in again replaces the machine's previous session, and
sagex auth logoutsigns it out.
CI and scripts. Where there's no browser or keychain, create an access token on your profile (Create token) and store it as a secret named SAGEX_API_KEY. It's shown once, and works until you revoke it or it goes 90 days unused. To save one to a machine's keychain instead, pipe it in:
Configuration
SageCode works out of the box. These environment variables change its behaviour when you need to:
| Variable | What it does |
|---|---|
SAGEX_API_KEY | Use this access token instead of the keychain. It takes precedence over a saved sign-in. Made for CI jobs and machines without a keychain. |
SAGEX_API_URL | Point SageCode at a different Autosage server. |
SAGEX_DEBUG=1 | Add connection details to network errors. |
Your preferences, such as the workspace folder and the terminal app's shell, are saved in ~/.sagex/config.json. Check your login at any time:
Update or uninstall
Upgrade with the same tool you installed with:
To uninstall, log out first so the session is signed out and removed from your keychain, then remove the tool:
Troubleshooting
| You see | What to do |
|---|---|
sagex: command not found | Open a new terminal so your PATH is reloaded. Still missing? Run uv tool update-shell, then open another terminal. |
| This sign-in request expired | Approve within 10 minutes of running sagex auth login. Run it again for a new code. |
| That code isn't valid or has expired (in the browser) | Check you typed the code from your terminal, or run sagex auth login again. |
| No OS keychain is available on this machine | Create an access token on your Autosage profile and set it in your environment: SAGEX_API_KEY=<token>. |
| This SageCode session expired, was signed out or was revoked | Run sagex auth login to sign in again. Sessions expire after 90 days without use. |
| That doesn't look like a SageCode token | Access tokens start with sgx_. Copy the whole token and try again. |
| Unable to reach the Autosage server | Check your internet connection and try again. For details, run the command again with SAGEX_DEBUG=1. |
Something else? Open an issue with the command you ran and what it printed.