Installation¶
System Requirements¶
- Python 3.10 or higher
- pip (Python package manager)
Basic Installation¶
Install the package from PyPI:
Installation with Optional Dependencies¶
The SDK has optional dependencies for additional features:
For chart plotting and visualization:
This installs Altair and Pandas for rendering Vega-Lite charts.
For environment variable management:
This installs python-dotenv for .env file support.
For all optional dependencies:
Configuration¶
Before using the SDK, you need to set up your Snowflake credentials.
Environment Variables¶
Set these environment variables:
export SNOWFLAKE_ACCOUNT_URL="https://your-account.snowflakecomputing.com"
export SNOWFLAKE_PAT="your-personal-access-token"
Using .env File¶
Create a .env file in your project root. If you're working from this repository, you can copy .env.example to .env first:
SNOWFLAKE_ACCOUNT_URL=https://your-account.snowflakecomputing.com
SNOWFLAKE_PAT=your-personal-access-token
Direct Parameters¶
Pass credentials directly to the client:
from cortex_agents import CortexAgent, load_credentials
agent = CortexAgent()
# Credentials are loaded from environment or .env file
# Or explicitly:
url, pat = load_credentials(
account_url="https://your-account.snowflakecomputing.com",
pat="your-personal-access-token"
)
Key-Pair JWT Authentication¶
If your Snowflake account uses key-pair authentication instead of a PAT, pass the JWT and set token_type="KEYPAIR_JWT":
from cortex_agents import CortexAgent
agent = CortexAgent(
account_url="https://your-account.snowflakecomputing.com",
pat="your-keypair-jwt-token",
token_type="KEYPAIR_JWT",
)
This adds the X-Snowflake-Authorization-Token-Type: KEYPAIR_JWT header to all requests.
Getting Your Credentials¶
- Snowflake Account URL: Found in your Snowflake account settings
- Personal Access Token (PAT): Generate from Snowflake web UI
- Login to Snowflake
- Go to Admin → Users & Roles
- Select your user
- Click "Security" tab
- Generate a new authentication token
Troubleshooting¶
ImportError: No module named 'cortex_agents'
Make sure you've installed the package:
Missing credentials error
Ensure your environment variables are set:
Connection refused
Verify your account URL is correct and your PAT is still valid.
Next Steps¶
- Check out the Quick Start guide
- Explore Examples and use cases
- Read the API Reference for detailed API documentation