Cortex Agent SDK

The Cortex Agent SDK helps you build applications that reason over your governed Snowflake data and take action with tools. Use it from Python or TypeScript to stream responses, preserve multi-turn conversations, run long tasks in the background, and manage reusable agent objects.

You can also embed Cortex Code when your application needs an agentic coding loop that can inspect files, run commands, use tools, and make changes in a workspace.

What you can build

GoalSDK capability
Answer questions with governed dataRun inline agents or saved agent objects that use Cortex Analyst, Cortex Search, and custom tools.
Show progress as it happensStream text, tool calls, tool results, citations, and status events to your application.
Build a conversational experienceUse conversation helpers and persistent threads to maintain context across turns and application sessions.
Run longer tasks reliablyStart a background run, disconnect safely, and reconnect later by run ID.
Embed an agentic coding workflowUse the Cortex Code CLI on your application host, or run the managed coding agent through a conversation.

Get started

You need a Snowflake account with Cortex Agents available and a supported credential. The SDK derives the API URL from the account value and uses Snowflake’s canonical hyphenated host form when the account identifier contains an underscore (_). Pass a full base URL only when you need a regional, PrivateLink, pre-production, or proxy endpoint. The Python SDK requires Python 3.10 or later. The TypeScript SDK requires Node.js 22.22 or later.

Choose your language to install the SDK and send an agent turn.

Install the SDK:

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

Set SNOWFLAKE_ACCOUNT and SNOWFLAKE_PAT in your environment, and then start a conversation:

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.");
console.log(`Conversation ID: ${conversation.id}`);

const answer: AgentResponse = await turn.result();
console.log(answer.text);

For a complete setup and multi-turn example, see the quickstart.

Authenticate

The SDK supports programmatic access tokens, OAuth access tokens, key pair JSON Web Tokens (JWTs), Snowflake session tokens, and custom authenticators. Keep credentials outside your source code. The SDK asks the authenticator for headers before every request attempt, and can run a refresh callback once by default when Snowflake returns a recognized expired-token or expired-session response.

For authentication examples, header formats, session-token guidance, and refresh behavior, see Authenticate Cortex Agent SDK requests.

Choose a coding interface

Choose the interface based on where you want the agent loop and tools to run.

InterfaceUse it whenHow it runs
Cortex Code CLIYour application host can install Cortex Code and needs access to local files, commands, hooks, or MCP servers.The SDK launches the local cortex executable.
Managed coding agentYou want durable, Snowflake-managed coding-agent turns without running a local CLI.Create a conversation with agent: { type: "coding", spec: { ... } }, or provide that object as a per-turn send() override.

For examples and supported options, see Cortex Code and Conversations.

Next steps

Where your configuration of Cortex Code uses a model provided on the Model and Service Pass-Through Terms, your use of that model is further subject to the terms for that model on that page.

The data classification of inputs and outputs are as set forth in the following table.

Input data classificationOutput data classificationDesignation
Usage DataCustomer Data

Covered AI Features

[1]

For additional information, refer to Snowflake AI and ML.