Skip to content

Snowflake Cortex

Install

To use SnowflakeModel, you need to either install pydantic-ai, or install pydantic-ai-slim with the snowflake optional group:

Terminal
pip install "pydantic-ai-slim[snowflake]"

Configuration

Snowflake Cortex serves Claude, GPT, Llama, Mistral, DeepSeek, and Snowflake’s own models through a REST API hosted in your Snowflake account, so data never leaves the Snowflake security perimeter.

To use it, you need your Snowflake account identifier (e.g. myorg-myaccount) and a token: a programmatic access token (PAT), OAuth token, or key-pair JWT. The role the request runs as — the role a PAT is restricted to, or otherwise your user’s default role — must have the SNOWFLAKE.CORTEX_USER database role, which is granted to PUBLIC by default.

For a list of available models, see the Cortex REST API documentation. Fine-tuned models can be referenced as database.schema.model.

Environment variables

Once you have the account identifier and token, you can set them as environment variables:

Terminal
export SNOWFLAKE_ACCOUNT='myorg-myaccount'
export SNOWFLAKE_TOKEN='your-token'

You can then use SnowflakeModel by name:

from pydantic_ai import Agent

agent = Agent('snowflake:claude-sonnet-4-6')
...

Or initialise the model directly with just the model name:

from pydantic_ai import Agent
from pydantic_ai.models.snowflake import SnowflakeModel

model = SnowflakeModel('claude-sonnet-4-6')
agent = Agent(model)
...

provider argument

You can provide a custom Provider via the provider argument:

from pydantic_ai import Agent
from pydantic_ai.models.snowflake import SnowflakeModel
from pydantic_ai.providers.snowflake import SnowflakeProvider

model = SnowflakeModel(
    'claude-sonnet-4-6',
    provider=SnowflakeProvider(account='myorg-myaccount', token='your-token'),
)
agent = Agent(model)
...

You can also customize the SnowflakeProvider with a custom base_url (e.g. when connecting through private connectivity) or httpx.AsyncClient:

from httpx import AsyncClient

from pydantic_ai import Agent
from pydantic_ai.models.snowflake import SnowflakeModel
from pydantic_ai.providers.snowflake import SnowflakeProvider

model = SnowflakeModel(
    'claude-sonnet-4-6',
    provider=SnowflakeProvider(
        base_url='https://myorg-myaccount.privatelink.snowflakecomputing.com/api/v2/cortex/v1',
        token='your-token',
        http_client=AsyncClient(timeout=30),
    ),
)
agent = Agent(model)
...

Model capabilities

Cortex only supports tool calling and structured output for OpenAI (openai-*) and Claude (claude-*) models; for other model families, structured output falls back to prompted output.

Thinking

To enable thinking on Claude models, use the unified thinking model setting, or set SnowflakeModelSettings.snowflake_reasoning directly to control the reasoning token budget:

from pydantic_ai import Agent
from pydantic_ai.models.snowflake import SnowflakeModel, SnowflakeModelSettings

agent = Agent(
    SnowflakeModel('claude-sonnet-4-6'),
    model_settings=SnowflakeModelSettings(snowflake_reasoning={'max_tokens': 4096}),
)
...

On OpenAI models, use the unified thinking setting or openai_reasoning_effort.