apache-airflow-providers-common-ai¶
Run model calls and tool-using agents as Airflow tasks. A task can classify, extract, summarize or route with any model vendor, or hand a model a set of tools built from your Airflow connections and let it work. Airflow supplies what a script does not: the API key comes from a connection, a failed call retries, a run can pause for a person to approve the output, the result lands in XCom for the next task, and the whole thing runs on a schedule.
Start here¶
Quick start: install, connect a vendor, run a two-task Dag and check its output.
What you can build: ten jobs a data team already has, each with the Dag that does it.
Supported model providers: which vendors work, and the extra, connection and prefix for each.
This is the Dag the quick start runs. The summarize task sends the release notes to the
model on the pydanticai_default connection; publish receives the answer like any
other upstream result:
from airflow.sdk import dag, task
RELEASE_NOTES = """
Changes since the last release:
- Tasks can now carry a retry policy that decides whether a failure is worth retrying.
- Heartbeat writes are batched, which cut metadata database load by about a third in testing.
- Fixed a crash when two tasks in one Dag file shared a task id.
- Dropped support for Python 3.9.
"""
@dag(schedule=None, tags=["example"])
def quickstart_llm():
@task.llm(llm_conn_id="pydanticai_default", system_prompt="You write release announcements. Be concise.")
def summarize(notes: str):
return f"Summarize these release notes in two sentences for a team status update:\n{notes}"
@task
def publish(summary: str) -> dict[str, str | int]:
print(f"Release summary: {summary}")
return {"summary": summary, "characters": len(summary)}
publish(summarize(RELEASE_NOTES))
quickstart_llm()
Point pydanticai_default at OpenAI, Anthropic, Google, Bedrock or a self-hosted server
and the Dag does not change. Core concepts explains the ideas behind the provider in one
page.
When to use this provider¶
Use case |
Use |
Package |
|---|---|---|
Portable generation, classification, extraction, branching, or a worker-run agent with toolsets |
|
|
Many prompts through a batch API at half the price, with retry-safe re-attachment and results landed on object storage |
|
|
A vendor’s native Embeddings or Responses API, or a batch of raw provider request bodies (multi-turn, images, non-chat endpoints) |
The vendor’s own provider |
e.g. apache-airflow-providers-openai, apache-airflow-providers-anthropic, apache-airflow-providers-cohere |
A vendor-managed, server-side agent session (e.g. Anthropic Managed Agents) |
The vendor’s own provider |
As a rule of thumb: if Airflow should run the AI step (and the model should stay
swappable), use common.ai; if the Dag submits work to a vendor-managed service and
waits for the result, use that vendor’s provider.
apache-airflow-providers-common-ai package¶
AI/LLM hooks and operators for Airflow pipelines using pydantic-ai.
Release: 0.10.0
Provider package¶
This package is for the common.ai provider.
All classes for this package are included in the airflow.providers.common.ai python package.
Installation¶
You can install this package on top of an existing Airflow installation via
pip install apache-airflow-providers-common-ai.
For the minimum Airflow version supported, see Requirements below.
Requirements¶
The minimum Apache Airflow version supported by this provider distribution is 3.0.0.
PIP package |
Version required |
|---|---|
|
|
|
|
|
|
|
|
Optional cross provider package dependencies¶
Those are dependencies that might be needed in order to use all the features of the package. You need to install the specified provider distributions in order to use them.
You can install such cross-provider dependencies when installing from PyPI. For example:
pip install apache-airflow-providers-common-ai[common.sql]
Dependent package |
Extra |
|---|---|
|
|
|
Optional dependencies¶
These extras install optional third-party libraries that enable additional features of the provider. Install them when installing from PyPI. For example:
pip install apache-airflow-providers-common-ai[anthropic]
Extra |
Dependencies |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Downloading official packages¶
You can download officially released packages and verify their checksums and signatures from the Official Apache Download site