Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Framework for building LLM-powered applications with agents, chains, and RAG. Supports multiple providers (OpenAI, Anthropic, Google), 500+ integrations, ReAct agents, tool calling, memory management, and vector store retrieval. Use for building chatbots, question-answering systems, autonomous agents, or RAG applications. Best for rapid prototyping and production deployments.
.claude/skills/openlair-langchain/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | 177% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 108% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 139% | 0% |
| case-13 | ✗→✓ | ▲ Improved | 136% | 0% |
| case-15 | ✗→✓ | ▲ Improved | 100% | 0% |
The most popular framework for building LLM-powered applications.
Use LangChain when:
Metrics:
Use alternatives instead:
bash# Core library (Python 3.10+) pip install -U langchain # With OpenAI pip install langchain-openai # With Anthropic pip install langchain-anthropic # Common extras pip install langchain-community # 500+ integrations pip install langchain-chroma # Vector store
pythonfrom langchain_anthropic import ChatAnthropic # Initialize model llm = ChatAnthropic(model="claude-sonnet-4-5-20250929") # Simple completion response = llm.invoke("Explain quantum computing in 2 sentences") print(response.content)
pythonfrom langchain.agents import create_agent from langchain_anthropic import ChatAnthropic # Define tools def get_weather(city: str) -> str: """Get current weather for a city.""" return f"It's sunny in {city}, 72°F" def search_web(query: str) -> str: """Search the web for information.""" return f"Search results for: {query}" # Create agent (<10 lines!) agent = create_agent( model=ChatAnthropic(model="claude-sonnet-4-5-20250929"), tools=[get_weather, search_web], system_prompt="You are a helpful assistant. Use tools when needed." ) # Run agent result = agent.invoke({"messages": [{"role": "user", "content": "What's the weather in Paris?"}]}) print(result["messages"][-1].content)
pythonfrom langchain_openai import ChatOpenAI from langchain_anthropic import ChatAnthropic from langchain_google_genai import ChatGoogleGenerativeAI # Swap providers easily llm = ChatOpenAI(model="gpt-4o") llm = ChatAnthropic(model="claude-sonnet-4-5-20250929") llm = ChatGoogleGenerativeAI(model="gemini-2.0-flash-exp") # Streaming for chunk in llm.stream("Write a poem"): print(chunk.content, end="", flush=True)
pythonfrom langchain.chains import LLMChain from langchain.prompts import PromptTemplate # Define prompt template prompt = PromptTemplate( input_variables=["topic"], template="Write a 3-sentence summary about {topic}" ) # Create chain chain = LLMChain(llm=llm, prompt=prompt) # Run chain result = chain.run(topic="machine learning")
ReAct (Reasoning + Acting) pattern:
pythonfrom langchain.agents import create_tool_calling_agent, AgentExecutor from langchain.tools import Tool # Define custom tool calculator = Tool( name="Calculator", func=lambda x: eval(x), description="Useful for math calculations. Input: valid Python expression." ) # Create agent with tools agent = create_tool_calling_agent( llm=llm, tools=[calculator, search_web], prompt="Answer questions using available tools" ) # Create executor agent_executor = AgentExecutor(agent=agent, tools=[calculator], verbose=True) # Run with reasoning result = agent_executor.invoke({"input": "What is 25 * 17 + 142?"})
pythonfrom langchain.memory import ConversationBufferMemory from langchain.chains import ConversationChain # Add memory to track conversation memory = ConversationBufferMemory() conversation = ConversationChain( llm=llm, memory=memory, verbose=True ) # Multi-turn conversation conversation.predict(input="Hi, I'm Alice") conversation.predict(input="What's my name?") # Remembers "Alice"
pythonfrom langchain_community.document_loaders import WebBaseLoader from langchain.text_splitter import RecursiveCharacterTextSplitter from langchain_openai import OpenAIEmbeddings from langchain_chroma import Chroma from langchain.chains import RetrievalQA # 1. Load documents loader = WebBaseLoader("https://docs.python.org/3/tutorial/") docs = loader.load() # 2. Split into chunks text_splitter = RecursiveCharacterTextSplitter( chunk_size=1000, chunk_overlap=200 ) splits = text_splitter.split_documents(docs) # 3. Create embeddings and vector store vectorstore = Chroma.from_documents( documents=splits, embedding=OpenAIEmbeddings() ) # 4. Create retriever retriever = vectorstore.as_retriever(search_kwargs={"k": 4}) # 5. Create QA chain qa_chain = RetrievalQA.from_chain_type( llm=llm, retriever=retriever, return_source_documents=True ) # 6. Query result = qa_chain({"query": "What are Python decorators?"}) print(result["result"]) print(f"Sources: {result['source_documents']}")
pythonfrom langchain.chains import ConversationalRetrievalChain # RAG with conversation memory qa = ConversationalRetrievalChain.from_llm( llm=llm, retriever=retriever, memory=ConversationBufferMemory( memory_key="chat_history", return_messages=True ) ) # Multi-turn RAG qa({"question": "What is Python used for?"}) qa({"question": "Can you elaborate on web development?"}) # Remembers context
pythonfrom langchain_core.pydantic_v1 import BaseModel, Field # Define schema class WeatherReport(BaseModel): city: str = Field(description="City name") temperature: float = Field(description="Temperature in Fahrenheit") condition: str = Field(description="Weather condition") # Get structured response structured_llm = llm.with_structured_output(WeatherReport) result = structured_llm.invoke("What's the weather in SF? It's 65F and sunny") print(result.city, result.temperature, result.condition)
pythonfrom langchain.agents import create_tool_calling_agent # Agent automatically parallelizes independent tool calls agent = create_tool_calling_agent( llm=llm, tools=[get_weather, search_web, calculator] ) # This will call get_weather("Paris") and get_weather("London") in parallel result = agent.invoke({ "messages": [{"role": "user", "content": "Compare weather in Paris and London"}] })
python# Stream agent steps for step in agent_executor.stream({"input": "Research AI trends"}): if "actions" in step: print(f"Tool: {step['actions'][0].tool}") if "output" in step: print(f"Output: {step['output']}")
pythonfrom langchain.chains.qa_with_sources import load_qa_with_sources_chain # Load multiple documents docs = [ loader.load("https://docs.python.org"), loader.load("https://docs.numpy.org") ] # QA with source citations chain = load_qa_with_sources_chain(llm, chain_type="stuff") result = chain({"input_documents": docs, "question": "How to use numpy arrays?"}) print(result["output_text"]) # Includes source citations
pythonfrom langchain.tools import tool @tool def risky_operation(query: str) -> str: """Perform a risky operation that might fail.""" try: # Your operation here result = perform_operation(query) return f"Success: {result}" except Exception as e: return f"Error: {str(e)}" # Agent handles errors gracefully agent = create_agent(model=llm, tools=[risky_operation])
pythonimport os # Enable tracing os.environ["LANGCHAIN_TRACING_V2"] = "true" os.environ["LANGCHAIN_API_KEY"] = "your-api-key" os.environ["LANGCHAIN_PROJECT"] = "my-project" # All chains/agents automatically traced agent = create_agent(model=llm, tools=[calculator]) result = agent.invoke({"input": "Calculate 123 * 456"}) # View traces at smith.langchain.com
pythonfrom langchain_chroma import Chroma vectorstore = Chroma.from_documents( documents=docs, embedding=OpenAIEmbeddings(), persist_directory="./chroma_db" )
pythonfrom langchain_pinecone import PineconeVectorStore vectorstore = PineconeVectorStore.from_documents( documents=docs, embedding=OpenAIEmbeddings(), index_name="my-index" )
pythonfrom langchain_community.vectorstores import FAISS vectorstore = FAISS.from_documents(docs, OpenAIEmbeddings()) vectorstore.save_local("faiss_index") # Load later vectorstore = FAISS.load_local("faiss_index", OpenAIEmbeddings())
python# Web pages from langchain_community.document_loaders import WebBaseLoader loader = WebBaseLoader("https://example.com") # PDFs from langchain_community.document_loaders import PyPDFLoader loader = PyPDFLoader("paper.pdf") # GitHub from langchain_community.document_loaders import GithubFileLoader loader = GithubFileLoader(repo="user/repo", file_filter=lambda x: x.endswith(".py")) # CSV from langchain_community.document_loaders import CSVLoader loader = CSVLoader("data.csv")
python# Recursive (recommended for general text) from langchain.text_splitter import RecursiveCharacterTextSplitter splitter = RecursiveCharacterTextSplitter( chunk_size=1000, chunk_overlap=200, separators=["\n\n", "\n", " ", ""] ) # Code-aware from langchain.text_splitter import PythonCodeTextSplitter splitter = PythonCodeTextSplitter(chunk_size=500) # Semantic (by meaning) from langchain_experimental.text_splitter import SemanticChunker splitter = SemanticChunker(OpenAIEmbeddings())
create_agent() for most cases| Operation | Latency | Notes | |-----------|---------|-------| | Simple LLM call | ~1-2s | Depends on provider | | Agent with 1 tool | ~3-5s | ReAct reasoning overhead | | RAG retrieval | ~0.5-1s | Vector search + LLM | | Embedding 1000 docs | ~10-30s | Depends on model |
| Feature | LangChain | LangGraph | |---------|-----------|-----------| | Best for | Quick agents, RAG | Complex workflows | | Abstraction level | High | Low | | Code to start | <10 lines | ~30 lines | | Control | Simple | Full control | | Stateful workflows | Limited | Native | | Cyclic graphs | No | Yes | | Human-in-loop | Basic | Advanced |
Use LangGraph when:
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | pass→pass | 9,713 | 8,758 | -10% | 1 | 1 | 0% | 2,020 | 5,291 | +162% | 0 | 0 | — |
case-02 | fail→pass | 7,192 | 4,949 | -31% | 1 | 1 | 0% | 1,600 | 4,424 | +177% | 0 | 0 | — |
case-03 | fail→pass | 13,633 | 9,776 | -28% | 1 | 1 | 0% | 2,634 | 5,489 | +108% | 0 | 0 | — |
case-04 | pass→pass | 8,912 | 7,535 | -15% | 1 | 1 | 0% | 1,887 | 5,206 | +176% | 0 | 0 | — |
case-05 | pass→pass | 10,882 | 6,139 | -44% | 1 | 1 | 0% | 2,203 | 4,629 | +110% | 0 | 0 | — |
case-06 | pass→pass | 12,236 | 7,555 | -38% | 1 | 1 | 0% | 2,309 | 4,827 | +109% | 0 | 0 | — |
case-07 | pass→pass | 11,079 | 8,686 | -22% | 1 | 1 | 0% | 2,077 | 5,304 | +155% | 0 | 0 | — |
case-08 | pass→pass | 6,260 | 2,900 | -54% | 1 | 1 | 0% | 1,335 | 4,000 | +200% | 0 | 0 | — |
case-09 | fail→pass | 9,608 | 4,487 | -53% | 1 | 1 | 0% | 1,812 | 4,324 | +139% | 0 | 0 | — |
case-10 | pass→pass | 4,883 | 2,742 | -44% | 1 | 1 | 0% | 1,020 | 3,957 | +288% | 0 | 0 | — |
case-11 | pass→pass | 3,416 | 3,103 | -9% | 1 | 1 | 0% | 662 | 3,984 | +502% | 0 | 0 | — |
case-12 | pass→pass | 9,084 | 6,024 | -34% | 1 | 1 | 0% | 1,626 | 4,764 | +193% | 0 | 0 | — |
case-13 | fail→pass | 14,452 | 10,758 | -26% | 1 | 1 | 0% | 2,434 | 5,739 | +136% | 0 | 0 | — |
case-14 | pass→pass | 7,237 | 3,509 | -52% | 1 | 1 | 0% | 1,232 | 3,894 | +216% | 0 | 0 | — |
case-15 | fail→pass | 15,137 | 8,050 | -47% | 1 | 1 | 0% | 2,336 | 4,678 | +100% | 0 | 0 | — |
case-16 | pass→pass | 9,187 | 4,967 | -46% | 1 | 1 | 0% | 1,547 | 4,290 | +177% | 0 | 0 | — |
case-17 | pass→pass | 4,814 | 4,212 | -13% | 1 | 1 | 0% | 682 | 4,013 | +488% | 0 | 0 | — |
case-18 | pass→pass | 12,817 | 6,685 | -48% | 1 | 1 | 0% | 2,084 | 4,617 | +122% | 0 | 0 | — |
case-19 | pass→pass | 14,409 | 13,031 | -10% | 1 | 1 | 0% | 2,294 | 5,449 | +138% | 0 | 0 | — |
case-20 | pass→pass | 13,950 | 10,694 | -23% | 1 | 1 | 0% | 1,940 | 4,966 | +156% | 0 | 0 | — |
case-21 | pass→pass | 16,722 | 14,222 | -15% | 1 | 1 | 0% | 2,536 | 5,710 | +125% | 0 | 0 | — |
case-22 | pass→pass | 15,712 | 12,584 | -20% | 1 | 1 | 0% | 2,532 | 5,506 | +117% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +23 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.