There are three ways to provide your API key to the SDK:
Environment Variable
Direct Parameter
Configuration File
Set the ALTRINA_API_KEY environment variable:On macOS/Linux:
export ALTRINA_API_KEY="your-api-key-here"
On Windows (Command Prompt):
set ALTRINA_API_KEY=your-api-key-here
On Windows (PowerShell):
$env:ALTRINA_API_KEY="your-api-key-here"
In .env file:
ALTRINA_API_KEY=your-api-key-here
Then use the SDK without specifying the key:
from altrina_sdk import BrowserAgentagent = BrowserAgent() # Uses env var automatically
Pass the API key directly when creating a client:
from altrina_sdk import BrowserAgentagent = BrowserAgent(api_key="your-api-key-here")
Never hardcode API keys in your source code. Use environment variables or secure configuration management.
Create a configuration file for your project:
config.py
import osfrom dotenv import load_dotenv# Load environment variables from .env fileload_dotenv()# ConfigurationALTRINA_API_KEY = os.getenv("ALTRINA_API_KEY")if not ALTRINA_API_KEY: raise ValueError("ALTRINA_API_KEY not found in environment")
Then use in your code:
from config import ALTRINA_API_KEYfrom altrina_sdk import BrowserAgentagent = BrowserAgent(api_key=ALTRINA_API_KEY)
from altrina_sdk import BrowserAgent, __version__print(f"Altrina SDK version: {__version__}")# Test with a simple tasktry: agent = BrowserAgent("YOUR_API_KEY") result = agent.run("Go to example.com and extract the title") print(f"✅ SDK is working! Result: {result.output}")except Exception as e: print(f"❌ Error: {e}")
Solution: Ensure the SDK is installed in the correct Python environment:
# Check installed packagespip list | grep altrina_sdk# If not found, install itpip install altrina_sdk
SSL Certificate Errors
Solution: Update certificates or use a different network:
# Update certificatespip install --upgrade certifi# Or install with trusted hostpip install --trusted-host pypi.org altrina_sdk
Permission Denied Errors
Solution: Install in user space or use virtual environment:
# Install for current user onlypip install --user altrina_sdk# Or use virtual environment (recommended)python -m venv myenvsource myenv/bin/activate # On Windows: myenv\Scripts\activatepip install altrina_sdk
Version Conflicts
Solution: Use a virtual environment to isolate dependencies:
FROM python:3.8-slimWORKDIR /app# Install the SDKRUN pip install altrina_sdk# Copy your applicationCOPY . .# Set environment variableENV ALTRINA_API_KEY=your-api-key-hereCMD ["python", "app.py"]
Build and run:
docker build -t altrina-app .docker run -e ALTRINA_API_KEY=$ALTRINA_API_KEY altrina-app