Skip to main content
Run tj login to authorize your terminal in the browser. Your Python code can then use Client() without copying a key into a script or a coding-agent prompt.

Sign in

Open the displayed link, sign in, complete any required account setup, and approve the code shown in your terminal for the intended organization. Login saves a credential locally. On first login, an interactive terminal offers project setup; you can skip it and run tj init later. Setup can open Claude Code, Codex, or Gemini CLI in your project with the integration instructions and this login profile. See assistant setup.
For an SSH session or a machine without a browser:
Open the displayed URL on another device. Login waits for approval for up to ten minutes; --timeout sets a shorter wait. An expired login needs a new code. If the CLI reports an uncertain redemption after losing its connection, review and revoke the new CLI key in Settings → API keys before trying again.

Organization profiles

Create a named profile when authorizing another organization or API:
Use --profile work on a command or set TRAJECTORY_PROFILE=work to select it without changing the saved default. Python also accepts Client(profile="work"). whoami verifies the credential and reports its organization and source. A saved profile belongs to one API origin. Selecting another --base-url cannot send that saved credential to the new destination. An explicitly selected profile with a mismatched origin returns an error.

API keys and automated jobs

For CI or another unattended environment, supply an API key from Settings → API keys through your environment’s secret management:
Credential precedence is an explicit Client(api_key=...), then TRAJECTORY_API_KEY, then the selected saved profile. An environment key continues to take precedence after switching profiles. The CLI never prints the credential. Client() sends the key as X-API-Key. Without a saved profile or explicit destination, the API is https://api.trajectory.ai. Set TRAJECTORY_BASE_URL or pass base_url for another destination. Saved login files live under $XDG_CONFIG_HOME/trajectory, or ~/.config/trajectory. Set TRAJECTORY_CONFIG_HOME to choose the directory directly. Keep that directory private and outside your project; it contains credentials. On POSIX systems, the directory has mode 700 and credential files have mode 600.

Sign out

Logout revokes the selected saved profile’s key and removes that profile locally. If revocation fails, the CLI retains the credential so you can retry. Environment credentials are managed separately and are not revoked by this command.

Managed spec (benchmark) sessions

A spec task receives TRAJECTORY_API_KEY. Use Client() normally. trajectories.create() returns the run’s trajectory ID; pass that ID to model, reward, and completion calls. The Backend resolves the model endpoint. See Bring your spec. Production traces use the organization API key throughout their lifecycle.