airflow.providers.databricks.hooks.model_serving

Expose Databricks Model Serving’s OpenAI-compatible chat endpoint as a pydantic-ai model hook.

Classes

PydanticAIDatabricksHook

Hook for Databricks Model Serving's OpenAI-compatible chat endpoint via pydantic-ai.

Module Contents

class airflow.providers.databricks.hooks.model_serving.PydanticAIDatabricksHook(llm_conn_id=None, model_id=None, fallback_conn_ids=None, *, databricks_conn_id=None, **kwargs)[source]

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

Hook for Databricks Model Serving’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 databricks connection (personal access token, OAuth, Azure or federated credentials – whichever that connection is configured for) and refreshed on every request through BaseDatabricksHook._get_token. Username/password basic auth is not supported. The underlying httpx2.AsyncClient is built once and lives as long as this hook instance; nothing currently closes it.

Connection fields:
  • extra JSON: {"model": "my-serving-endpoint", "databricks_conn_id": "databricks_default"}

A bare model name is a serving endpoint name and is qualified as openai-chat:<endpoint>, so requests use the Chat Completions API. Databricks documents that API for chat endpoints (Foundation Model APIs, external models and custom LLM endpoints), not for every endpoint type. Databricks’ own limits on function calling and structured outputs apply; see the connection documentation for pointers.

A Databricks connection that sets the proxies or azure_resource_id extra is rejected, because this hook does not route requests through a proxy or send the Azure workspace resource headers.

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

  • model_id (str | None) – Serving endpoint name, e.g. "my-serving-endpoint".

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

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

conn_type = 'pydanticai_databricks'[source]
default_conn_name = 'pydanticai_databricks_default'[source]
hook_name = 'Pydantic AI (Databricks Model Serving)'[source]
model_provider = 'openai-chat'[source]
databricks_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 obtaining a Databricks token.

A missing or unusable credential is reported here. A personal access token is only checked for being set: it is not sent to the workspace, so a revoked or mistyped one still passes. Token types that are fetched from an identity provider are validated by that fetch. Does NOT call the serving endpoint.

Was this entry helpful?