airflow-ai-sdk
⚠️ Discontinuation of project
This project is no longer actively maintained by Astronomer. Development has been paused and we are not accepting new contributions, bug fixes or releases.
We recommend migrating to
apache-airflow-providers-common-ai, the official Apache Airflow provider for AI and LLM workflows, which is where new development now happens. See the migration guide for step-by-step instructions.The code is still here for you to explore, fork and adapt under the terms of its license. Please note that it may not work with the latest dependencies or platforms, and it could contain security vulnerabilities. Astronomer can't offer guarantees or warranties for its use.
If you're interested in adopting or stewarding this project, we'd be happy to chat, reach us at oss@astronomer.io. Thanks for being part of the open-source journey and helping keep great ideas alive!
A Python SDK for working with LLMs from Apache Airflow. It allows users to call LLMs and orchestrate agent calls directly within their Airflow pipelines using decorator-based tasks.
We find it's often helpful to rely on mature orchestration tooling like Airflow for instrumenting LLM workflows and agents in production, as these LLM workflows follow the same form factor as more traditional workflows like ETL pipelines, operational processes, and ML workflows.
Quick Start
pip install airflow-ai-sdk[openai]
Installing with no optional dependencies will give you the slim version of the package. The available optional dependencies are listed in pyproject.toml.
Features
- LLM tasks with
@task.llm: Define tasks that call language models to process text - Agent tasks with
@task.agent: Orchestrate multi-step AI reasoning with custom tools - Automatic output parsing: Use type hints to automatically parse and validate LLM outputs
- Branching with
@task.llm_branch: Change DAG control flow based on LLM output - Model support: All models in the Pydantic AI library (OpenAI, Anthropic, Gemini, etc.)
- Embedding tasks with
@task.embed: Create vector embeddings from text
[!TIP] You can find further information and a full DAG example for each of these decorators in the Airflow AI SDK Decorators & Code Snippets quick notes!
Example
from typing import Literal
import pendulum
from airflow.decorators import dag, task
from airflow.models.dagrun import DagRun
@task.llm(
model="gpt-4o-mini",
output_type=Literal["positive", "negative", "neutral"],
system_prompt="Classify the sentiment of the given text.",
)
def process_with_llm(dag_run: DagRun) -> str:
input_text = dag_run.conf.get("input_text")
# can do pre-processing here (e.g. PII redaction)
return input_text
@dag(
schedule=None,
start_date=pendulum.datetime(2025, 1, 1),
catchup=False,
params={"input_text": "I'm very happy with the product."},
)
def sentiment_classification():
process_with_llm()
sentiment_classification()
Examples Repository
To get started with a complete example environment, check out the examples repository, which offers a full local Airflow instance with the AI SDK installed and 5 example pipelines:
git clone https://github.com/astronomer/ai-sdk-examples.git
cd ai-sdk-examples
astro dev start
If you don't have the Astro CLI installed, run brew install astro or see other options here.
Documentation
For detailed documentation, see the docs directory:
License
Metadata
Release files for airflow-ai-sdk 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| airflow_ai_sdk-0.1.8.tar.gz | 234.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| airflow_ai_sdk-0.1.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 252.7 kB
Release files / airflow_ai_sdk-0.1.8.tar.gz
| Download URL | airflow_ai_sdk-0.1.8.tar.gz |
|---|---|
| Size | 234.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
286604097b590b82eac67f0922ef1e0a85299e95cb6add5680f30b8b7927cc60
|
|
BLAKE2b-256 checksum How to use checksums |
3c4a732f57ae090c10e55d2f1586b3ef291ea8f04f379a23f19de4244fafa411
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.6.10
|
Release files / airflow_ai_sdk-0.1.8-py3-none-any.whl
| Download URL | airflow_ai_sdk-0.1.8-py3-none-any.whl |
|---|---|
| Size | 18.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b340852dff19ea458ff260967607565ad408be5ee49f899c6bc5f27288409d0
|
|
BLAKE2b-256 checksum How to use checksums |
e8ca495dda700d20d60a5f02c0dcb8a588bd21f99bd9c3a4f9e6442deaad50c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.6.10
|
Security for airflow-ai-sdk 0.1.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.