Skip to content
Lucas Lessa
Voltar para as notícias
SnowflakePublic PreviewImpacto: Alto

Cortex Agent SDK for Python and TypeScript in Snowflake

The Cortex Agent SDK allows building applications that use Cortex Agents and Cortex Code in Python and TypeScript.

O que mudou

Use cases

Imagine you have a custom application and need to integrate AI to query enterprise data securely, maintain multi-turn conversations, and run long background tasks. With the SDK, you can:

  • Query governed data using Cortex Analyst and Cortex Search.
  • Maintain persistent multi-turn conversations.
  • Run tasks in the background and reconnect by run ID.
  • Integrate Cortex Code for agentic development workflows.

How to use

Install the TypeScript package:

npm install "@snowflake/cortex-agent-sdk@>=0.0.2"

Start a conversation and send a message:

import {
  CortexAgentClient,
  type AgentResponse,
  type Conversation,
  type Turn,
} from "@snowflake/cortex-agent-sdk";

const client: CortexAgentClient = new CortexAgentClient({
  account: process.env.SNOWFLAKE_ACCOUNT!,
  auth: process.env.SNOWFLAKE_PAT!,
});

const conversation: Conversation = await client.conversations.create({
  thread: { origin_application: "my-app" },
  agent: {
    type: "inline",
    spec: { models: { orchestration: "claude-sonnet-4-5" } },
  },
});

const turn: Turn = await conversation.send("Explain Snowflake micro-partitions in three sentences.");
const answer: AgentResponse = await turn.result();
console.log(answer.text);

What happens in this code:

  1. Initializes the Cortex Agent client using environment variables for the account and token.
  2. Creates a new conversation linked to an inline agent.
  3. Sends an instruction for the agent to process.
  4. Awaits the result and prints the returned response.

Install the Python package:

pip install "snowflake-cortex-agent-sdk>=0.0.2"

Run a basic call in Python:

from cortex_agent_sdk import AgentResponse, Conversation, CortexAgentClient, Turn

client: CortexAgentClient = CortexAgentClient(account="my_account", auth="<token>")
conversation: Conversation = client.conversations.create(
    origin_application="cortex_agent_sdk",
    agent={"type": "inline", "spec": {}},
)
turn: Turn = conversation.send("What can Cortex Agent do?")
answer: AgentResponse = turn.result()
print(answer.text)

What happens in this code:

  1. Creates a client instance passing the account and authentication token.
  2. Sets up a new conversation session with an inline agent.
  3. Sends a question to the agent.
  4. Collects and displays the generated response text.

Limitations and requirements

  • Stage: Public Preview.
  • The Python SDK requires Python 3.10 or later.
  • The TypeScript SDK requires Node.js 22.22 or later.
  • Requires a Snowflake account with Cortex Agents enabled and valid credentials (PAT, OAuth, key-pair JWT, or session token).
Ver nota oficial do Snowflake

Cortex Agent SDK (Public Preview)

Resumo e explicação gerados por IA a partir da release note oficial. Em caso de dúvida, a documentação oficial da plataforma prevalece.

Relacionadas