Snowflake Cortex Agent SDK for Python
Python SDK for the Snowflake Cortex Agent REST API. Covers the current public surface:
- Durable lite, data-agent, and coding-agent conversations
- Named + versioned data agents through the direct API client
- Coding-agent runs with sandbox, bash, skills, and workspace mounts
- Threads, background runs, streaming, and feedback through
cortex_agent_sdk.api - High-level
Conversation.send()->Turnabstraction - Route-test helpers in
cortex_agent_sdk.testing(seedocs/13-testing.md) - Curated
AgentResponsecontent and usage view - Synchronous and asyncio clients
- Claude-shaped local Cortex Code sessions via
cortex_agent_sdk.cortexcode
Install
View snowflake-cortex-agent-sdk on PyPI.
pip install snowflake-cortex-agent-sdk
Requires Python 3.10 or newer.
Quickstart
import os
from cortex_agent_sdk import (
AgentResponse,
Conversation,
ConversationMessage,
CortexAgentClient,
Turn,
)
client: CortexAgentClient = CortexAgentClient(
account="my_account",
auth=os.environ["SNOWFLAKE_PAT"],
)
conversation: Conversation = client.conversations.create(
origin_application="cortex_agent_sdk",
agent={"type": "inline", "spec": {"models": {"orchestration": "claude-sonnet-4-5"}}},
)
turn: Turn = conversation.send("What is Snowflake Arctic?")
print(f"run: {turn.id}")
answer: AgentResponse = turn.result()
print(answer.text)
history: list[ConversationMessage] = conversation.history()
Set a default agent when creating a conversation. A send can override it for one turn when needed:
inline_turn: Turn = conversation.send(
"Summarize the context.",
agent={"type": "inline", "spec": {"models": {"orchestration": "auto"}}},
)
data_turn: Turn = conversation.send(
"Which products grew fastest?",
agent={
"type": "data",
"spec": {"database": "ANALYTICS", "schema": "PUBLIC", "name": "SALES_AGENT"},
},
)
coding_turn: Turn = conversation.send(
"Fix the failing test.",
agent={
"type": "coding",
"spec": {
"models": {"orchestration": "claude-sonnet-4-5"},
"permission_policy": "always_allow",
"workspace_mounts": [{"name": "USER$MY_USER.PUBLIC.DEFAULT$"}],
},
},
)
Use turn.events() for event-level progress and turn.cancel() to stop a run.
Async
The asynchronous API mirrors the sync API:
from cortex_agent_sdk import AgentResponse, AsyncConversation, AsyncCortexAgentClient, AsyncTurn
async with AsyncCortexAgentClient(account="my_account", auth="<token>") as client:
conversation: AsyncConversation = await client.conversations.create(
origin_application="cortex_agent_sdk",
agent={"type": "inline", "spec": {"models": {"orchestration": "auto"}}},
)
turn: AsyncTurn = await conversation.send("Analyze this data.")
answer: AgentResponse = await turn.result()
Cortex Code sessions (cortex_agent_sdk.cortexcode)
cortex_agent_sdk.cortexcode is the Cortex Code SDK for driving the local
cortex binary from Python. It exposes one-shot query() calls and long-lived
CortexCodeSDKClient sessions with permissions, hooks, MCP, plugins, structured
output, and session controls.
import asyncio
from cortex_agent_sdk.cortexcode import AssistantMessage, ResultMessage, query
async def main() -> None:
async for message in query(prompt="Summarize this repository"):
if isinstance(message, AssistantMessage):
for block in message.content:
if hasattr(block, "text"):
print(block.text, end="")
elif isinstance(message, ResultMessage):
print(f"\nDone: {message.subtype}")
asyncio.run(main())
This entry point runs the local Cortex Code CLI. For server-side integrations,
use the package-root CortexAgentClient with a coding-agent conversation
instead.
Resources at a glance
| Resource | Purpose |
|---|---|
client.conversations |
Create, attach, list, and search conversations |
client.feedback |
Send feedback for a data-agent turn |
Conversation binds a thread to an inline, data, or coding agent and hides
message and run plumbing. send() returns a Turn with id, result(),
events(), and cancel().
For direct REST request shapes, streaming modes, raw response wrappers, or SSE
parsing, import CortexAgentClient and related types from
cortex_agent_sdk.api.
Separate entry point, not a client.* resource:
| Entry point | Purpose |
|---|---|
cortex_agent_sdk.cortexcode |
Python SDK for the local Cortex Code CLI: permissions, hooks, MCP, plugins, and session controls |
Auth at a glance
Authentication headers are rebuilt for every attempt. refresh_auth runs only
for recognized token/session expiry responses, including legacy 200 JSON error
envelopes; by default the SDK refreshes once
and replays the request once. SDK-generated errors do not include credential
values.
| Class | For | Header shape |
|---|---|---|
PatAuth (or string shorthand) |
Programmatic Access Token | Authorization: Bearer <token> + X-Snowflake-Authorization-Token-Type: PROGRAMMATIC_ACCESS_TOKEN |
OAuthAuth |
External OAuth / Snowflake OAuth access tokens | Authorization: Bearer <token> + X-Snowflake-Authorization-Token-Type: OAUTH |
KeyPairJwtAuth |
Key-pair JWT auth | Authorization: Bearer <token> + X-Snowflake-Authorization-Token-Type: KEYPAIR_JWT |
SnowflakeSessionTokenAuth |
snowflake-connector-python session tokens |
Authorization: Snowflake Token="<token>" |
CallableAuth |
Lazy token minting | Bearer + configurable token-type header |
Custom Authenticator |
Anything else | You return the header map |
Status
Preview. Expect breaking changes as the underlying API stabilizes.
License
See LICENSE. Use is governed by your Snowflake customer agreement.
Metadata
Release files for snowflake-cortex-agent-sdk 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| snowflake_cortex_agent_sdk-0.0.3.tar.gz | 164.0 kB | Without provenance | Details for snowflake_cortex_agent_sdk-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| snowflake_cortex_agent_sdk-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for snowflake_cortex_agent_sdk-0.0.3-py3-none-any.whl |
Total release size: 359.4 kB
Release files / snowflake_cortex_agent_sdk-0.0.3.tar.gz
| Download URL | snowflake_cortex_agent_sdk-0.0.3.tar.gz |
|---|---|
| Size | 164.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91a1d15b48d0c961e24879e382733e7cb906cb267c4ca4b8868de72e40cca8a7
|
|
BLAKE2b-256 checksum How to use checksums |
79688a464f38118c622edd990a754a608dbd79561bb435ed0055d312a5a12735
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.8
|
Release files / snowflake_cortex_agent_sdk-0.0.3-py3-none-any.whl
| Download URL | snowflake_cortex_agent_sdk-0.0.3-py3-none-any.whl |
|---|---|
| Size | 195.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3340cf47cbab0091a9054564e096fe4fa61edad7f86afbe23ff8f8365ecb73da
|
|
BLAKE2b-256 checksum How to use checksums |
3fb59593bde317422cf7e3408fd07dc9552a5123c63ab88a5d4ea19fe05c170a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.8
|
Security for snowflake-cortex-agent-sdk 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.