docs/ai_builder/features/installing_external_packages.md
import reflex as rx
Add a Python package when the app needs a library that is not already in its environment.
You can install one in either of these ways:
requirements.txt in Code, then save the file.Describe the outcome and name the package when you already know which one to use:
Use the requests package to call this REST endpoint. Add it to the app's
dependencies and handle timeouts and non-success responses.
rx.el.div(
rx.image(
src="https://web.reflex-assets.dev/docs-preview/ai-builder/platform/agent_package_install.webp",
alt="Installing external packages via the chat interface",
class_name="rounded-md h-auto mb-4",
border=f"0.81px solid {rx.color('slate', 5)}",
),
class_name="w-full flex flex-col rounded-md",
)
requirements.txtOpen requirements.txt in Code, add the package on its own line, and save. Reflex installs the dependency and recompiles the app.
rx.el.div(
rx.image(
src="https://web.reflex-assets.dev/docs-preview/ai-builder/platform/requirements_package_added.webp",
alt="Installing external packages via requirements.txt",
class_name="rounded-md h-auto mb-4",
border=f"0.81px solid {rx.color('slate', 5)}",
),
class_name="w-full flex flex-col rounded-md",
)
Pin or constrain dependencies used by a deployed app so future builds remain repeatable. Update those versions deliberately after reviewing compatibility. After installation, check Preview and the build output for import or compatibility errors.
Some packages are too large or require system dependencies that are unavailable in the Builder environment. When that happens, use a hosted API or another supported service instead.