Python SDK for Snowflake Cortex Agents and Analyst
Project description
Snowflake Cortex Agents Python SDK
Python SDK for Snowflake Cortex Agents and Cortex Analyst, with sync and async clients, SSE streaming, and chart helpers for agent responses.
Installation
Install from PyPI:
pip install snowflake-cortex-agents
Optional extras:
dotenvfor.envloadingchartsfor Altair and Pandas chart renderingallfor all optional dependencies
pip install snowflake-cortex-agents[all]
For source and contributor setup, see CONTRIBUTING.md.
Credentials
Set credentials with environment variables:
export SNOWFLAKE_ACCOUNT_URL=https://your-account.snowflakecomputing.com
export SNOWFLAKE_PAT=your-personal-access-token
Or install snowflake-cortex-agents[dotenv] and use a .env file:
SNOWFLAKE_ACCOUNT_URL=https://your-account.snowflakecomputing.com
SNOWFLAKE_PAT=your-personal-access-token
When working from this repository, you can copy .env.example to .env and fill in your values.
Quick Start
Both Cortex Agent run() and Cortex Analyst message() return streaming SSE responses.
Run an existing agent
from cortex_agents import CortexAgent
with CortexAgent() as client:
response = client.run(
"What's this month revenue?",
agent_name="MY_AGENT",
database="MY_DATABASE",
schema="MY_SCHEMA",
)
for event in response:
if event["type"] == "text.delta":
print(event["data"]["text"], end="", flush=True)
Ask Cortex Analyst a question
from cortex_agents import CortexAnalyst
with CortexAnalyst() as analyst:
response = analyst.message(
question="What were the top 5 products by revenue last month?",
semantic_model_file="@my_stage/semantic_model.yaml",
)
for event in response:
if event["type"] == "text.delta":
print(event["data"]["text"], end="", flush=True)
elif event["type"] == "sql.delta":
print(event["data"]["sql"], end="", flush=True)
Async support
Async clients are available via AsyncCortexAgent and AsyncCortexAnalyst. See docs/quickstart.md and examples/example_agent_async.py for runnable async examples.
Documentation
- docs/installation.md: installation, optional extras, and credential setup
- docs/quickstart.md: sync and async getting-started flows
- docs/guides/agents.md: Cortex Agent usage
- docs/guides/analyst.md: Cortex Analyst usage
- docs/guides/threads_api.md: thread management
- docs/guides/agents_threads.md: conversational agent patterns
- USAGE.md: broader API usage notes
- docs/guides/chart_plotting.md: chart rendering helpers
- examples/: runnable examples
Requirements
- Python 3.10+
- Snowflake account with Cortex enabled
- Personal Access Token (PAT)
Contributing
Development workflow, uv-based setup, and quality checks are documented in CONTRIBUTING.md.
License
This project is licensed under the MIT License. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file snowflake_cortex_agents-0.1.0.tar.gz.
File metadata
- Download URL: snowflake_cortex_agents-0.1.0.tar.gz
- Upload date:
- Size: 36.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52fb969742620f0b75124f391a68d89fd0d1e991dbb0d0efad2926e8c63e9528
|
|
| MD5 |
a55ee76c622d177363749d2bf17e0d14
|
|
| BLAKE2b-256 |
496a9e5960a2b708e70f1f08b90145b8633636a28fb598a969f85527559d5b10
|
File details
Details for the file snowflake_cortex_agents-0.1.0-py3-none-any.whl.
File metadata
- Download URL: snowflake_cortex_agents-0.1.0-py3-none-any.whl
- Upload date:
- Size: 48.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fa23fdd0280989b5a611bc2f9c19bc713d175c55b6158c35c554bfef926dc9a
|
|
| MD5 |
74d6165c41d9041ec20e0f371f098137
|
|
| BLAKE2b-256 |
da45f3a3761e5e2231148869d6037c5bac774a47f9aacdf041df297b3bbd5b03
|