{"name":"Air: The Modern Python Web Framework for FastAPI and Pydantic","description":"Air is a new Python web framework developed by the authors of \"Two Scoops of Django.\" It leverages FastAPI, Starlette, and Pydantic to provide a fast and intuitive development experience. Designed for building both APIs and web pages, Air offers features like Air Tags for HTML generation, Jinja2 integration, and HTMX support, aiming to breathe fresh air into Python web development.","github":"https://github.com/feldroy/air","url":"https://osrepos.com/repo/feldroy-air","source":"osrepos.com","sourceDescription":"This repository profile is provided by osrepos.com, an open source repository discovery platform.","repositoryProfile":"https://osrepos.com/repo/feldroy-air","generatedFor":"open source discovery and AI-assisted research","markdown":"https://osrepos.com/repo/feldroy-air.md","json":"https://osrepos.com/repo/feldroy-air.json","topics":["fastapi","pydantic","python","starlette","web","web development","framework"],"keywords":["fastapi","pydantic","python","starlette","web","web development","framework"],"stars":null,"summary":"Air is a new Python web framework developed by the authors of \"Two Scoops of Django.\" It leverages FastAPI, Starlette, and Pydantic to provide a fast and intuitive development experience. Designed for building both APIs and web pages, Air offers features like Air Tags for HTML generation, Jinja2 integration, and HTMX support, aiming to breathe fresh air into Python web development.","content":"## Introduction\n\nAir is a new Python web framework created by the authors of \"Two Scoops of Django.\" It aims to simplify web development by building upon popular and robust libraries like FastAPI, Starlette, and Pydantic. Air allows developers to efficiently build both RESTful APIs and dynamic web pages within a single application, offering a fresh approach to Python web development.\n\n## Installation\n\nTo get started with Air, you can install it using pip or conda:\n\nsh\npip install -U air\n# or\nconda install air -c conda-forge\n\n\nFor `uv` users, follow these steps:\n\nsh\nuv venv\nsource .venv/bin/activate\nuv init\nuv add air\n\n\nYou can also install optional features (extras) to extend Air's capabilities:\n\nsh\n# Standard extras (FastAPI’s recommended)\nuv add \"air[standard]\"\n\n# Pretty HTML Rendering (lxml, rich)\nuv add \"air[pretty]\"\n\n# SQLModel / SQLAlchemy support\nuv add \"air[sqlmodel]\"\n\n# OAuth clients via Authlib\nuv add \"air[auth]\"\n\n# All extras\nuv add \"air[all]\"\n\n\nYou can combine extras in one command, for example: `uv add \"air[pretty,sql]\"`.\n\n## Examples\n\n### A Simple Example\n\nCreate a `main.py` with:\n\npython\nimport air\n\napp = air.Air()\n\n\n@app.get(\"/\")\nasync def index():\n    return air.Html(air.H1(\"Hello, world!\", style=\"color: blue;\"))\n\n\nRun the app with:\n\nsh\nfastapi dev\n\n\nIf you have fastapi installed globally, you may see an error. In that case, run the app with:\n\nsh\nuv run fastapi dev\n\n\nThis example uses Air Tags, which are Python classes that render as HTML. Air Tags are typed and documented, designed to work well with any code completion tool.\n\n### Combining FastAPI and Air\n\nAir is just a layer over FastAPI, making it trivial to combine sophisticated HTML pages and a REST API into one app.\n\npython\nimport air\nfrom fastapi import FastAPI\n\napp = air.Air()\napi = FastAPI()\n\n@app.get(\"/\")\ndef landing_page():\n    return air.Html(\n        air.Head(air.Title(\"Awesome SaaS\")),\n        air.Body(\n            air.H1(\"Awesome SaaS\"),\n            air.P(air.A(\"API Docs\", target=\"_blank\", href=\"/api/docs\")),\n        ),\n    )\n\n\n@api.get(\"/\")\ndef api_root():\n    return {\"message\": \"Awesome SaaS is powered by FastAPI\"}\n\n# Combining the Air and FastAPI apps into one\napp.mount(\"/api\", api)\n\n\n### Combining FastAPI and Air using Jinja2\n\nIf you prefer using Jinja2 instead of Air Tags, Air has you covered.\n\npython\nimport air\nfrom air.requests import Request\nfrom fastapi import FastAPI\n\napp = air.Air()\napi = FastAPI()\n\n# Air's JinjaRenderer is a shortcut for using Jinja templates\njinja = air.JinjaRenderer(directory=\"templates\")\n\n@app.get(\"/\")\ndef index(request: Request):\n    return jinja(request, name=\"home.html\")\n\n@api.get(\"/\")\ndef api_root():\n    return {\"message\": \"Awesome SaaS is powered by FastAPI\"}\n\n# Combining the Air and and FastAPI apps into one\napp.mount(\"/api\", api)\n\n\nDon't forget the Jinja template! Create a `templates/home.html` file with:\n\nhtml\n<!doctype html>\n<html>\n    <head>\n        <title>Awesome SaaS</title>\n    </head>\n    <body>\n        <h1>Awesome SaaS</h1>\n        <p>\n            <a target=\"_blank\" href=\"/api/docs\">API Docs</a>\n        </p>\n    </body>\n</html>\n\n\nUsing Jinja with Air is designed to be easier than with FastAPI directly.\n\n## Why use Air?\n\nAir offers several compelling reasons for developers to choose it:\n\n*   **Powered by FastAPI**: Designed to work with FastAPI so you can serve your API and web pages from one app.\n*   **Fast to code**: Tons of intuitive shortcuts and optimizations designed to expedite coding HTML with FastAPI.\n*   **Air Tags**: Easy to write and performant HTML content generation using Python classes to render HTML.\n*   **Jinja Friendly**: No need to write `response_class=HtmlResponse` and `templates.TemplateResponse` for every HTML view.\n*   **Mix Jinja and Air Tags**: Jinja and Air Tags both are first class citizens. Use either or both in the same view!\n*   **HTMX friendly**: We love HTMX and provide utilities to use it with Air.\n*   **HTML form validation powered by Pydantic**: Air Forms provide two ways to use Pydantic with HTML forms (dependency injection or from within views).\n*   **Easy to learn yet well documented**: Hopefully Air is so intuitive and well-typed you'll barely need to use the documentation. In case you do need to look something up we're taking our experience writing technical books and using it to make documentation worth boasting about.\n\n## Links\n\nFor more information, refer to the official documentation and source code:\n\n*   Documentation: [https://airdocs.fastapicloud.dev/](https://airdocs.fastapicloud.dev/){:target=\"_blank\"}\n*   Source Code: [https://github.com/feldroy/air](https://github.com/feldroy/air){:target=\"_blank\"}","metrics":{"detailViews":3,"githubClicks":3},"dates":{"published":null,"modified":"2025-11-06T00:01:10.000Z"}}