Skip to main content

langchain-flagsmith

PyPI - Version PyPI - License PyPI - Python Version

The Flagsmith integration for LangChain and LangGraph.

Quick Install

pip install langchain-flagsmith

Add [langgraph] for hand-built LangGraph graphs, or [agent] to also install LangChain for create_agent.

What is this?

langchain-flagsmith lets you control a LangChain agent from Flagsmith feature flags. Flip a flag and the running agent picks it up on its next refresh. No redeploy.

One flag each for:

  • Model: llm_model switches between models you list in a catalog.
  • Prompt: system_prompt replaces the system message.
  • Tools: tool_<name> turns one tool on or off.
  • Kill switch: agent_enabled stops the agent with a safe answer.

Segments and percentage splits work too, so you can give one model to beta users or A/B test a prompt.

Usage

pip install "langchain-flagsmith[agent]" langchain-openai
import os

from langchain.agents import create_agent
from langchain_openai import ChatOpenAI
from langchain_flagsmith import AgentFlags, Catalog, Fixed

flags = AgentFlags(
    os.environ["FLAGSMITH_SERVER_KEY"],  # server-side key, starts with "ser."
    catalog=Catalog(
        default="fast",
        entries=[
            Fixed("fast", lambda: ChatOpenAI(model="gpt-4o-mini")),
            Fixed("smart", lambda: ChatOpenAI(model="gpt-4o")),
        ],
    ),
    refresh_interval=5,  # seconds between flag fetches. Default 60. A webhook is instant.
)

agent = create_agent(ChatOpenAI(model="gpt-4o-mini"), tools=[], middleware=[flags.middleware()])

out = agent.invoke(
    {"messages": [("user", "hi")]},
    config={"configurable": {"user_id": "u1"}},
)

Already have an agent? Wrap the model in one line: model = flags.wrap(ChatOpenAI(...)).

Documentation

License

MIT

Metadata

Release files for langchain-flagsmith 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-flagsmith 0.1.0
File Size Uploaded Provenance Actions
langchain_flagsmith-0.1.0.tar.gz 72.5 kB With provenance Details for langchain_flagsmith-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-flagsmith 0.1.0
File Interpreter ABI Platform Actions
langchain_flagsmith-0.1.0-py3-none-any.whl Python 3 none any Details for langchain_flagsmith-0.1.0-py3-none-any.whl

Total release size: 118.0 kB

Release files / langchain_flagsmith-0.1.0.tar.gz

Download URL langchain_flagsmith-0.1.0.tar.gz
Size 72.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c8434e0d83c33b300ad193cc827dfebdfb2e8633aecfe7734a4aa94e6476f03f
BLAKE2b-256 checksum
How to use checksums
8a50c42a397182a0dc53090e40e4dde25a86c53978c85e4fb186afa0b57e7d09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / langchain_flagsmith-0.1.0-py3-none-any.whl

Download URL langchain_flagsmith-0.1.0-py3-none-any.whl
Size 45.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e231f7268f65edaea148c5c5d040df9b224e44e135373e61a0a24b9effd235f3
BLAKE2b-256 checksum
How to use checksums
e680a3b46c07ab5deccf2db31a248403015f1f8b1a3bea8b72fffe19c4af426e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for langchain-flagsmith 0.1.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_flagsmith-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page