airflow.providers.snowflake.hooks.cortex_model¶
Expose Snowflake Cortex’s OpenAI-compatible chat endpoint as a pydantic-ai model hook.
Attributes¶
Classes¶
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.PydanticAIHookHook 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 existingsnowflakeconnection (OAuth, PAT, or key-pair JWT – whichever that connection is configured for), refreshed on every request the same way asSnowflakeCortexAgentHookandSnowflakeSqlApiHook. SeeSnowflakeRestTokenProvider. The underlyinghttpx2.AsyncClientis built once and lives as long as this hook instance; nothing currently closes it (SnowflakeProvideronly 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_snowflakeconnection.model_id (str | None) – Model identifier, e.g.
"snowflake:claude-4-sonnet". A bare name (no recognized platform prefix) is qualified withsnowflake:.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.