Python in open-source AI tools: the language behind RAG platforms, agents and gateways in 2026
Why AI runs on Python
Python became the language of machine learning in the 2010s through NumPy, scikit-learn and then PyTorch and TensorFlow. Its syntax is easy for researchers, it interoperates well with C, C++ and CUDA code that does the heavy maths, and Jupyter notebooks made it the default for experiments. When large language models arrived, the libraries for loading, fine-tuning and serving them were Python, and so were the first agent and RAG frameworks, LangChain and LlamaIndex, both released in 2022.
The result is that most open-source AI back ends in 2026 are Python services: they receive requests from a web front end, call a model through an API or a local runtime, retrieve documents from a vector database, and return results.
Which directory projects use it
| Project | What it is | Python's role |
|---|---|---|
| Dify | LLM app platform | API server and workers (Flask, Celery); front end is Next.js |
| Langflow | Visual flow builder | FastAPI back end and components; React front end |
| Browser Use | Browser automation for agents | Library built on Playwright |
| Skyvern | Browser workflow automation | FastAPI service with vision models |
| Letta | Agents with long-term memory | Server and SDK |
| Mem0 | Memory layer for AI apps | Library and server |
| LiteLLM | Model gateway | SDK and FastAPI proxy |
| Aider | Terminal coding agent | Entire tool |
| OpenHands | Autonomous coding agent | Agent server and runtime |
Extending any of these, such as writing a custom Dify tool, a Langflow component or a Browser Use action, means writing Python.
Python 3.15
Python 3.15.0 was released on October 9, 2026, following the annual October schedule. Changes that matter for AI projects include:
- Lazy imports. PEP 810 adds explicit lazy imports, so a module is loaded only when first used. AI libraries import large packages such as PyTorch, and lazy imports can cut command-line startup from seconds to a fraction of a second.
- UTF-8 by default. PEP 686 makes UTF-8 the default text encoding on every platform, removing a long-standing source of errors when reading documents on Windows.
- Profiling. A new low-overhead sampling profiler helps find slow code in long-running services.
Python 3.15.1 followed on October 21, 2026, as an expedited security and maintenance release. It upgraded the bundled pip to 26.2.2 in response to the eMudhra/emSign certificate authority incident, which led several software vendors in October to remove trust for certificates from a compromised intermediate authority.
Python 3.14, released in October 2025, made the free-threaded build, which runs without the global interpreter lock, officially supported. Free-threaded Python lets CPU-heavy Python code use multiple cores in one process. For AI services it helps preprocessing, tokenization and data loading; many native libraries now publish free-threaded builds, but check compatibility before switching.
Which version to run
| Version | Status in October 2026 | Advice |
|---|---|---|
| 3.15 | Newest, bug fixes | Wait for your libraries to support it |
| 3.14 | Bug fixes | Good for new projects if dependencies support it |
| 3.13 | Security fixes | Safe, widely supported |
| 3.12 | Security fixes | Safest for older AI libraries |
| 3.10 and 3.11 | Security fixes until 2026 and 2027 | Plan to upgrade |
AI libraries with compiled extensions, such as PyTorch, often support a new Python release a few months after it ships. Check the project's pyproject.toml for its requires-python setting before choosing.
Packaging with uv
Dependency conflicts were the single biggest headache in Python AI projects: two libraries pinned different versions of the same dependency, CUDA builds of PyTorch needed special index URLs, and installs took minutes. uv, from Astral, released in 2024, addressed much of this. It resolves and installs dependencies many times faster than pip, writes a lock file for reproducible installs, manages Python versions itself, and handles PyTorch's CUDA-specific indexes through configuration.
A typical install of a Python AI tool from source now looks like:
uv sync
uv run python -m app
Aider, Browser Use and many other projects document uv tool install or uvx to run them without touching the system Python.
What it means for self-hosting
- Docker is easiest. Python projects with many dependencies are far simpler to run as containers. Dify, Langflow and LiteLLM all publish official images.
- Workers and queues. Python back ends often split into an API process and background workers using Celery or a similar queue with Redis. Scale workers separately.
- Memory. A Python worker that loads an embedding model or tokenizer can use 1 to 4 GB. Count workers carefully on small servers.
- GPU builds. If a project runs models locally, install the CUDA build of PyTorch that matches your driver. The CPU build installs by default on many systems and runs very slowly.
- Supply chain. PyPI has seen malicious uploads, including the compromised LiteLLM releases of March and October 2026. Pin versions, use lock files, and prefer official images.
Notebooks and scripts
Much AI work in Python starts in a Jupyter notebook: loading a dataset, trying prompts, measuring retrieval quality. Projects such as Langflow and Dify let you prototype visually and then export or call flows from Python scripts. When a notebook experiment becomes a service, move the code into a package with tests and a lock file before deploying it, since notebooks hide state and run cells out of order.
Async web frameworks
Python AI services mostly use FastAPI or Flask for HTTP, and Django for full applications with admin panels. FastAPI's async support suits model calls, which spend most of their time waiting on network responses, and its Pydantic models validate structured output from language models.
Python compared with TypeScript and Go
| Concern | Python | TypeScript | Go |
|---|---|---|---|
| AI and ML libraries | Most extensive | Growing | Few |
| Web front end | Separate | Native | Separate |
| Single binary deploys | No | No | Yes |
| Concurrency | Async, free-threaded builds | Event loop | Goroutines |
| Typical AI use | Back ends, agents, RAG, research | Chat UIs, product apps | Runtimes, gateways, infra |
Contributing
Python AI projects typically use Ruff for linting and formatting, pytest for tests, and either uv or Poetry for dependencies. Many tests call model APIs; look for a mock or recorded-response mode so you can run the suite without paying for tokens. Type hints are common and checked with mypy or Pyright. Start with an issue labelled "good first issue", and run the formatter before pushing, since most projects enforce it in CI.
Related: FastAPI stack, Django stack, TypeScript stack, Hugging Face stack, Playwright stack, Stack index.
Frequently asked questions
Why is Python used for AI?
PyTorch, JAX, Hugging Face Transformers, NumPy and almost every research library are Python-first, so models are trained, evaluated and often served from Python. Agent and RAG frameworks followed, because their authors already worked there. Python's slow interpreter matters little when the heavy work runs on GPUs in C++ and CUDA.
Which Python version should I use for AI projects?
Use the version the project's documentation names, usually stated in pyproject.toml. Many AI libraries take a few months to support a new Python release, so in late 2026 Python 3.12 and 3.13 are the safest choices for compatibility, with 3.14 widely supported and 3.15 still being adopted.
What is uv?
uv is a fast Python package and project manager from Astral, written in Rust. It installs Python versions, creates virtual environments, resolves and locks dependencies, and runs scripts, replacing pip, pip-tools, pyenv and virtualenv for most uses. Many AI projects now document uv as the install method.
Do I need Python to self-host Dify or Langflow?
Not if you use Docker, which both projects recommend. Python matters if you install from source, write custom components or tools, or contribute code.
Is Python too slow for production AI services?
For most AI services, no. Time is dominated by model inference, which runs in optimized native code, and by network calls to model APIs. Python async frameworks such as FastAPI handle many concurrent requests. Where overhead matters, projects move hot paths to Rust or Go, as LiteLLM has done for some components.