airflow.providers.snowflake.hooks.cortex_model

Expose Snowflake Cortex’s OpenAI-compatible chat endpoint as a pydantic-ai model hook.

Attributes

CORTEX_CHAT_COMPLETIONS_PATH

Classes

PydanticAISnowflakeHook

Hook for Snowflake Cortex's OpenAI-compatible chat endpoint via pydantic-ai.

Module Contents

airflow.providers.snowflake.hooks.cortex_model.CORTEX_CHAT_COMPLETIONS_PATH = '/api/v2/cortex/v1'[source]
class airflow.providers.snowflake.hooks.cortex_model.PydanticAISnowflakeHook(llm_conn_id=None, model_id=None, fallback_conn_ids=None, *, snowflake_conn_id=None, **kwargs)[source]

Bases: airflow.providers.common.ai.hooks.pydantic_ai.PydanticAIHook

Hook for Snowflake Cortex’s OpenAI-compatible chat endpoint via pydantic-ai.

Unlike the other PydanticAI* hooks, credentials do not live on this connection: they are read from an existing snowflake connection (OAuth, PAT, or key-pair JWT – whichever that connection is configured for), refreshed on every request the same way as SnowflakeCortexAgentHook and SnowflakeSqlApiHook. See SnowflakeRestTokenProvider. The underlying httpx2.AsyncClient is built once and lives as long as this hook instance; nothing currently closes it (SnowflakeProvider only owns and closes a client it built itself, not one passed in).

Connection fields:
  • extra JSON: {"model": "snowflake:claude-4-sonnet", "snowflake_conn_id": "snowflake_default"}

Model family support (pydantic-ai-slim’s SnowflakeProvider.model_profile): Claude (claude*) and OpenAI (openai-*) models support tools and structured output; other families (llama*, snowflake-llama*, mistral*, mixtral*, deepseek*, and any unlisted family) do not support tools, and structured output falls back to prompted mode. Use a Claude or OpenAI family model for a tool-using agent.

Parameters:
  • llm_conn_id (str | None) – Airflow connection ID for this pydanticai_snowflake connection.

  • model_id (str | None) – Model identifier, e.g. "snowflake:claude-4-sonnet". A bare name (no recognized platform prefix) is qualified with snowflake:.

  • fallback_conn_ids (list[str] | None) – See PydanticAIHook.

  • snowflake_conn_id (str | None) – Connection ID of an existing Snowflake connection to source credentials, account, and host from. Takes precedence over the connection extra’s snowflake_conn_id; one of the two is required.

conn_type = 'pydanticai_snowflake'[source]
default_conn_name = 'pydanticai_snowflake_default'[source]
hook_name = 'Pydantic AI (Snowflake Cortex)'[source]
model_provider = 'snowflake'[source]
snowflake_conn_id = None[source]
static get_ui_field_behaviour()[source]

Return custom field behaviour for the Airflow connection form.

test_connection()[source]

Test connection by resolving the model and fetching a Snowflake token.

Calls Snowflake’s token endpoint, so a bad credential is reported here. Does NOT call the LLM API.

Was this entry helpful?