Skip to main content

Environment and Configuration

The Svantic CLI resolves configuration from three sources in order of precedence: CLI flags, environment variables, and built-in defaults.

Precedence

A CLI flag always wins. If not provided, the CLI checks the corresponding environment variable, then the config file. If none are set, the built-in default is used.

Environment Variables

Place variables in a .env file in the working directory. The CLI loads it automatically.

CLI Flags

Configuration File

The CLI reads configuration from ~/.svantic/config.json:

Authentication

Chat Commands

Interactive and headless modes require mesh credentials. The auth flow:
  1. CLI reads client_id and client_secret from flags or environment variables.
  2. Calls MeshAuth.get_token() on the Mesh API, passing credentials.
  3. Mesh returns a JWT with tenant context.
  4. CLI calls POST /sessions/init on the gateway with the JWT.
  5. Gateway returns a session_id for subsequent messages.
In interactive mode, the terminal also registers as an A2A agent via MeshConnector.connect().

Admin Commands

Admin commands (status, tenants, agents, sessions, config) require a JWT token:
Or store it in ~/.svantic/config.json.

Token Refresh

If a session expires while idle, the terminal automatically:
  1. Re-authenticates to get a fresh JWT.
  2. Creates a new session via the gateway.
  3. Retries the message transparently.

Forge Mode

Forge commands (svantic forge tool, svantic forge agent) run locally and do not require mesh credentials. The only relevant environment variable is:
  • GOOGLE_API_KEY — required when using --prompt for AI-powered tool generation.

Setting Up a .env File

Create a .env file in your working directory:

Troubleshooting

”Mesh credentials required”

Fix: Set both SVANTIC_CLIENT_ID and SVANTIC_CLIENT_SECRET in your .env file or pass them as flags.

”Auth error: HTTP 401”

Fix: Verify that SVANTIC_CLIENT_ID and SVANTIC_CLIENT_SECRET are correct. Check that the credentials have not expired or been revoked.

”Connection error”

Fix: Ensure the Svantic platform is reachable at the URL specified by SVANTIC_URL (default: https://api.svantic.com). Check network connectivity.

”Session expired”

The terminal prints Session expired (reaped); re-initializing... and retries automatically. If re-initialization fails, check that your credentials are still valid and the gateway is reachable.

”Could not reach gateway”

Fix: Verify SVANTIC_URL is correct. Check network connectivity. Ensure the Svantic platform is reachable.