> ## Documentation Index > Fetch the complete documentation index at: https://axionquant.com/llms.txt?v=2 > Use this file to discover all available pages before exploring further. # Authentication > How to authenticate the AxionQuant Python SDK with your API key. The AxionQuant SDK authenticates requests using a Bearer token. Every API call that requires data access must include a valid API key. This guide walks through how to get one and how to pass it to the client securely. ## Get an API key Sign in to your Axion account and visit the [API keys page](https://axionquant.com/dashboard/api-keys) to generate a key. Keep it private; treat it like a password. ## Pass the key to the client Pass your API key to the `Axion` constructor: ```python theme={null} from axion import Axion client = Axion(api_key="your_api_key_here") ``` The SDK adds the key to every outgoing request as an `Authorization: Bearer ` header. Never hardcode your API key in source files that you commit to version control. Use an environment variable or a `.env` file instead. Pick the approach that fits your workflow. ## Recommended: environment variables Set the variable in your shell before running your script: ```bash theme={null} export AXION_API_KEY="your_api_key_here" ``` Then read it with `os.getenv`: ```python theme={null} import os from axion import Axion client = Axion(api_key=os.getenv("AXION_API_KEY")) ``` Install python-dotenv: ```bash theme={null} pip install python-dotenv ``` Create a `.env` file in your project root: ```bash .env theme={null} AXION_API_KEY=your_api_key_here ``` Add `.env` to your `.gitignore`: ```bash .gitignore theme={null} .env ``` Load it at the top of your script: ```python theme={null} from dotenv import load_dotenv import os from axion import Axion load_dotenv() client = Axion(api_key=os.getenv("AXION_API_KEY")) ``` `load_dotenv()` is a no-op if the `.env` file does not exist, so this pattern is safe in production environments where the variable is already set. ## How authentication works internally When you pass an `api_key` to the constructor, the SDK adds it to the shared `requests.Session` headers: ```python theme={null} self.session.headers.update({"Authorization": f"Bearer {api_key}"}) ``` Every subsequent request made through that session carries the header automatically. You do not need to pass the key on individual calls. ## What happens without an API key If you call an endpoint that requires authentication without providing an API key, the SDK raises: ```python theme={null} Exception("Authentication required but no API key provided to client.") ``` You can construct an unauthenticated client for endpoints that do not require a key: ```python theme={null} client = Axion() # no api_key argument ``` Attempting a protected request with this client will raise the authentication error above. Handle authentication errors and other exceptions in your code. Make your first authenticated API call.