# Logging in to Afnio Backend Afnio is designed for seamless agent development: your workflow logic and forward pass run locally, while language models (LM) calls and optimization (backward pass) are securely handled by the Afnio backend, hosted on [Tellurio Studio](https://platform.tellurio.ai/). This enables scalable experiment tracking and advanced optimization features without extra setup. To use Afnio—whether for inference, evaluation, or optimization—you’ll need to log in with your [Tellurio API key](https://platform.tellurio.ai/settings/api-keys). Your credentials are securely stored in your system keyring after login. For more details on experiment tracking and optimization, see [Runs and Experiments](runs_and_experiments). ## Login via CLI (Recommended) The fastest way to log in is using the command line: ```bash afnio login --relogin ``` _Output:_ ```output Please enter your Tellurio API key and hit enter, or press ctrl+c to quit: [afnio] API key provided and stored securely in local keyring. [afnio] Currently logged in as 'username' to 'https://platform.tellurio.ai'. Use `afnio login --relogin` to force relogin. ``` You will be prompted for your Tellurio API key (available on the Tellurio Studio overview page or under [API Keys](https://platform.tellurio.ai/settings/api-keys)). Once logged in, your credentials are securely stored in your system keyring for future sessions. ## Login via Python Code You can also log in programmatically from your script or notebook: ```python import afnio.tellurio as te te.login(api_key="YOUR_TELLURIO_API_KEY", relogin=True) ``` _Output:_ ```output INFO : API key provided and stored securely in local keyring. INFO : Currently logged in as 'username' to 'https://platform.tellurio.ai'. Use `afnio login --relogin` to force relogin. ``` You only need to log in once per session. If you change your API key or want to force a new login, use `relogin=True`. ## Login via Environment Variable You can also log in by setting the `TELLURIO_API_KEY` environment variable before starting your Python session or running CLI commands: ```bash export TELLURIO_API_KEY="YOUR_TELLURIO_API_KEY" ``` ## Credential Storage and Resolution - Credentials and preferences (such as your most recent username and consent to share your API key with the server) are stored in `~/.tellurio_config.json` in your home directory. - When logging in via Python, Afnio looks for your API key in the following order: 1. The `api_key` argument passed directly to `te.login()` 2. The `TELLURIO_API_KEY` environment variable 3. Your system keyring (if previously stored) ## Troubleshooting - If you see authentication errors, check that your API key is set correctly. - You can store your API key securely in your environment or use a password manager. ## Further Reading - [Runs and Experiments](runs_and_experiments)