Airflow Summit 2026 is coming August 31 - September 2 in Austin, TX. Register now to secure your spot!

Quick start

Go from zero to a generated model response in three steps: install the provider, configure a connection, and write a Dag.

1. Install

pip install apache-airflow-providers-openai

2. Configure the connection

Every call goes through an OpenAI connection (conn_type openai, default connection id openai_default). Specify your OpenAI API key in the password field. See OpenAI Connection for the full reference, including workload identity authentication (Kubernetes, Azure, GCP, or a custom token provider) if you’d rather exchange short-lived identity tokens than store a long-lived API key.

The quickest way to set one up is an environment variable:

export AIRFLOW_CONN_OPENAI_DEFAULT='{"conn_type": "openai", "password": "sk-..."}'

Or add it through the Airflow UI (Admin > Connections) or the CLI (airflow connections add).

3. Write your first Dag

The OpenAIResponseOperator generates a model response with the OpenAI Responses API and returns the response’s aggregated output text:

airflow/providers/openai/example_dags/example_response.py[source]

from __future__ import annotations

# This is for Airflow 2.11. For Airflow 3+, use `from airflow.sdk import dag`
from airflow.providers.common.compat.sdk import dag
from airflow.providers.openai.operators.openai import OpenAIResponseOperator


@dag(tags=["example"])
def quickstart_openai():
    OpenAIResponseOperator(
        task_id="generate_response",
        conn_id="openai_default",
        input_text="Write a one-sentence summary of Apache Airflow.",
    )


quickstart_openai()

Run it like any other Dag (airflow dags test quickstart_openai) and the generate_response task pushes the aggregated output text to XCom.

Where to go next

  • OpenAIEmbeddingOperator — the full operator set: embeddings with OpenAIEmbeddingOperator, batch jobs with OpenAITriggerBatchOperator, and the Responses/Conversations OpenAIHook methods for use inside @task functions.

  • OpenAI Connection — the full connection reference, including workload identity authentication.

Was this entry helpful?