Skip to main content

Run Claude Code against Claude models hosted on Snowflake Cortex.

Project description

❄️ snowflake-claude-code

PyPI CI License

Run Claude Code against Claude models served by Cortex inside your Snowflake account, so prompts and responses never leave your Snowflake governance boundary.

Claude Code  →  FastAPI proxy (127.0.0.1:4000)  →  Snowflake Cortex Inference

The CLI authenticates to Snowflake (SSO or PAT), starts a local proxy that translates Anthropic Messages API calls to Cortex Inference calls (SSE streaming included), and launches Claude Code pointed at the proxy.

⚡ Quick start

uv tool install snowflake-claude-code
npm install -g @anthropic-ai/claude-code
snowflake-claude-code --account MYORG-MYACCOUNT --user me@company.com

Browser pops for Snowflake SSO, proxy spins up, Claude Code launches.

🔒 Why

Your Claude Code session never talks to Anthropic. Every prompt, file read, tool call, and model response goes over TLS to the same Snowflake endpoint your warehouse queries already use — governed by your existing Snowflake trust boundary, not a new third-party LLM vendor.

  • 🚫 No traffic to Anthropic. The proxy binds to 127.0.0.1 only; the only outbound endpoint is your Snowflake account's API.
  • 🛡️ Snowflake IAM applies. Role, warehouse, and network policy controls gate model access. Revoke Snowflake → revoke AI.
  • 🔑 Familiar auth. Browser SSO flows through your existing IdP; PATs for headless.
  • 📝 Full audit trail. Every call lands in SNOWFLAKE.ACCOUNT_USAGE.CORTEX_REST_API_USAGE_HISTORY.
  • 🌍 Data residency honored. Inference runs in your account's region.
  • 🧠 No training on your data. Per Snowflake Cortex terms.
  • 💰 Consolidated spend. Cortex tokens roll up with your warehouse costs.
  • ♻️ Transparent re-auth. Expired tokens trigger a silent refresh mid-session.

📦 Install

Requires Python 3.10+ and the Claude Code CLI.

uv tool install snowflake-claude-code     # recommended
pipx install snowflake-claude-code        # or pipx
pip install snowflake-claude-code         # or pip
uvx snowflake-claude-code ...             # or run without installing

And Claude Code itself:

npm install -g @anthropic-ai/claude-code

🚀 Usage

snowflake-claude-code \
  --account MYORG-MYACCOUNT \
  --user me@company.com \
  --model claude-sonnet-4-6

Flags

Flag Default Description
--account Snowflake account identifier
--user Snowflake username (required for SSO)
--model claude-sonnet-4-6 Cortex model ID
--port 4000 Local proxy port
--token Snowflake PAT (skips browser SSO)
--verbose, -v off Debug logging

Environment variables

Any flag can also be provided via an env var — useful for shell profiles, CI, or devcontainers:

Env var Equivalent flag
SNOWFLAKE_ACCOUNT --account
SNOWFLAKE_USER (or SNOWFLAKE_USERNAME) --user
SNOWFLAKE_MODEL --model
SNOWFLAKE_PORT --port
SNOWFLAKE_TOKEN --token
export SNOWFLAKE_ACCOUNT=MYORG-MYACCOUNT
export SNOWFLAKE_USER=me@company.com
snowflake-claude-code

Config file

Or persist them in ~/.snowflake-claude-code/config.toml:

account = "MYORG-MYACCOUNT"
user = "me@company.com"
default_model = "claude-sonnet-4-6"
port = 4000
# token = "pat-..."   # optional, skips SSO

Precedence: CLI flags > env vars > config file > defaults.

🤖 Supported models

Model ID Notes
claude-sonnet-4-6 Default — 1M context built-in
claude-sonnet-4-5 Previous-generation Sonnet
claude-opus-4-6 Most capable Claude model on Cortex
claude-opus-4-5 Previous-generation Opus
claude-haiku-4-5 Fastest, cheapest

Not every model is available in every Snowflake region — use cross-region inference or check SHOW CORTEX FUNCTIONS for your region.

Non-Claude Cortex models work for plain chat too (--model mistral-large2, --model llama3.1-70b). Tool-calling compatibility varies.

🔍 Verify traffic is hitting Snowflake

SELECT START_TIME, MODEL_NAME, TOKENS, USER_ID, INFERENCE_REGION
FROM SNOWFLAKE.ACCOUNT_USAGE.CORTEX_REST_API_USAGE_HISTORY
WHERE START_TIME >= CURRENT_DATE()
ORDER BY START_TIME DESC;

ACCOUNT_USAGE views lag 45 min–3 hours. For real-time, run with --verbose.

🏗️ Architecture

snowflake_claude_code/
├── cli.py        Parse config, start proxy, launch `claude` subprocess
├── proxy.py      FastAPI app: /v1/messages, /v1/models, /v1/health
├── translate.py  Anthropic ⇄ Cortex format translation + SSE adapter
├── auth.py       Snowflake connector + re-auth on 401
└── config.py     Layered config loader

The proxy binds to 127.0.0.1 only. The Snowflake token lives in process memory for the session lifetime and is cleared on exit.

🛠️ Development

git clone https://github.com/dylan-murray/snowflake-claude-code.git
cd snowflake-claude-code
uv sync --group dev

uv run pytest
uv run ruff check .
uv run ruff format .

CI runs on Python 3.10–3.13.

📄 License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snowflake_claude_code-1.0.2.tar.gz (83.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snowflake_claude_code-1.0.2-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file snowflake_claude_code-1.0.2.tar.gz.

File metadata

  • Download URL: snowflake_claude_code-1.0.2.tar.gz
  • Upload date:
  • Size: 83.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for snowflake_claude_code-1.0.2.tar.gz
Algorithm Hash digest
SHA256 acc353d072b094d2a35bce5a71922262071ba755f27c11fb0b6b98b0c67e7009
MD5 f90c3e8238d7ea71bc3137c90df62157
BLAKE2b-256 f76414154fda9850f0d3d098d46373dbe0aca24810637fe7b506aaa1c0ab6487

See more details on using hashes here.

Provenance

The following attestation bundles were made for snowflake_claude_code-1.0.2.tar.gz:

Publisher: release.yml on dylan-murray/snowflake-claude-code

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snowflake_claude_code-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for snowflake_claude_code-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 af3429a9c79d57dac7cbf7906596641b8005cb152951d1bba91c5a393e62f265
MD5 805e3337094352d0f3efa71d8c967065
BLAKE2b-256 89a094527d9c045168f7ea9b32d57efd23f763f1185a6bbb9b9c13e483944632

See more details on using hashes here.

Provenance

The following attestation bundles were made for snowflake_claude_code-1.0.2-py3-none-any.whl:

Publisher: release.yml on dylan-murray/snowflake-claude-code

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page