Skip to content

Snowflake Cortex Agents Documentation

Welcome to the Snowflake Cortex Agents SDK documentation! This SDK provides Python clients for interacting with Snowflake's Cortex REST API, including support for Cortex Agents and Analysts powered by Cortex LLMs.

Key Capabilities

  • 🤖 Cortex Agent - Build intelligent agents with Snowflake's Cortex API
  • 📊 Cortex Analyst - Generate SQL from natural language questions
  • Async Support - Full async/await support for high-performance applications
  • 🔄 Streaming Responses - Real-time event streaming for interactive experiences
  • 🛠️ Type Hints - Full type annotations for IDE support and type checking

Installation

pip install snowflake-cortex-agents

Quick Start

Setup Snowflake credentials as environment variables:

export SNOWFLAKE_ACCOUNT_URL=https://your-account.snowflakecomputing.com
export SNOWFLAKE_PAT=your_personal_access_token

Or, pip install snowflake-cortex-agents[dotenv] and create a .env file with your Snowflake credentials. 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

Synchronous:

from cortex_agents import CortexAgent

with CortexAgent() as client:
    response = client.run(
        "What's the monthly revenue this year?",
        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)

Asynchronous:

import asyncio
from cortex_agents import AsyncCortexAgent

async def main():
    async with AsyncCortexAgent() as agent:
        response = await agent.run(
            "Analyze sales trends",
            agent_name="my_agent"
        )
        for event in response:
            if event["type"] == "text.delta":
                print(event["data"]["text"], end="", flush=True)

asyncio.run(main())

Get Started

Learn more by exploring the documentation sections: