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.
Metadata
Release files for snowflake-cortex-agents 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| snowflake_cortex_agents-0.1.0.tar.gz | 36.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| snowflake_cortex_agents-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 85.1 kB
Release files / snowflake_cortex_agents-0.1.0.tar.gz
| Download URL | snowflake_cortex_agents-0.1.0.tar.gz |
|---|---|
| Size | 36.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
52fb969742620f0b75124f391a68d89fd0d1e991dbb0d0efad2926e8c63e9528
|
|
BLAKE2b-256 checksum How to use checksums |
496a9e5960a2b708e70f1f08b90145b8633636a28fb598a969f85527559d5b10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / snowflake_cortex_agents-0.1.0-py3-none-any.whl
| Download URL | snowflake_cortex_agents-0.1.0-py3-none-any.whl |
|---|---|
| Size | 48.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8fa23fdd0280989b5a611bc2f9c19bc713d175c55b6158c35c554bfef926dc9a
|
|
BLAKE2b-256 checksum How to use checksums |
da45f3a3761e5e2231148869d6037c5bac774a47f9aacdf041df297b3bbd5b03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|