Skip to main content

API Keys

API keys authenticate inference requests and SDK calls to the Axionic backend. Format: ax_ followed by 48 lowercase hex characters (e.g., ax_a3f9...). Get a key from Spectra Settings → API Keys or via the CLI:
Set the key in code:
string
required
Your Axionic API key. Must start with ax_.
boolean
default:"false"
If true, saves the key to ~/.mechanex/config.json so it is auto-loaded on every future SDK init and CLI start.
persist=True writes the key to ~/.mechanex/config.json. Omit or pass False to keep the key in memory only for the current process.

Config File

The SDK and CLI auto-load credentials from ~/.mechanex/config.json at startup. Fields stored in the config file: You can edit this file directly, but prefer using mx.set_key(persist=True) or mx.login() to populate it correctly.

JWT Authentication

Some operations — billing, account management, and organization access — require a JWT rather than an API key. Obtain one by logging in:
string
required
Your Axionic account email address.
string
required
Your account password.
Tokens are stored automatically in the config file. When a JWT expires, the SDK silently refreshes it via POST /auth/refresh and retries the original request — no manual intervention needed. For key creation, rotation, and account management (balance, user info), use the CLI.